Documentation ¶
Overview ¶
Package gitinfo enables querying info from Git repository using git and a local checkout.
Index ¶
- func GetBranchCommits(ctx context.Context, co git.Checkout, branch string) ([]*vcsinfo.IndexCommit, error)
- type GitBranch
- type GitInfo
- func (g *GitInfo) ByIndex(ctx context.Context, N int) (*vcsinfo.LongCommit, error)
- func (g *GitInfo) Checkout(ctx context.Context, ref string) error
- func (g *GitInfo) Details(ctx context.Context, hash string, includeBranchInfo bool) (*vcsinfo.LongCommit, error)
- func (g *GitInfo) DetailsMulti(ctx context.Context, hashes []string, includeBranchInfo bool) ([]*vcsinfo.LongCommit, error)
- func (g *GitInfo) Dir() string
- func (g *GitInfo) From(start time.Time) []string
- func (g *GitInfo) FullHash(ctx context.Context, ref string) (string, error)
- func (g *GitInfo) GetBranch() string
- func (g *GitInfo) GetBranches(ctx context.Context) ([]*GitBranch, error)
- func (g *GitInfo) IndexOf(ctx context.Context, hash string) (int, error)
- func (g *GitInfo) InitialCommit(ctx context.Context) (string, error)
- func (g *GitInfo) LastN(ctx context.Context, N int) []string
- func (g *GitInfo) LastNIndex(N int) []*vcsinfo.IndexCommit
- func (g *GitInfo) Log(ctx context.Context, begin, end string) (string, error)
- func (g *GitInfo) LogArgs(ctx context.Context, args ...string) (string, error)
- func (g *GitInfo) LogFine(ctx context.Context, begin, end string, args ...string) (string, error)
- func (g *GitInfo) Range(begin, end time.Time) []*vcsinfo.IndexCommit
- func (g *GitInfo) Reset(ctx context.Context, ref string) error
- func (g *GitInfo) RevList(ctx context.Context, args ...string) ([]string, error)
- func (g *GitInfo) ShortList(ctx context.Context, begin, end string) (*ShortCommits, error)
- func (g *GitInfo) Timestamp(hash string) time.Time
- func (g *GitInfo) TimestampAtIndex(N int) (time.Time, error)
- func (g *GitInfo) Update(ctx context.Context, pull, allBranches bool) error
- type ShortCommits
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBranchCommits ¶
func GetBranchCommits(ctx context.Context, co git.Checkout, branch string) ([]*vcsinfo.IndexCommit, error)
GetBranchCommits gets all the commits in the given branch and directory in topological order and only with the first parent (omitting commits from branches that are merged in). The earliest commits are returned first. Note: Primarily used for testing and will probably be removed in the future.
Types ¶
type GitInfo ¶
type GitInfo struct {
// contains filtered or unexported fields
}
GitInfo allows querying a Git repo.
func CloneOrUpdate ¶
CloneOrUpdate creates a new GitInfo by running "git clone" or "git pull" depending on whether the repo already exists.
func NewGitInfo ¶
NewGitInfo creates a new GitInfo for the Git repository found in directory dir. If pull is true then a git pull is done on the repo before querying it for history.
func (*GitInfo) ByIndex ¶
ByIndex returns a LongCommit describing the commit at position N, as ordered in the current branch.
Does not make sense if readCommitsFromGitAllBranches has been called.
func (*GitInfo) Details ¶
func (g *GitInfo) Details(ctx context.Context, hash string, includeBranchInfo bool) (*vcsinfo.LongCommit, error)
Details returns more information than ShortCommit about a given commit. See the vcsinfo.VCS interface for details.
func (*GitInfo) DetailsMulti ¶
func (g *GitInfo) DetailsMulti(ctx context.Context, hashes []string, includeBranchInfo bool) ([]*vcsinfo.LongCommit, error)
See the vcsinfo.VCS interface for details.
func (*GitInfo) GetBranches ¶
GetBranches returns a slice of strings naming the branches in the repo.
func (*GitInfo) IndexOf ¶
IndexOf returns the index of given hash as counted from the first commit in this branch by 'rev-list'. The index is 0 based.
func (*GitInfo) InitialCommit ¶
InitialCommit returns the hash of the initial commit.
func (*GitInfo) LastNIndex ¶
func (g *GitInfo) LastNIndex(N int) []*vcsinfo.IndexCommit
LastNIndex returns the last N commits.
func (*GitInfo) Log ¶
Log returns a --name-only short log for every commit in (begin, end].
If end is "" then it returns just the short log for the single commit at begin.
Example response:
commit b7988a21fdf23cc4ace6145a06ea824aa85db099 Author: Joe Gregorio <jcgregorio@google.com> Date: Tue Aug 5 16:19:48 2014 -0400 A description of the commit. perf/go/skiaperf/perf.go perf/go/types/types.go perf/res/js/logic.js
func (*GitInfo) LogArgs ¶
LogArgs is the same as Log() but appends all the 'args' to the Log request to allow finer control of the log output. I.e. you could call:
LogArgs("--since=2015-10-24", "--format=format:%ct", "infra/bots/assets/skp/VERSION")
func (*GitInfo) Range ¶
func (g *GitInfo) Range(begin, end time.Time) []*vcsinfo.IndexCommit
Range returns all commits from the half open interval ['begin', 'end'), i.e. includes 'begin' and excludes 'end'.
func (*GitInfo) ShortList ¶
ShortList returns a slice of ShortCommit for every commit in (begin, end].
func (*GitInfo) TimestampAtIndex ¶
This is a temporary performance enhancement for Perf. It will be removed once Perf moves to gitstore.
type ShortCommits ¶
type ShortCommits struct {
Commits []*vcsinfo.ShortCommit
}
ShortCommits stores a slice of ShortCommit struct.