interfaces

package
v0.27.1 Latest Latest
Warning

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

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

Documentation

Overview

Package interfaces defines the worktree interface for dependency injection. This package is separate to avoid circular imports.

Index

Constants

This section is empty.

Variables

This section is empty.

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              interface{} // fs.FS
	Git             interface{} // git.Git
	StatusManager   interface{} // status.Manager
	Logger          interface{} // logger.Logger
	Prompt          interface{} // 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 defines the interface for worktree operations. This interface is implemented by the concrete worktree types.

type WorktreeProvider

type WorktreeProvider func(params NewWorktreeParams) Worktree

WorktreeProvider defines the function signature for creating worktree instances.

Jump to

Keyboard shortcuts

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