Documentation
¶
Overview ¶
Package worktree wraps the git CLI to manage linked worktrees. Git is the source of truth: nothing is persisted here — every operation reads or mutates what `git worktree` already knows.
Index ¶
- func DefaultRoot() string
- type Branch
- type Info
- type Manager
- func (m *Manager) Branches(ctx context.Context, repo string) ([]Branch, error)
- func (m *Manager) Fetch(ctx context.Context, repo string) error
- func (m *Manager) List(ctx context.Context, repo string) ([]Info, error)
- func (m *Manager) Prune(ctx context.Context, repo string) error
- func (m *Manager) Remove(ctx context.Context, repo, path string, force bool) error
- func (m *Manager) RepoRoot(ctx context.Context, path string) (string, bool, error)
- func (m *Manager) Resolve(ctx context.Context, repo, branch, base string) (string, bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultRoot ¶
func DefaultRoot() string
DefaultRoot is where worktrees live unless configured otherwise.
Types ¶
type Branch ¶
type Branch struct {
Name string `json:"name"`
IsLocal bool `json:"is_local"`
IsRemote bool `json:"is_remote"`
}
Branch is a branch name and where it is known from.
type Info ¶
type Info struct {
Path string `json:"path"`
Branch string `json:"branch,omitempty"`
Head string `json:"head,omitempty"`
IsMain bool `json:"is_main"`
Detached bool `json:"detached"`
}
Info describes one worktree of a repository.
type Manager ¶
type Manager struct {
// Root is the directory where new worktrees are created,
// e.g. ~/.agent_composer/worktrees.
Root string
}
Manager creates and inspects worktrees under a global root directory.
func (*Manager) Remove ¶
Remove deletes a worktree (never its branch). Git refuses dirty worktrees unless force is set — that refusal is surfaced verbatim.
func (*Manager) RepoRoot ¶
RepoRoot resolves the enclosing git repository of path. ok is false when path is not inside a git repository (not an error — callers use it to decide whether to offer worktrees at all).