Documentation
¶
Overview ¶
Package git shells out to the git CLI to read diff data for a repo.
Index ¶
- Constants
- Variables
- func IsBinary(content []byte) bool
- type ChangedFile
- type Driver
- func (d *Driver) AddWorktree(root, sessionName, baseOverride string) (string, string, error)
- func (d *Driver) BaseRef(root string) (ref, describe string, err error)
- func (d *Driver) BranchBase(root, override string) (ref, describe string, err error)
- func (d *Driver) BranchRefs(root string) ([]string, error)
- func (d *Driver) ChangedFiles(root string, scope Scope, baseRef string) ([]ChangedFile, error)
- func (d *Driver) CountWorkingLines(root, path string) (LineCount, error)
- func (d *Driver) DefaultBase(dir string) string
- func (d *Driver) FetchBase(dir, override string) error
- func (d *Driver) Fingerprint(root string, scope Scope, baseRef string) (uint64, error)
- func (d *Driver) IndexFile(root, path string) ([]byte, error)
- func (d *Driver) IsRepoRoot(dir string) bool
- func (d *Driver) LastCommitParent(root string) string
- func (d *Driver) NumStat(root string, scope Scope, baseRef string) (map[string]FileStat, error)
- func (d *Driver) OpenRepo(dir string) (Repo, error)
- func (d *Driver) RemoveWorktreeIfClean(root, path, branch, baseOverride string) (bool, error)
- func (d *Driver) RenameWorktreeBranch(root, path, branch, newName string) (string, error)
- func (d *Driver) RepoRoot(dir string) (string, error)
- func (d *Driver) ResolveRef(root, ref string) error
- func (d *Driver) ResolveRepos(cwd string) ([]string, error)
- func (d *Driver) ShowFile(root, ref, path string) ([]byte, error)
- func (d *Driver) WorkingFile(root, path string) ([]byte, error)
- func (d *Driver) Worktrees(root string) ([]Worktree, error)
- type FileStat
- type LineCount
- type Repo
- type Scope
- type Status
- type Worktree
Constants ¶
const ( ScopeUncommitted = value.ScopeUncommitted ScopeBranch = value.ScopeBranch ScopeLastCommit = value.ScopeLastCommit ScopeStaged = value.ScopeStaged )
Variables ¶
var ErrNotARepo = errors.New("not a git repository")
Functions ¶
Types ¶
type ChangedFile ¶
type ChangedFile = value.ChangedFile
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
func (*Driver) AddWorktree ¶ added in v0.15.0
func (*Driver) BaseRef ¶
BaseRef finds the merge base against the repo's default base for the branch scope, returning the resolved ref and a short description.
func (*Driver) BranchBase ¶ added in v0.6.0
BranchBase resolves the base ref the branch scope diffs against. A non-empty override is validated first and fails loudly when it no longer resolves, never falling back to auto-detection; empty override auto-detects.
func (*Driver) BranchRefs ¶ added in v0.6.0
BranchRefs lists local and remote branch short names, dropping the symbolic refs such as origin/HEAD that name a remote's default rather than a branch.
func (*Driver) ChangedFiles ¶
func (*Driver) CountWorkingLines ¶ added in v0.6.0
CountWorkingLines streams a working-tree file, so files too big to diff still count.
func (*Driver) DefaultBase ¶ added in v0.40.0
DefaultBase is the branch work in the repo merges into: the default branch on upstream, which GitHub's fork layout names the parent, else on origin, else the local branch. "" when the repo names no default branch.
func (*Driver) FetchBase ¶ added in v0.40.0
FetchBase updates the remote-tracking branch a worktree would branch from, and only that branch, so a session starts from the remote's tip rather than from whatever the last fetch left behind.
func (*Driver) Fingerprint ¶
Fingerprint hashes the repo state visible to a scope so callers can cheaply detect when a reload is needed.
func (*Driver) IsRepoRoot ¶ added in v0.6.0
func (*Driver) LastCommitParent ¶ added in v0.9.1
LastCommitParent returns HEAD's parent ref, or git's empty-tree object when HEAD is a root commit.
func (*Driver) RemoveWorktreeIfClean ¶ added in v0.15.0
RemoveWorktreeIfClean removes a session's worktree and its am/ branch only when nothing would be lost: no uncommitted or untracked files, and no commits that exist nowhere else. A kept worktree is not an error.
func (*Driver) RenameWorktreeBranch ¶ added in v0.35.0
RenameWorktreeBranch gives a managed worktree the branch a session of newName would have received at spawn without moving its live directory. The recorded branch is returned untouched when the worktree directory or branch no longer exists, or the worktree has left the recorded branch (switched to another, or detached mid-rebase), which is what a worktree renamed, removed or repointed by hand looks like.
func (*Driver) ResolveRef ¶ added in v0.6.0
func (*Driver) ResolveRepos ¶ added in v0.5.0
ResolveRepos returns the git repo roots reachable from cwd, most-active first. When cwd is itself a repo, that repo plus its linked worktrees are the roots. When cwd is an umbrella folder holding several repos, each nested repo root is returned ranked with dirty working trees before clean ones, then by most recent commit, so review lands on the repo the agent is most likely editing.