Documentation
¶
Index ¶
- Variables
- func CommitURL(remoteURL, commitHash string) string
- type BranchManager
- func (bm *BranchManager) CurrentBranch(dir string) (string, error)
- func (bm *BranchManager) Exists(dir, branch string) (bool, error)
- func (bm *BranchManager) MergedBranches(dir, base string) ([]string, error)
- func (bm *BranchManager) RemoteBranches(dir string) ([]string, error)
- func (bm *BranchManager) ValidateBranchName(name string) error
- type Executor
- type RealExecutor
- type Worktree
- type WorktreeManager
- func (wm *WorktreeManager) Add(dir, branch, base string) (string, error)
- func (wm *WorktreeManager) Cleanable(dir string) ([]Worktree, error)
- func (wm *WorktreeManager) CurrentRef(dir string) (string, error)
- func (wm *WorktreeManager) FetchRefspec(dir, remote, refspec string) error
- func (wm *WorktreeManager) Find(dir, query string) (Worktree, error)
- func (wm *WorktreeManager) Kind() vcs.Kind
- func (wm *WorktreeManager) List(dir string) ([]Worktree, error)
- func (wm *WorktreeManager) MainWorktree(dir string) (Worktree, error)
- func (wm *WorktreeManager) RemoteURL(dir string) (string, error)
- func (wm *WorktreeManager) Remove(dir, branch, cwd string, force bool) error
- func (wm *WorktreeManager) StateDir(dir string) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrBranchAlreadyExists = errors.New("branch already exists") ErrInvalidBranchName = errors.New("invalid branch name") )
Sentinel errors for branch operations.
var ( ErrWorktreeNotFound = vcs.ErrWorktreeNotFound ErrMultipleMatches = vcs.ErrMultipleMatches ErrMainWorktree = vcs.ErrMainWorktree ErrWorktreeIsCurrentDir = vcs.ErrWorktreeIsCurrentDir ErrBranchAlreadyInUse = vcs.ErrBranchAlreadyInUse ErrPathAlreadyExists = vcs.ErrPathAlreadyExists ErrWorktreeHasChanges = vcs.ErrWorktreeHasChanges )
Sentinel errors for worktree operations. These alias the shared vcs errors so that errors.Is works against either package's name — the jj backend wraps the same values, letting internal/cli render one set of messages for both.
var WorktreePath = vcs.WorktreePath
WorktreePath computes the sibling worktree directory path. Aliased from vcs so git and jj lay out their checkouts identically.
Functions ¶
Types ¶
type BranchManager ¶
type BranchManager struct {
// contains filtered or unexported fields
}
BranchManager handles branch-related operations.
func NewBranchManager ¶
func NewBranchManager(executor Executor) *BranchManager
NewBranchManager creates a new BranchManager.
func (*BranchManager) CurrentBranch ¶
func (bm *BranchManager) CurrentBranch(dir string) (string, error)
CurrentBranch returns the current branch name.
func (*BranchManager) Exists ¶
func (bm *BranchManager) Exists(dir, branch string) (bool, error)
Exists checks if a branch exists in the repo.
func (*BranchManager) MergedBranches ¶
func (bm *BranchManager) MergedBranches(dir, base string) ([]string, error)
MergedBranches returns branches whose unique commits have been merged into the given base branch. Branches that sit at the exact same commit as base are excluded — they never diverged, so they are not "merged".
func (*BranchManager) RemoteBranches ¶ added in v0.4.0
func (bm *BranchManager) RemoteBranches(dir string) ([]string, error)
RemoteBranches returns remote branch names with the remote prefix stripped. For example, "origin/feature-x" becomes "feature-x". HEAD pointers (e.g., "origin/HEAD -> origin/main") are excluded.
func (*BranchManager) ValidateBranchName ¶
func (bm *BranchManager) ValidateBranchName(name string) error
ValidateBranchName checks if a branch name is valid using git check-ref-format.
type Executor ¶
type Executor interface {
// Run executes a git command in the given directory and returns stdout.
Run(dir string, args ...string) (string, error)
}
Executor abstracts git CLI calls for testability.
type Worktree ¶
Worktree represents a single git worktree entry. It is an alias of the shared vcs model so git and jj listings are the same type end to end.
type WorktreeManager ¶
type WorktreeManager struct {
// contains filtered or unexported fields
}
WorktreeManager handles worktree operations.
func NewWorktreeManager ¶
func NewWorktreeManager(executor Executor) *WorktreeManager
NewWorktreeManager creates a new WorktreeManager with the given executor.
func (*WorktreeManager) Add ¶
func (wm *WorktreeManager) Add(dir, branch, base string) (string, error)
Add creates a new worktree for the given branch.
func (*WorktreeManager) Cleanable ¶ added in v0.6.0
func (wm *WorktreeManager) Cleanable(dir string) ([]Worktree, error)
Cleanable returns worktrees whose branch has been merged into the main worktree's branch, plus worktrees git reports as prunable.
func (*WorktreeManager) CurrentRef ¶ added in v0.6.0
func (wm *WorktreeManager) CurrentRef(dir string) (string, error)
CurrentRef returns the branch checked out at dir.
func (*WorktreeManager) FetchRefspec ¶ added in v0.6.0
func (wm *WorktreeManager) FetchRefspec(dir, remote, refspec string) error
FetchRefspec fetches a "src:dst" refspec from a remote.
func (*WorktreeManager) Find ¶
func (wm *WorktreeManager) Find(dir, query string) (Worktree, error)
Find searches worktrees by substring match on branch name. Returns the matching worktree, or an error if zero or multiple matches.
func (*WorktreeManager) Kind ¶ added in v0.6.0
func (wm *WorktreeManager) Kind() vcs.Kind
Kind reports that this manager drives git. Part of the vcs.Manager interface.
func (*WorktreeManager) List ¶
func (wm *WorktreeManager) List(dir string) ([]Worktree, error)
List returns all worktrees for the repo at dir.
func (*WorktreeManager) MainWorktree ¶
func (wm *WorktreeManager) MainWorktree(dir string) (Worktree, error)
MainWorktree returns the main (first) worktree.
func (*WorktreeManager) RemoteURL ¶
func (wm *WorktreeManager) RemoteURL(dir string) (string, error)
RemoteURL returns the URL of the "origin" remote for the repo at dir.