Documentation
¶
Overview ¶
Package worktree manages isolated git worktrees by shelling out to `git worktree`. The Manager interface is consumed by the cli/app layers; Git is the only implementation.
Safety invariant: Shepherd never performs a mutating operation against the main working tree. RunInWorktree and Remove refuse it, and Remove additionally refuses any path outside the configured worktrees root.
Index ¶
- type ExecResult
- type Git
- func (g *Git) Create(ctx context.Context, task domain.Task, base string) (domain.Worktree, error)
- func (g *Git) Get(ctx context.Context, ref string) (domain.Worktree, error)
- func (g *Git) List(ctx context.Context) ([]domain.Worktree, error)
- func (g *Git) Prune(ctx context.Context, removeBranches bool) ([]domain.Worktree, error)
- func (g *Git) Remove(ctx context.Context, wt domain.Worktree, force bool) error
- func (g *Git) RunInWorktree(ctx context.Context, wt domain.Worktree, name string, args ...string) (ExecResult, error)
- type Manager
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecResult ¶
type ExecResult struct {
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
ExitCode int `json:"exit_code"`
Duration time.Duration `json:"duration"`
}
ExecResult is the captured outcome of a command run in (or for) a worktree.
type Git ¶
type Git struct {
// contains filtered or unexported fields
}
Git implements Manager over the git CLI.
func (*Git) Create ¶
Create makes a new worktree+branch for task, branched from base (or the configured default / HEAD). On a name/branch collision it appends a short unique suffix.
type Manager ¶
type Manager interface {
Create(ctx context.Context, task domain.Task, base string) (domain.Worktree, error)
List(ctx context.Context) ([]domain.Worktree, error)
Get(ctx context.Context, ref string) (domain.Worktree, error)
RunInWorktree(ctx context.Context, wt domain.Worktree, name string, args ...string) (ExecResult, error)
Remove(ctx context.Context, wt domain.Worktree, force bool) error
Prune(ctx context.Context, removeBranches bool) ([]domain.Worktree, error)
}
Manager creates and manages git worktrees.
type Options ¶
type Options struct {
RepoRoot string // absolute main work tree
Root string // absolute worktrees root
NameTemplate string
BranchPrefix string
DefaultBase string // base ref when none is given (empty => HEAD)
}
Options configures a Git manager. The app layer maps config into these so the worktree package stays independent of the config schema.