Documentation
¶
Overview ¶
Package git wraps git CLI operations behind a testable interface.
Index ¶
- type RealRunner
- func (r *RealRunner) AddWorktree(ctx context.Context, bareRepo, worktreePath, branch string) error
- func (r *RealRunner) AddWorktreeNewBranch(ctx context.Context, bareRepo, worktreePath, newBranch, startPoint string) error
- func (r *RealRunner) BareClone(ctx context.Context, url, dest string) error
- func (r *RealRunner) BranchExists(ctx context.Context, bareRepo, branch string) (bool, error)
- func (r *RealRunner) CheckoutBranch(ctx context.Context, worktreePath, branch string) error
- func (r *RealRunner) CheckoutNewBranch(ctx context.Context, worktreePath, newBranch, startPoint string) error
- func (r *RealRunner) CurrentBranch(ctx context.Context, worktreePath string) (string, error)
- func (r *RealRunner) DefaultBranch(ctx context.Context, bareRepo string) (string, error)
- func (r *RealRunner) DeleteBranch(ctx context.Context, bareRepo, branch string) error
- func (r *RealRunner) EnsureRemoteRef(ctx context.Context, bareRepo, branch string) error
- func (r *RealRunner) Fetch(ctx context.Context, repoPath string) error
- func (r *RealRunner) IsClean(ctx context.Context, worktreePath string) (bool, error)
- func (r *RealRunner) Rebase(ctx context.Context, worktreePath, onto string) error
- func (r *RealRunner) RebaseAbort(ctx context.Context, worktreePath string) error
- func (r *RealRunner) RemoveWorktree(ctx context.Context, bareRepo, worktreePath string) error
- func (r *RealRunner) ResetBranch(ctx context.Context, worktreePath, ref string) error
- type Runner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RealRunner ¶
RealRunner shells out to the git binary.
func (*RealRunner) AddWorktree ¶
func (r *RealRunner) AddWorktree(ctx context.Context, bareRepo, worktreePath, branch string) error
AddWorktree creates a worktree from a bare repo at the given path and branch. Uses --force to allow the same branch to be checked out in multiple worktrees across different workspaces.
func (*RealRunner) AddWorktreeNewBranch ¶
func (r *RealRunner) AddWorktreeNewBranch(ctx context.Context, bareRepo, worktreePath, newBranch, startPoint string) error
AddWorktreeNewBranch creates a worktree with a new branch starting from startPoint.
func (*RealRunner) BareClone ¶
func (r *RealRunner) BareClone(ctx context.Context, url, dest string) error
BareClone creates a bare clone of a repository.
func (*RealRunner) BranchExists ¶
BranchExists checks if a branch exists in the bare repo (local or remote ref).
func (*RealRunner) CheckoutBranch ¶ added in v1.5.3
func (r *RealRunner) CheckoutBranch(ctx context.Context, worktreePath, branch string) error
CheckoutBranch switches to an existing branch in a worktree.
func (*RealRunner) CheckoutNewBranch ¶ added in v1.5.3
func (r *RealRunner) CheckoutNewBranch(ctx context.Context, worktreePath, newBranch, startPoint string) error
CheckoutNewBranch creates and switches to a new branch from a start point.
func (*RealRunner) CurrentBranch ¶ added in v1.5.3
CurrentBranch returns the currently checked-out branch in a worktree.
func (*RealRunner) DefaultBranch ¶
DefaultBranch returns the default branch name (e.g. "main" or "master") for a bare repo.
func (*RealRunner) DeleteBranch ¶ added in v1.6.0
func (r *RealRunner) DeleteBranch(ctx context.Context, bareRepo, branch string) error
DeleteBranch force-deletes a branch in the bare repo.
func (*RealRunner) EnsureRemoteRef ¶ added in v1.5.0
func (r *RealRunner) EnsureRemoteRef(ctx context.Context, bareRepo, branch string) error
EnsureRemoteRef creates refs/remotes/origin/{branch} in a bare repo so origin/{branch} resolves from worktrees.
func (*RealRunner) Fetch ¶
func (r *RealRunner) Fetch(ctx context.Context, repoPath string) error
Fetch fetches all refs in a bare repository and ensures the default branch has a remote tracking ref so status checks can reference origin/main.
func (*RealRunner) IsClean ¶ added in v1.5.0
IsClean returns true if the worktree has no uncommitted changes.
func (*RealRunner) Rebase ¶ added in v1.5.0
func (r *RealRunner) Rebase(ctx context.Context, worktreePath, onto string) error
Rebase rebases the current branch onto the given ref.
func (*RealRunner) RebaseAbort ¶ added in v1.5.0
func (r *RealRunner) RebaseAbort(ctx context.Context, worktreePath string) error
RebaseAbort aborts a rebase in progress.
func (*RealRunner) RemoveWorktree ¶
func (r *RealRunner) RemoveWorktree(ctx context.Context, bareRepo, worktreePath string) error
RemoveWorktree removes a worktree from a bare repo.
func (*RealRunner) ResetBranch ¶ added in v1.5.2
func (r *RealRunner) ResetBranch(ctx context.Context, worktreePath, ref string) error
ResetBranch resets the current branch in a worktree to the given ref. This is used to fast-forward existing worktrees to the latest remote state.
type Runner ¶
type Runner interface {
BareClone(ctx context.Context, url, dest string) error
Fetch(ctx context.Context, repoPath string) error
AddWorktree(ctx context.Context, bareRepo, worktreePath, branch string) error
AddWorktreeNewBranch(ctx context.Context, bareRepo, worktreePath, newBranch, startPoint string) error
RemoveWorktree(ctx context.Context, bareRepo, worktreePath string) error
BranchExists(ctx context.Context, bareRepo, branch string) (bool, error)
DeleteBranch(ctx context.Context, bareRepo, branch string) error
DefaultBranch(ctx context.Context, bareRepo string) (string, error)
EnsureRemoteRef(ctx context.Context, bareRepo, branch string) error
ResetBranch(ctx context.Context, worktreePath, ref string) error
IsClean(ctx context.Context, worktreePath string) (bool, error)
CurrentBranch(ctx context.Context, worktreePath string) (string, error)
CheckoutBranch(ctx context.Context, worktreePath, branch string) error
CheckoutNewBranch(ctx context.Context, worktreePath, newBranch, startPoint string) error
Rebase(ctx context.Context, worktreePath, onto string) error
RebaseAbort(ctx context.Context, worktreePath string) error
}
Runner abstracts git operations for testability.