codemanager

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: 20 Imported by: 0

Documentation

Overview

Package codemanager provides worktree management functionality and error definitions.

Index

Constants

This section is empty.

Variables

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

type CloneOpts struct {
	Recursive bool // defaults to true
}

CloneOpts contains optional parameters for Clone.

type CodeManager

type CodeManager 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)
}

CodeManager interface provides Git repository detection functionality.

func NewCodeManager

func NewCodeManager(params NewCodeManagerParams) (CodeManager, error)

NewCodeManager creates a new CodeManager instance.

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

type CreateWorkspaceParams struct {
	WorkspaceName string   // Name of the workspace
	Repositories  []string // Repository identifiers (names, paths, URLs)
}

CreateWorkspaceParams contains parameters for CreateWorkspace.

type DeleteAllWorktreesOpts

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

type DeleteRepositoryParams struct {
	RepositoryName string // Name of the repository to delete
	Force          bool   // Skip confirmation prompts
}

DeleteRepositoryParams contains parameters for DeleteRepository.

type DeleteWorkspaceParams

type DeleteWorkspaceParams struct {
	WorkspaceName string // Name of the workspace to delete
	Force         bool   // Skip confirmation prompts
}

DeleteWorkspaceParams contains parameters for DeleteWorkspace.

type DeleteWorktreeOpts

type DeleteWorktreeOpts struct {
	WorkspaceName  string
	RepositoryName string
}

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

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 NewCodeManagerParams

type NewCodeManagerParams struct {
	Dependencies *dependencies.Dependencies
}

NewCodeManagerParams contains parameters for creating a new CodeManager instance.

type OpenWorktreeOpts

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

type RepositoryInfo struct {
	Name              string
	Path              string
	InRepositoriesDir bool
}

RepositoryInfo contains information about a repository for display purposes.

type WorkspaceInfo

type WorkspaceInfo struct {
	Name         string
	Repositories []string
	Worktrees    []string
}

WorkspaceInfo contains information about a workspace for display purposes.

Directories

Path Synopsis
Package consts provides operation name constants for the hook system.
Package consts provides operation name constants for the hook system.

Jump to

Keyboard shortcuts

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