Documentation
¶
Overview ¶
Package cm provides worktree management functionality and error definitions.
Index ¶
- Variables
- type CM
- type CloneOpts
- type CreateWorkTreeOpts
- type CreateWorkspaceParams
- type DeleteAllWorktreesOpts
- type DeleteRepositoryParams
- type DeleteWorkspaceParams
- type DeleteWorktreeOpts
- type InitOpts
- type ListWorktreesOpts
- type LoadWorktreeOpts
- type NewCMParams
- type OpenWorktreeOpts
- type RepositoryInfo
- type RepositoryProvider
- type WorkspaceInfo
- type WorkspaceProvider
- type WorktreeProvider
Constants ¶
This section is empty.
Variables ¶
var ( // Git repository errors. ErrGitRepositoryNotFound = errors.New("not a valid Git repository: .git directory not found") ErrGitRepositoryInvalid = errors.New("not a valid Git repository") // Repository and branch errors. ErrRepositoryURLEmpty = errors.New("repository URL cannot be empty") // Worktree creation errors. ErrWorktreeExists = errors.New("worktree already exists for this branch") ErrRepositoryNotClean = errors.New("repository is not in a clean state") ErrDirectoryExists = errors.New("worktree directory already exists") // Worktree deletion errors. ErrWorktreeNotInStatus = errors.New("worktree not found in status file") ErrDeletionCancelled = errors.New("deletion cancelled by user") // Load branch errors. ErrBranchNameContainsColon = errors.New("branch name contains invalid character ':'") ErrArgumentEmpty = errors.New("argument cannot be empty") ErrOriginRemoteNotFound = errors.New("origin remote not found or invalid") ErrOriginRemoteInvalidURL = errors.New("origin remote URL is not a valid Git hosting service URL") ErrFailedToLoadRepositories = errors.New("failed to load repositories from status file") // Initialization errors. ErrNotInitialized = errors.New("CM is not initialized") ErrFailedToExpandRepositoriesDir = errors.New("failed to expand repositories directory") // Project detection errors. ErrNoGitRepositoryOrWorkspaceFound = errors.New("no Git repository or workspace found") ErrWorkspaceModeNotSupported = errors.New("workspace mode not yet supported for load command") // Clone errors. ErrRepositoryExists = errors.New("repository already exists") ErrUnsupportedRepositoryURLFormat = errors.New("unsupported repository URL format") // Clone operation errors. ErrFailedToDetectDefaultBranch = errors.New("failed to detect default branch") ErrFailedToCloneRepository = errors.New("failed to clone repository") ErrFailedToInitializeRepository = errors.New("failed to initialize repository in CM") // Workspace creation errors. ErrInvalidWorkspaceName = errors.New("invalid workspace name") ErrRepositoryNotFound = errors.New("repository not found") ErrInvalidRepository = errors.New("invalid repository") ErrDuplicateRepository = errors.New("duplicate repository") ErrWorkspaceAlreadyExists = errors.New("workspace already exists") ErrStatusUpdate = errors.New("status file update failed") ErrRepositoryAddition = errors.New("failed to add repository to status file") ErrPathResolution = errors.New("path resolution failed") // Repository deletion errors. ErrInvalidRepositoryName = errors.New("invalid repository name") // Workspace deletion errors. ErrWorkspaceNotFound = errors.New("workspace not found") )
Error definitions for cm package.
Functions ¶
This section is empty.
Types ¶
type CM ¶
type CM interface {
// CreateWorkTree executes the main application logic.
CreateWorkTree(branch string, opts ...CreateWorkTreeOpts) error
// DeleteWorkTree deletes a worktree for the specified branch.
DeleteWorkTree(branch string, force bool, opts ...DeleteWorktreeOpts) error
// DeleteWorkTrees deletes multiple worktrees for the specified branches.
DeleteWorkTrees(branches []string, force bool) error
// DeleteAllWorktrees deletes all worktrees for the current repository or workspace.
DeleteAllWorktrees(force bool, opts ...DeleteAllWorktreesOpts) error
// OpenWorktree opens an existing worktree in the specified IDE.
OpenWorktree(worktreeName, ideName string, opts ...OpenWorktreeOpts) error
// ListWorktrees lists worktrees for a workspace or repository.
ListWorktrees(opts ...ListWorktreesOpts) ([]status.WorktreeInfo, error)
// LoadWorktree loads a branch from a remote source and creates a worktree.
LoadWorktree(branchArg string, opts ...LoadWorktreeOpts) error
// Init initializes CM configuration.
Init(opts InitOpts) error
// Clone clones a repository and initializes it in CM.
Clone(repoURL string, opts ...CloneOpts) error
// ListRepositories lists all repositories from the status file with base path validation.
ListRepositories() ([]RepositoryInfo, error)
// DeleteRepository deletes a repository and all associated resources.
DeleteRepository(params DeleteRepositoryParams) error
// CreateWorkspace creates a new workspace with repository selection.
CreateWorkspace(params CreateWorkspaceParams) error
// DeleteWorkspace deletes a workspace and all associated resources.
DeleteWorkspace(params DeleteWorkspaceParams) error
// ListWorkspaces lists all workspaces from the status file.
ListWorkspaces() ([]WorkspaceInfo, error)
// SetLogger sets the logger for this CM instance.
SetLogger(logger logger.Logger)
}
CM interface provides Git repository detection functionality.
type CloneOpts ¶
type CloneOpts struct {
Recursive bool // defaults to true
}
CloneOpts contains optional parameters for Clone.
type CreateWorkTreeOpts ¶
type CreateWorkTreeOpts struct {
IDEName string
IssueRef string
WorkspaceName string
RepositoryName string
Force bool
Remote string // Remote name to use (defaults to "origin" if empty)
}
CreateWorkTreeOpts contains optional parameters for CreateWorkTree.
type CreateWorkspaceParams ¶ added in v0.20.0
type CreateWorkspaceParams struct {
WorkspaceName string // Name of the workspace
Repositories []string // Repository identifiers (names, paths, URLs)
}
CreateWorkspaceParams contains parameters for CreateWorkspace.
type DeleteAllWorktreesOpts ¶ added in v0.25.0
type DeleteAllWorktreesOpts struct {
WorkspaceName string // Name of the workspace to delete all worktrees for (optional)
RepositoryName string // Name of the repository to delete all worktrees for (optional)
}
DeleteAllWorktreesOpts contains options for DeleteAllWorktrees.
type DeleteRepositoryParams ¶ added in v0.26.0
type DeleteRepositoryParams struct {
RepositoryName string // Name of the repository to delete
Force bool // Skip confirmation prompts
}
DeleteRepositoryParams contains parameters for DeleteRepository.
type DeleteWorkspaceParams ¶ added in v0.24.0
type DeleteWorkspaceParams struct {
WorkspaceName string // Name of the workspace to delete
Force bool // Skip confirmation prompts
}
DeleteWorkspaceParams contains parameters for DeleteWorkspace.
type DeleteWorktreeOpts ¶ added in v0.24.0
DeleteWorktreeOpts contains optional parameters for DeleteWorkTree.
type InitOpts ¶
type InitOpts struct {
Force bool
Reset bool
RepositoriesDir string
WorkspacesDir string
StatusFile string
NonInteractive bool
}
InitOpts contains optional parameters for Init.
type ListWorktreesOpts ¶ added in v0.24.0
type ListWorktreesOpts struct {
WorkspaceName string // Name of the workspace to list worktrees for (optional)
RepositoryName string // Name of the repository to list worktrees for (optional)
}
ListWorktreesOpts contains options for ListWorktrees.
type LoadWorktreeOpts ¶
type LoadWorktreeOpts struct {
IDEName string
RepositoryName string
Remote string // Remote name to use (defaults to "origin" if empty)
}
LoadWorktreeOpts contains optional parameters for LoadWorktree.
type NewCMParams ¶
type NewCMParams struct {
RepositoryProvider RepositoryProvider
WorkspaceProvider WorkspaceProvider
WorktreeProvider WorktreeProvider
Config config.Config
ConfigPath string // Path to the config file (used for saving config)
Hooks hooks.HookManagerInterface
Status status.Manager
FS fs.FS
Git git.Git
Logger logger.Logger
Prompt prompt.Prompter
}
NewCMParams contains parameters for creating a new CM instance.
type OpenWorktreeOpts ¶ added in v0.25.0
type OpenWorktreeOpts struct {
WorkspaceName string // Name of the workspace to open worktree for (optional)
RepositoryName string // Name of the repository to open worktree for (optional)
}
OpenWorktreeOpts contains optional parameters for OpenWorktree.
type RepositoryInfo ¶ added in v0.16.0
RepositoryInfo contains information about a repository for display purposes.
type RepositoryProvider ¶ added in v0.19.0
type RepositoryProvider func(params repository.NewRepositoryParams) repository.Repository
RepositoryProvider is a function type that creates repository instances.
type WorkspaceInfo ¶ added in v0.24.0
WorkspaceInfo contains information about a workspace for display purposes.
type WorkspaceProvider ¶ added in v0.19.0
type WorkspaceProvider func(params workspace.NewWorkspaceParams) workspace.Workspace
WorkspaceProvider is a function type that creates workspace instances.
type WorktreeProvider ¶ added in v0.24.0
type WorktreeProvider func(params worktree.NewWorktreeParams) worktree.Worktree
WorktreeProvider is a function type that creates worktree instances.