Documentation
¶
Overview ¶
Package git reads and drives the checkout holding a project, and its origin.
Index ¶
- type Commit
- type Credentials
- type Identity
- type Repository
- func (r *Repository) Branches(prefix string) ([]string, error)
- func (r *Repository) ChangedPaths(ctx context.Context, commit string) ([]string, error)
- func (r *Repository) Commit(ref string) (Commit, error)
- func (r *Repository) Count(base, tip string) (int, error)
- func (r *Repository) DefaultBranch(ctx context.Context) (string, error)
- func (r *Repository) DeleteBranch(ctx context.Context, branch, expected string) error
- func (r *Repository) Fetch(ctx context.Context, refspecs ...string) error
- func (r *Repository) Files(commit, dir string) (map[string][]byte, error)
- func (r *Repository) MergeBase(rev string) (_ string, err error)
- func (r *Repository) Show(commit, path string) ([]byte, error)
- func (r *Repository) Tip(ref string) (string, error)
- func (r *Repository) Worktree(commit string) (*Worktree, error)
- type Worktree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Commit ¶
type Commit struct {
SHA, Parent string
AuthorEmail, CommitterEmail string
Trailers map[string]string
}
Commit describes one commit.
type Credentials ¶
Credentials supply the username and password presented to an HTTP origin.
type Identity ¶
type Identity struct {
Name, Email string
}
Identity is the author and committer of every commit made here.
type Repository ¶
type Repository struct {
// Dir is the top-level directory of the checkout.
Dir string
// Remote is the origin URL as the checkout configures it, or "" without one.
Remote string
// Shallow reports a checkout cloned without its whole history.
Shallow bool
// Credentials authenticate fetches and pushes to an HTTP origin. An SSH
// origin uses the SSH agent instead.
Credentials Credentials
// Identity signs the commits made in worktrees.
Identity Identity
// contains filtered or unexported fields
}
Repository is the checkout holding a project.
func (*Repository) Branches ¶
func (r *Repository) Branches(prefix string) ([]string, error)
Branches lists origin's branches under a prefix.
func (*Repository) ChangedPaths ¶
ChangedPaths returns paths changed since commit, including working-tree edits.
func (*Repository) Commit ¶
func (r *Repository) Commit(ref string) (Commit, error)
Commit describes the commit a SHA or ref points at.
func (*Repository) Count ¶
func (r *Repository) Count(base, tip string) (int, error)
Count reports how many commits tip has beyond base: zero, one, or two for any larger number, which is all ownership needs to tell apart.
func (*Repository) DefaultBranch ¶
func (r *Repository) DefaultBranch(ctx context.Context) (string, error)
DefaultBranch returns the branch origin's HEAD points at: the checkout's record of it, or the remote's answer when the checkout never recorded one.
func (*Repository) DeleteBranch ¶
func (r *Repository) DeleteBranch(ctx context.Context, branch, expected string) error
DeleteBranch removes an origin branch while it still has the expected tip.
func (*Repository) Fetch ¶
func (r *Repository) Fetch(ctx context.Context, refspecs ...string) error
Fetch updates origin's remote-tracking refs for the given refspecs and prunes the ones they no longer match.
func (*Repository) Files ¶ added in v0.11.0
func (r *Repository) Files(commit, dir string) (map[string][]byte, error)
Files returns the files below dir at a commit, keyed by their repository path. A commit without the directory has none.
func (*Repository) MergeBase ¶
func (r *Repository) MergeBase(rev string) (_ string, err error)
MergeBase returns the commit where the histories of rev and HEAD meet, as git merge-base finds it.
func (*Repository) Show ¶
func (r *Repository) Show(commit, path string) ([]byte, error)
Show reads a path from a commit; a missing path returns nil.
type Worktree ¶
type Worktree struct {
Dir string
// contains filtered or unexported fields
}
Worktree is a detached checkout of one commit in a temporary directory. The commits it makes reach the checkout only through origin, on the next fetch. Callers remove it.
func (*Worktree) Commit ¶
Commit records the given paths on top of the worktree's commit and returns the new commit, which the worktree then has checked out.