worktree

package
v0.18.1 Latest Latest
Warning

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

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

Documentation

Overview

Package worktree provides worktree management functionality and error definitions.

Package worktree is a generated GoMock package.

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 MockWorktree

type MockWorktree struct {
	// contains filtered or unexported fields
}

MockWorktree is a mock of Worktree interface.

func NewMockWorktree

func NewMockWorktree(ctrl *gomock.Controller) *MockWorktree

NewMockWorktree creates a new mock instance.

func (*MockWorktree) AddToStatus

func (m *MockWorktree) AddToStatus(params AddToStatusParams) error

AddToStatus mocks base method.

func (*MockWorktree) BuildPath

func (m *MockWorktree) BuildPath(repoURL, remoteName, branch string) string

BuildPath mocks base method.

func (*MockWorktree) CleanupDirectory

func (m *MockWorktree) CleanupDirectory(worktreePath string) error

CleanupDirectory mocks base method.

func (*MockWorktree) Create

func (m *MockWorktree) Create(params CreateParams) error

Create mocks base method.

func (*MockWorktree) Delete

func (m *MockWorktree) Delete(params DeleteParams) error

Delete mocks base method.

func (*MockWorktree) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockWorktree) EnsureBranchExists

func (m *MockWorktree) EnsureBranchExists(repoPath, branch string) error

EnsureBranchExists mocks base method.

func (*MockWorktree) Exists

func (m *MockWorktree) Exists(repoPath, branch string) (bool, error)

Exists mocks base method.

func (*MockWorktree) GetPath

func (m *MockWorktree) GetPath(repoPath, branch string) (string, error)

GetPath mocks base method.

func (*MockWorktree) RemoveFromStatus

func (m *MockWorktree) RemoveFromStatus(repoURL, branch string) error

RemoveFromStatus mocks base method.

func (*MockWorktree) ValidateCreation

func (m *MockWorktree) ValidateCreation(params ValidateCreationParams) error

ValidateCreation mocks base method.

func (*MockWorktree) ValidateDeletion

func (m *MockWorktree) ValidateDeletion(params ValidateDeletionParams) error

ValidateDeletion mocks base method.

type MockWorktreeMockRecorder

type MockWorktreeMockRecorder struct {
	// contains filtered or unexported fields
}

MockWorktreeMockRecorder is the mock recorder for MockWorktree.

func (*MockWorktreeMockRecorder) AddToStatus

func (mr *MockWorktreeMockRecorder) AddToStatus(params any) *gomock.Call

AddToStatus indicates an expected call of AddToStatus.

func (*MockWorktreeMockRecorder) BuildPath

func (mr *MockWorktreeMockRecorder) BuildPath(repoURL, remoteName, branch any) *gomock.Call

BuildPath indicates an expected call of BuildPath.

func (*MockWorktreeMockRecorder) CleanupDirectory

func (mr *MockWorktreeMockRecorder) CleanupDirectory(worktreePath any) *gomock.Call

CleanupDirectory indicates an expected call of CleanupDirectory.

func (*MockWorktreeMockRecorder) Create

func (mr *MockWorktreeMockRecorder) Create(params any) *gomock.Call

Create indicates an expected call of Create.

func (*MockWorktreeMockRecorder) Delete

func (mr *MockWorktreeMockRecorder) Delete(params any) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockWorktreeMockRecorder) EnsureBranchExists

func (mr *MockWorktreeMockRecorder) EnsureBranchExists(repoPath, branch any) *gomock.Call

EnsureBranchExists indicates an expected call of EnsureBranchExists.

func (*MockWorktreeMockRecorder) Exists

func (mr *MockWorktreeMockRecorder) Exists(repoPath, branch any) *gomock.Call

Exists indicates an expected call of Exists.

func (*MockWorktreeMockRecorder) GetPath

func (mr *MockWorktreeMockRecorder) GetPath(repoPath, branch any) *gomock.Call

GetPath indicates an expected call of GetPath.

func (*MockWorktreeMockRecorder) RemoveFromStatus

func (mr *MockWorktreeMockRecorder) RemoveFromStatus(repoURL, branch any) *gomock.Call

RemoveFromStatus indicates an expected call of RemoveFromStatus.

func (*MockWorktreeMockRecorder) ValidateCreation

func (mr *MockWorktreeMockRecorder) ValidateCreation(params any) *gomock.Call

ValidateCreation indicates an expected call of ValidateCreation.

func (*MockWorktreeMockRecorder) ValidateDeletion

func (mr *MockWorktreeMockRecorder) ValidateDeletion(params any) *gomock.Call

ValidateDeletion indicates an expected call of ValidateDeletion.

type NewWorktreeParams

type NewWorktreeParams struct {
	FS            fs.FS
	Git           git.Git
	StatusManager status.Manager
	Logger        logger.Logger
	Prompt        prompt.Prompt
	BasePath      string
	Verbose       bool
}

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

	// 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)

	// GetPath gets the path of a worktree for a branch.
	GetPath(repoPath, branch string) (string, error)
}

Worktree interface provides worktree management capabilities.

func NewWorktree

func NewWorktree(params NewWorktreeParams) Worktree

NewWorktree creates a new Worktree instance.

Jump to

Keyboard shortcuts

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