Documentation
¶
Overview ¶
Package gitrepo is a thin wrapper over the system git binary.
Shelling out to real git is deliberate. A reimplementation (go-git and friends) would produce diffs that differ in formatting and rename detection from what the reviewer sees when they run git themselves, and linking a C library would reintroduce the runtime dependency this tool exists without. Requiring git on PATH costs nothing: without a repository there is nothing for jaira to operate on.
Index ¶
- Variables
- func Available() bool
- type Commit
- type Repo
- func (r *Repo) Commits(shas []string) ([]Commit, error)
- func (r *Repo) CommitsForTicket(ticketPath, ticketID string) ([]string, error)
- func (r *Repo) Diff(shas []string) (string, error)
- func (r *Repo) HeadSHA() (string, error)
- func (r *Repo) IsRepo() bool
- func (r *Repo) Root() (string, error)
- func (r *Repo) Stat(shas []string) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNoGit = errors.New("gitrepo: git is not available on PATH")
ErrNoGit means the git binary is unavailable.
Functions ¶
Types ¶
type Commit ¶
type Commit struct {
SHA string `json:"sha"`
Short string `json:"short"`
Subject string `json:"subject"`
Author string `json:"author"`
Date string `json:"date"`
}
Commit describes one commit for display on a ticket.
type Repo ¶
type Repo struct{ Dir string }
Repo is a git working tree.
func (*Repo) Commits ¶
Commits resolves metadata for the SHAs recorded on a ticket. Unknown SHAs are returned with empty metadata rather than dropped, so a ticket referencing a commit from an unfetched branch still shows what it claims.
func (*Repo) CommitsForTicket ¶ added in v0.1.1
CommitsForTicket works out which commits carry a ticket, so a person never has to type a sha by hand for the tool to know it. The result is the union of two independent sources, because neither alone finds every commit that belongs to a ticket: a commit can touch the ticket file without naming the ticket in its message (a rename, a bulk edit), and a commit can name the ticket without touching its file (the source change the ticket describes). The returned shas are oldest-first, since the recorded list is read as the history of the ticket and every caller records it the same way.
func (*Repo) Diff ¶
Diff returns the combined patch for a set of commits, scoped to those commits rather than to the working tree — a reviewer is judging what the ticket shipped, not whatever happens to be uncommitted right now.