Documentation
¶
Overview ¶
Package worktree provides worktree management functionality and error definitions.
Package worktree provides worktree management functionality for CM.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Worktree errors. ErrWorktreeExists = errors.New("worktree already exists") ErrWorktreeNotInStatus = errors.New("worktree not found in status file") // Directory errors. ErrDirectoryExists = errors.New("directory already exists") // User interaction errors. ErrDeletionCancelled = errors.New("deletion cancelled by user") )
Error definitions for worktree package.
Functions ¶
This section is empty.
Types ¶
type AddToStatusParams ¶
type AddToStatusParams struct { RepoURL string Branch string WorktreePath string WorkspacePath string Remote string IssueInfo *issue.Info }
AddToStatusParams contains parameters for adding worktree to status.
type CreateParams ¶
type CreateParams struct { RepoURL string Branch string WorktreePath string RepoPath string Remote string IssueInfo *issue.Info Force bool }
CreateParams contains parameters for worktree creation.
type DeleteParams ¶
type DeleteParams struct { RepoURL string Branch string WorktreePath string RepoPath string Force bool }
DeleteParams contains parameters for worktree deletion.
type NewWorktreeParams ¶
type NewWorktreeParams struct { FS fs.FS Git git.Git StatusManager status.Manager Logger logger.Logger Prompt prompt.Prompter RepositoriesDir string }
NewWorktreeParams contains parameters for creating a new Worktree instance.
type ValidateCreationParams ¶
type ValidateCreationParams struct { RepoURL string Branch string WorktreePath string RepoPath string }
ValidateCreationParams contains parameters for worktree creation validation.
type ValidateDeletionParams ¶
ValidateDeletionParams contains parameters for worktree deletion validation.
type Worktree ¶
type Worktree interface { // BuildPath constructs a worktree path from repository URL, remote name, and branch. BuildPath(repoURL, remoteName, branch string) string // Create creates a new worktree with proper validation and cleanup. Create(params CreateParams) error // CheckoutBranch checks out the branch in the worktree after hooks have been executed. CheckoutBranch(worktreePath, branch string) error // Delete deletes a worktree with proper cleanup and confirmation. Delete(params DeleteParams) error // ValidateCreation validates that worktree creation is possible. ValidateCreation(params ValidateCreationParams) error // ValidateDeletion validates that worktree deletion is possible. ValidateDeletion(params ValidateDeletionParams) error // EnsureBranchExists ensures the specified branch exists, creating it if necessary. EnsureBranchExists(repoPath, branch string) error // AddToStatus adds the worktree to the status file. AddToStatus(params AddToStatusParams) error // RemoveFromStatus removes the worktree from the status file. RemoveFromStatus(repoURL, branch string) error // CleanupDirectory removes the worktree directory. CleanupDirectory(worktreePath string) error // Exists checks if a worktree exists for the specified branch. Exists(repoPath, branch string) (bool, error) // SetLogger sets the logger for this worktree instance. SetLogger(logger logger.Logger) }
Worktree interface provides worktree management capabilities.
func NewWorktree ¶
func NewWorktree(params NewWorktreeParams) Worktree
NewWorktree creates a new Worktree instance.