Documentation ¶
Overview ¶
gitinfo enables querying info from a Git repository.
Index ¶
- 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) Dir() string
- func (g *GitInfo) From(start time.Time) []string
- func (g *GitInfo) FullHash(ctx context.Context, ref string) (string, error)
- func (g *GitInfo) GetBranches(ctx context.Context) ([]*GitBranch, error)
- func (g *GitInfo) GetFile(ctx context.Context, fileName, commit string) (string, error)
- func (g *GitInfo) IndexOf(ctx context.Context, hash string) (int, error)
- func (g *GitInfo) InitialCommit(ctx context.Context) (string, error)
- func (g *GitInfo) IsAncestor(ctx context.Context, a, b string) bool
- func (g *GitInfo) LastN(ctx context.Context, N int) []string
- func (g *GitInfo) LastNIndex(N int) []*vcsinfo.IndexCommit
- func (g *GitInfo) LastSkpCommit(ctx context.Context) (time.Time, error)
- 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) NumCommits() int
- func (g *GitInfo) Range(begin, end time.Time) []*vcsinfo.IndexCommit
- func (g *GitInfo) Reset(ctx context.Context, ref string) error
- func (g *GitInfo) ResolveCommit(ctx context.Context, commitHash string) (string, error)
- func (g *GitInfo) RevList(ctx context.Context, args ...string) ([]string, error)
- func (g *GitInfo) SetSecondaryRepo(secVCS vcsinfo.VCS, extractor depot_tools.DEPSExtractor)
- func (g *GitInfo) ShortList(ctx context.Context, begin, end string) (*ShortCommits, error)
- func (g *GitInfo) SkpCommits(ctx context.Context, tile *tiling.Tile) ([]int, error)
- func (g *GitInfo) TileAddressFromHash(hash string, start time.Time) (num, offset int, err error)
- func (g *GitInfo) Timestamp(hash string) time.Time
- func (g *GitInfo) Update(ctx context.Context, pull, allBranches bool) error
- type RepoMap
- type ShortCommits
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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) 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 ¶
InitalCommit 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) LastSkpCommit ¶
LastSkpCommit returns the time of the last change to the SKP_VERSION file.
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) NumCommits ¶
NumCommits returns the number of commits in the repo.
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) ResolveCommit ¶
ResolveCommit see vcsinfo.VCS interface.
func (*GitInfo) SetSecondaryRepo ¶
func (g *GitInfo) SetSecondaryRepo(secVCS vcsinfo.VCS, extractor depot_tools.DEPSExtractor)
SetSecondaryRepo allows to add a secondary repository and extractor to this instance. It is not included in the constructor since it is currently only used by the Gold ingesters.
func (*GitInfo) ShortList ¶
ShortList returns a slice of ShortCommit for every commit in (begin, end].
func (*GitInfo) SkpCommits ¶
SkpCommits returns the indices for all the commits that contain SKP updates.
func (*GitInfo) TileAddressFromHash ¶
TileAddressFromHash takes a commit hash and time, then returns the Level 0 tile number that contains the hash, and its position in the tile commit array. This assumes that tiles are built for commits since after the given time.
type RepoMap ¶
type RepoMap struct {
// contains filtered or unexported fields
}
RepoMap is a struct used for managing multiple Git repositories.
func NewRepoMap ¶
NewRepoMap creates and returns a RepoMap which operates within the given workdir.
func (*RepoMap) Repo ¶
Repo retrieves a pointer to a GitInfo for the requested repo URL. If the repo does not yet exist in the repoMap, it is cloned and added before it is returned.
func (*RepoMap) RepoForCommit ¶
RepoForCommit attempts to determine which repository the given commit hash belongs to and returns the associated repo URL if found. This is fragile, because it's possible, though very unlikely, that there may be collisions of commit hashes between repositories.
type ShortCommits ¶
type ShortCommits struct {
Commits []*vcsinfo.ShortCommit
}
ShortCommits stores a slice of ShortCommit struct.