Documentation
¶
Overview ¶
Package parallel provides multi-worktree orchestration for parallel branch execution.
This package extends devflow's git worktree primitives to support fork/join workflows where multiple branches execute in parallel, each in their own isolated worktree.
Index ¶
- type ConflictFile
- type Manager
- func (m *Manager) AbortMerge() error
- func (m *Manager) BaseBranch() string
- func (m *Manager) BaseDir() string
- func (m *Manager) BaseRepo() string
- func (m *Manager) BranchCount() int
- func (m *Manager) CleanupAll() error
- func (m *Manager) CleanupBranch(branchID string) error
- func (m *Manager) ContinueMerge(message string) error
- func (m *Manager) CreateBranchWorktree(branchID, gitBranch string) (string, error)
- func (m *Manager) GetWorktreePath(branchID string) string
- func (m *Manager) GitContextForBranch(branchID string) (*git.Context, error)
- func (m *Manager) ListBranchWorktrees() map[string]string
- func (m *Manager) MergeBranches(ctx context.Context, cfg MergeConfig) ([]MergeResult, error)
- func (m *Manager) MergeSingleBranch(ctx context.Context, branchID string, cfg MergeConfig) *MergeResult
- func (m *Manager) ResolveConflict(path, resolvedContent string) error
- type MergeConfig
- type MergeResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConflictFile ¶
type ConflictFile struct {
Path string // File path relative to repo root
OursContent string // Content from base branch
TheirsContent string // Content from feature branch
Markers string // Full file content with conflict markers
}
ConflictFile describes a merge conflict.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager orchestrates multiple worktrees for parallel branch execution.
It maintains a mapping from branch IDs (logical identifiers from the workflow) to git worktree paths. Each parallel branch gets its own isolated worktree, allowing concurrent git operations without conflicts.
The Manager uses the "base branch" (whatever branch was checked out at fork time) as the starting point for all branch worktrees. Merges go back to this base branch, NOT to a hardcoded "main" branch.
Thread-safe for concurrent worktree operations.
func NewManager ¶
NewManager creates a ParallelWorktreeManager for the given repository.
baseDir is where worktrees will be created (e.g., /tmp/worktrees/run-123) repoPath is the path to the main repository baseBranch is the current branch (working branch) - merges return here
func (*Manager) AbortMerge ¶
AbortMerge aborts an in-progress merge.
func (*Manager) BaseBranch ¶
BaseBranch returns the base branch name (where merges go).
func (*Manager) BranchCount ¶
BranchCount returns the number of active branch worktrees.
func (*Manager) CleanupAll ¶
CleanupAll removes all branch worktrees.
func (*Manager) CleanupBranch ¶
CleanupBranch removes a single branch worktree.
func (*Manager) ContinueMerge ¶
ContinueMerge completes a merge after conflicts have been resolved.
func (*Manager) CreateBranchWorktree ¶
CreateBranchWorktree creates an isolated worktree for a parallel branch.
branchID is the logical identifier from the workflow (e.g., "workerA") gitBranch is the git branch name to create/checkout (if empty, uses branchID)
Returns the path to the worktree directory.
func (*Manager) GetWorktreePath ¶
GetWorktreePath returns the worktree path for a branch ID. Returns empty string if not found.
func (*Manager) GitContextForBranch ¶
GitContextForBranch creates a git.Context for a specific branch's worktree. Returns nil if the branch doesn't have a worktree.
func (*Manager) ListBranchWorktrees ¶
ListBranchWorktrees returns all active branch worktrees.
func (*Manager) MergeBranches ¶
func (m *Manager) MergeBranches(ctx context.Context, cfg MergeConfig) ([]MergeResult, error)
MergeBranches merges all branch worktrees back to the base working branch. Returns results for each branch, including any conflicts.
func (*Manager) MergeSingleBranch ¶
func (m *Manager) MergeSingleBranch(ctx context.Context, branchID string, cfg MergeConfig) *MergeResult
MergeSingleBranch merges one branch worktree back to the base working branch.
func (*Manager) ResolveConflict ¶
ResolveConflict writes resolved content for a conflicted file.
type MergeConfig ¶
type MergeConfig struct {
// CommitMessage is the message for the merge commit (if not fast-forward)
CommitMessage string
// NoFastForward forces a merge commit even if fast-forward is possible
NoFastForward bool
// SquashMerge squashes all branch commits into one
SquashMerge bool
}
MergeConfig configures how branches are merged back to base.
type MergeResult ¶
type MergeResult struct {
BranchID string
Success bool
Conflicts []ConflictFile
CommitSHA string
Error error
}
MergeResult contains the outcome of merging a branch.