Documentation
¶
Overview ¶
Package git is a thin wrapper around the git binary.
Index ¶
- func Ref(name string) string
- func SamePath(a, b string) bool
- type Commit
- type Error
- type Repo
- func (r *Repo) At(dir string) *Repo
- func (r *Repo) BranchExists(name string) bool
- func (r *Repo) Checkout(branch string) error
- func (r *Repo) CommitCount(base, head string) (int, error)
- func (r *Repo) CommonDir() (string, error)
- func (r *Repo) ConflictLines(file string) []int
- func (r *Repo) ConflictedFiles() ([]string, error)
- func (r *Repo) CreateBranch(name, start string) error
- func (r *Repo) CurrentBranch() (string, error)
- func (r *Repo) DefaultBranch(remote string) (string, error)
- func (r *Repo) DefaultRemote() (string, error)
- func (r *Repo) EnableRerere() error
- func (r *Repo) Fetch(remote string) error
- func (r *Repo) ForkPoint(base, branch string) (string, error)
- func (r *Repo) GitDir() (string, error)
- func (r *Repo) HasPatches(branch, sha string) bool
- func (r *Repo) Includes(branch, sha string) bool
- func (r *Repo) IsAncestor(a, b string) bool
- func (r *Repo) IsClean() (bool, error)
- func (r *Repo) LastCommit(rev string) (Commit, error)
- func (r *Repo) MergeBase(a, b string) (string, error)
- func (r *Repo) RebaseInProgress() (bool, error)
- func (r *Repo) Remotes() ([]string, error)
- func (r *Repo) RevParse(rev string) (string, error)
- func (r *Repo) Run(args ...string) (string, error)
- func (r *Repo) RunEnv(env []string, args ...string) (string, error)
- func (r *Repo) SetBranchSHA(branch, sha string) error
- func (r *Repo) TopLevel() (string, error)
- func (r *Repo) ValidBranchName(name string) bool
- func (r *Repo) WorktreeFor(branch string) (string, error)
- func (r *Repo) Worktrees() ([]Worktree, error)
- type Worktree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Repo ¶
type Repo struct {
Dir string
}
Repo runs git commands in Dir.
func (*Repo) BranchExists ¶
BranchExists reports whether a local branch exists.
func (*Repo) Checkout ¶
Checkout switches to branch. The "--" keeps git from taking a missing branch's name as a path and restoring that path from the index instead.
func (*Repo) CommitCount ¶
CommitCount returns the number of commits in base..head.
func (*Repo) ConflictLines ¶
ConflictLines returns the 1-based line numbers of conflict markers in file, a path relative to the worktree root as ConflictedFiles returns it.
func (*Repo) ConflictedFiles ¶
ConflictedFiles lists paths with unresolved conflicts.
func (*Repo) CreateBranch ¶
CreateBranch creates name at start without checking it out.
func (*Repo) CurrentBranch ¶
CurrentBranch returns the checked-out branch, or "" when HEAD is detached. It strips refs/heads/ itself: `--short` yields "heads/x" when a tag x exists.
func (*Repo) DefaultBranch ¶
DefaultBranch returns the remote's default branch from refs/remotes/<remote>/HEAD, falling back to main or master.
func (*Repo) DefaultRemote ¶
DefaultRemote returns "origin" when present, else the only remote.
func (*Repo) EnableRerere ¶
EnableRerere turns on rerere for this repository.
func (*Repo) HasPatches ¶ added in v1.0.2
HasPatches reports whether every commit sha has and the local branch lacks makes a change the branch already has, as when a host rebased the branch onto the same base itself. Merge commits never count.
func (*Repo) Includes ¶
Includes reports whether sha is, or once was, part of the local branch: an ancestor of its tip or of one of its reflog entries. A remote commit that is not included was never integrated locally.
func (*Repo) IsAncestor ¶
IsAncestor reports whether a is an ancestor of b.
func (*Repo) IsClean ¶
IsClean reports whether the worktree has no staged or unstaged changes to tracked files.
func (*Repo) LastCommit ¶
LastCommit returns the tip commit of rev.
func (*Repo) RebaseInProgress ¶
RebaseInProgress reports whether this worktree is mid-rebase.
func (*Repo) SetBranchSHA ¶
SetBranchSHA force-moves a branch that is not checked out.
func (*Repo) ValidBranchName ¶
ValidBranchName reports whether name is an acceptable branch name. `check-ref-format --branch` expands @{-N} and accepts "@", so those are rejected here.
func (*Repo) WorktreeFor ¶
WorktreeFor returns the path of the worktree that has branch checked out, or "".