Documentation ¶
Overview ¶
Package gitrepo provides operations on git repos.
Index ¶
- Variables
- func AllCommitDates(repo *git.Repository, refName ReferenceName, prefix string) (dates map[string]Dates, err error)
- func Clone(ctx context.Context, repoURL string) (repo *git.Repository, err error)
- func CloneAt(ctx context.Context, repoURL string, ref plumbing.ReferenceName) (repo *git.Repository, err error)
- func CloneOrOpen(ctx context.Context, repoPath string) (*git.Repository, error)
- func HeadCommit(repo *git.Repository) (*object.Commit, error)
- func HeadHash(repo *git.Repository) (plumbing.Hash, error)
- func Open(ctx context.Context, dirpath string) (repo *git.Repository, err error)
- func ParseGitHubRepo(s string) (owner, repoName string, err error)
- func PlainClone(ctx context.Context, dir, repoURL string) (repo *git.Repository, err error)
- func PlainCloneWith(ctx context.Context, dir string, opts *git.CloneOptions) (repo *git.Repository, err error)
- func ReadTxtarRepo(filename string, now time.Time) (_ *git.Repository, err error)
- func Root(repo *git.Repository) (root *object.Tree, err error)
- func TxtarRepoAndHead(file string) (*git.Repository, *object.Commit, error)
- type Dates
- type ReferenceName
Constants ¶
This section is empty.
Variables ¶
var ( HeadReference = ReferenceName{plumbing.HEAD} // HEAD MainReference = ReferenceName{plumbing.NewRemoteReferenceName("origin", "master")} // origin/master )
Functions ¶
func AllCommitDates ¶
func AllCommitDates(repo *git.Repository, refName ReferenceName, prefix string) (dates map[string]Dates, err error)
AllCommitDates returns the oldest and newest commit timestamps for every file in the repo at the given reference, where the filename begins with prefix. The supplied prefix should include the trailing /.
func CloneAt ¶
func CloneAt(ctx context.Context, repoURL string, ref plumbing.ReferenceName) (repo *git.Repository, err error)
Clone returns a bare repo by cloning the repo at repoURL at the given ref.
func CloneOrOpen ¶
CloneOrOpen clones repoPath if it is an HTTP(S) URL, or opens it from the local disk otherwise.
func HeadCommit ¶
HeadCommit returns the commit at the repo HEAD.
func ParseGitHubRepo ¶
ParseGitHubRepo parses a string of the form owner/repo or github.com/owner/repo.
func PlainClone ¶
PlainClone returns a (non-bare) repo with its history by cloning the repo at repoURL.
func PlainCloneWith ¶
func PlainCloneWith(ctx context.Context, dir string, opts *git.CloneOptions) (repo *git.Repository, err error)
PlainCloneWith returns a (non-bare) repo with its history by cloning the repo with the given options opt.
func ReadTxtarRepo ¶
ReadTxtarRepo converts a txtar file to a single-commit repo. It is intended for testing.
Types ¶
type ReferenceName ¶
type ReferenceName struct{ plumbing.ReferenceName }
ReferenceName is a git reference.