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 contains stacks whose terragrunt.stack.hcl was added in the git diff.
Added []*component.Stack
// Removed contains stacks whose terragrunt.stack.hcl was removed in the git diff.
Removed []*component.Stack
// Changed contains stacks whose terragrunt.stack.hcl was modified in the git diff.
Changed []StackDiffChangedPair
// ReadingAffected contains stacks whose terragrunt.stack.hcl did not change directly,
// but that read files which did. These are identified during stack generation and need
// to be walked for unit-level changes.
ReadingAffected []StackDiffChangedPair
}
type StackDiffChangedPair ¶
type WorktreeOpts ¶ added in v1.0.1
type WorktreeOpts struct {
WorkingDir string
GitExpressions filter.GitExpressions
Experiments experiment.Experiments
}
WorktreeOpts contains parameters for NewWorktrees.
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 maps Git expression strings to their corresponding worktree pairs.
WorktreePairs map[string]WorktreePair
// OriginalWorkingDir is the user's working directory before worktrees were created.
OriginalWorkingDir string
// ReadingAffectedStacks holds stacks identified during generation as affected by
// changes to files they read, even though the stack file itself did not change in
// the git diff. These are included in Stacks().ReadingAffected so that the worktree
// discovery phase walks them for unit-level changes.
ReadingAffectedStacks []StackDiffChangedPair
// 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 ¶
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.