worktree

package
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

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

View Source
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

type ValidateDeletionParams struct {
	RepoURL string
	Branch  string
}

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.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL