Documentation
¶
Overview ¶
Package worktrees provides functionality for creating and managing Git worktrees for operating across multiple Git references.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StackDiff ¶
type StackDiff struct {
Added []*component.Stack
Removed []*component.Stack
Changed []StackDiffChangedPair
}
type StackDiffChangedPair ¶
type WorktreePair ¶
type WorktreePair struct {
GitExpression *filter.GitExpression
Diffs *git.Diffs
FromWorktree Worktree
ToWorktree Worktree
}
WorktreePair is a pair of worktrees, one for the from and one for the to reference, along with the GitExpression that generated the diffs and the diff for that expression.
type Worktrees ¶
type Worktrees struct {
WorktreePairs map[string]WorktreePair
OriginalWorkingDir string
// contains filtered or unexported fields
}
Worktrees is a map of WorktreePairs, and the Git runner used to create and manage the worktrees. The key is the string representation of the GitExpression that generated the worktree pair.
func NewWorktrees ¶
func NewWorktrees( ctx context.Context, l log.Logger, workingDir string, gitExpressions filter.GitExpressions, ) (*Worktrees, error)
NewWorktrees creates a new Worktrees for a given set of Git filters.
Note that it is the responsibility of the caller to call Cleanup on the Worktrees object when it is no longer needed.
func (*Worktrees) Cleanup ¶
Cleanup removes all created Git worktrees and their temporary directories.
func (*Worktrees) DisplayPath ¶
DisplayPath translates a worktree path to the equivalent path in the original repository for user-facing output. This is useful for logging and reporting where users expect to see paths relative to their working directory, not temporary worktree paths. If the path is not within a worktree, it returns the path unchanged.
func (*Worktrees) Stacks ¶
Stacks returns a slice of stacks that can be found in the diffs found in worktrees.
This can be useful, as stacks need to be discovered in worktrees, generated, then diffed on-disk to find changed units.
They are returned as added, removed, and changed stacks, respectively.