Documentation ¶
Index ¶
- Constants
- type Commit
- type CommitSlice
- type Graph
- func (r *Graph) BranchHeads() []*gitinfo.GitBranch
- func (r *Graph) Branches() []string
- func (r *Graph) Get(ref string) *Commit
- func (r *Graph) GetCommitsNewerThan(ts time.Time) ([]*vcsinfo.LongCommit, error)
- func (r *Graph) GetLastNCommits(n int) ([]*vcsinfo.LongCommit, error)
- func (r *Graph) Len() int
- func (r *Graph) RecurseAllBranches(f func(*Commit) (bool, error)) error
- func (r *Graph) Repo() *git.Repo
- func (r *Graph) Update(ctx context.Context) error
- func (r *Graph) UpdateAndReturnNewCommits(ctx context.Context) ([]*vcsinfo.LongCommit, error)
- type Map
Constants ¶
const ( // Name of the file we store inside the Git checkout to speed up the // initial Update(). CACHE_FILE = "sk_gitrepo.gob" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Commit ¶
type Commit struct { *vcsinfo.LongCommit ParentIndices []int // contains filtered or unexported fields }
Commit represents a commit in a Git repo.
func (*Commit) GetParents ¶
Parents returns the parents of this commit.
func (*Commit) HasAncestor ¶
HasAncestor returns true iff the given commit is an ancestor of this commit.
func (*Commit) Recurse ¶
Recurse runs the given function recursively over commit history, starting at the given commit. The function accepts the current Commit as a parameter. Returning false from the function indicates that recursion should stop for the current branch, however, recursion will continue for any other branches until they are similarly terminated. Returning an error causes recursion to stop without properly terminating other branchces. The error will bubble to the top and be returned. Here's an example of printing out the entire ancestry of a given commit:
commit.Recurse(func(c *Commit) (bool, error) { sklog.Info(c.Hash) return true, nil })
type CommitSlice ¶
type CommitSlice []*Commit
Helpers for sorting.
func (CommitSlice) Hashes ¶
func (s CommitSlice) Hashes() []string
Hashes returns a slice of commit hashes corresponding to the commits in s.
func (CommitSlice) Len ¶
func (s CommitSlice) Len() int
func (CommitSlice) Less ¶
func (s CommitSlice) Less(a, b int) bool
func (CommitSlice) Swap ¶
func (s CommitSlice) Swap(a, b int)
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph represents an entire Git repo.
func New ¶
New returns a Graph instance which uses the given git.Graph. Obtains cached data but does NOT update the Graph; the caller is responsible for doing so before using the Graph if up-to-date data is required.
func NewGraph ¶
NewGraph returns a Graph instance, creating a git.Repo from the repoUrl and workdir. Obtains cached data but does NOT update the Graph; the caller is responsible for doing so before using the Graph if up-to-date data is required.
func (*Graph) BranchHeads ¶
BranchHeads returns the set of branch heads from the repo.
func (*Graph) Get ¶
Get returns a Commit object for the given ref, if such a commit exists. This function does not understand complex ref types (eg. HEAD~3); only branch names and full commit hashes are accepted.
func (*Graph) GetCommitsNewerThan ¶
Return any commits at or after the given timestamp.
func (*Graph) GetLastNCommits ¶
func (r *Graph) GetLastNCommits(n int) ([]*vcsinfo.LongCommit, error)
GetLastNCommits returns the last N commits in the repo.
func (*Graph) RecurseAllBranches ¶
RecurseAllBranches runs the given function recursively over the entire commit history, starting at each of the known branch heads. The function accepts the current Commit as a parameter. Returning false from the function indicates that recursion should stop for the current branch, however, recursion will continue for any other branches until they are similarly terminated. Returning an error causes recursion to stop without properly terminating other branchces. The error will bubble to the top and be returned. Here's an example of printing out all of the commits in the repo:
repo.RecurseAllBranches(func(c *Commit) (bool, error) { sklog.Info(c.Hash) return true, nil })
func (*Graph) Update ¶
Update syncs the local copy of the repo and loads new commits/branches into the Graph object.
func (*Graph) UpdateAndReturnNewCommits ¶
UpdateAndReturnNewCommits syncs the local copy of the repo and loads new commits/branches into the Graph object. Returns a slice of any new commits, in no particular order.
type Map ¶
Map is a convenience type for dealing with multiple Graphs for different repos. The keys are repository URLs.
func NewMap ¶
NewMap returns a Map instance with Graphs for the given repo URLs. Obtains cached data but does NOT update the Map; the caller is responsible for doing so before using the Map if up-to-date data is required.
func (Map) FindCommit ¶
FindCommit returns the Commit object, repo URL, and Graph object for the given commit hash if it exists in any of the Graphs in the Map and an error otherwise.
func (Map) UpdateAndReturnNewCommits ¶
func (m Map) UpdateAndReturnNewCommits(ctx context.Context) (map[string][]*vcsinfo.LongCommit, error)
UpdateAndReturnNewCommits updates all Graphs in the Map. Returns a map of repo URLs to slices of new commits in each of the repos.