Documentation
¶
Index ¶
- Variables
- func NewWorktreeDirProvider(log *logger.Logger, cfg config.Config, projectRoot string) git.WorktreeDirProvider
- type GitManagerFactory
- type Project
- type ProjectManager
- type ProjectRecord
- type ProjectState
- type ProjectStatus
- type PruneStaleResult
- type WorktreeRecord
- type WorktreeState
- type WorktreeStatus
Constants ¶
This section is empty.
Variables ¶
var ErrNotInProjectPath = errors.New("not in a registered project path")
var ErrProjectExists = errors.New("project already exists")
var ErrProjectHandleNotInitialized = errors.New("project handle not initialized")
var ErrProjectNotFound = errors.New("project not found")
var ErrProjectNotRegistered = errors.New("project root is not registered")
var ErrWorktreeExists = errors.New("worktree already exists for branch")
var ErrWorktreeNotFound = errors.New("worktree not found")
Functions ¶
func NewWorktreeDirProvider ¶ added in v0.2.0
func NewWorktreeDirProvider(log *logger.Logger, cfg config.Config, projectRoot string) git.WorktreeDirProvider
NewWorktreeDirProvider creates a WorktreeDirProvider for the given project. It looks up the project in the registry to populate known worktree paths, enabling path reuse for existing worktrees and UUID-based generation for new ones. External callers (e.g. container/shared) use this instead of the full project service.
Types ¶
type GitManagerFactory ¶ added in v0.2.0
type GitManagerFactory func(projectRoot string) (*git.GitManager, error)
GitManagerFactory creates a git.GitManager for the given project root. Production callers pass git.NewGitManager; tests pass a factory returning gittest.InMemoryGitManager.GitManager.
type Project ¶ added in v0.2.0
type Project interface {
Name() string
RepoPath() string
Record() (ProjectRecord, error)
CreateWorktree(ctx context.Context, branch, base string) (string, error)
AddWorktree(ctx context.Context, branch, base string) (WorktreeState, error)
RemoveWorktree(ctx context.Context, branch string, deleteBranch bool) error
PruneStaleWorktrees(ctx context.Context, dryRun bool) (*PruneStaleResult, error)
ListWorktrees(ctx context.Context) ([]WorktreeState, error)
GetWorktree(ctx context.Context, branch string) (WorktreeState, error)
}
Project is the runtime behavior contract for a single registered project. The concrete implementation is package-private.
type ProjectManager ¶ added in v0.2.0
type ProjectManager interface {
Register(ctx context.Context, name string, repoPath string) (Project, error)
Update(ctx context.Context, entry config.ProjectEntry) (Project, error)
List(ctx context.Context) ([]config.ProjectEntry, error)
ListProjects(ctx context.Context) ([]ProjectState, error)
Remove(ctx context.Context, root string) error
Get(ctx context.Context, root string) (Project, error)
ResolvePath(ctx context.Context, cwd string) (Project, error)
CurrentProject(ctx context.Context) (Project, error)
ListWorktrees(ctx context.Context) ([]WorktreeState, error)
}
func NewProjectManager ¶ added in v0.2.0
func NewProjectManager(cfg config.Config, log *logger.Logger, gitFactory GitManagerFactory) (ProjectManager, error)
type ProjectRecord ¶ added in v0.2.0
type ProjectRecord struct {
Name string
Root string
Worktrees map[string]WorktreeRecord
}
ProjectRecord is the persisted model for a registered project.
type ProjectState ¶ added in v0.4.0
type ProjectState struct {
Name string
Root string
Worktrees []WorktreeState
Status ProjectStatus
StatusErr error // non-nil when Status is ProjectInaccessible
}
ProjectState is a caller-facing enriched project view. Analogous to WorktreeState: combines registry data with runtime checks.
type ProjectStatus ¶ added in v0.4.0
type ProjectStatus string
ProjectStatus captures the health of a project's root directory.
const ( ProjectOK ProjectStatus = "ok" ProjectMissing ProjectStatus = "missing" ProjectInaccessible ProjectStatus = "inaccessible" )
type PruneStaleResult ¶ added in v0.2.0
type WorktreeRecord ¶ added in v0.2.0
WorktreeRecord is the persisted model for a project worktree.
type WorktreeState ¶ added in v0.2.0
type WorktreeState struct {
Project string
Branch string
Path string
Head string
IsDetached bool
ExistsInRegistry bool
ExistsInGit bool
Status WorktreeStatus
IsLocked bool // worktree is locked against pruning (.git/worktrees/<slug>/locked exists)
InspectError error // non-nil indicates degraded health check (permissions, git errors)
}
WorktreeState is a caller-facing merged worktree view.
type WorktreeStatus ¶ added in v0.2.0
type WorktreeStatus string
WorktreeStatus captures the health/drift status of a worktree.
const ( WorktreeHealthy WorktreeStatus = "healthy" WorktreeRegistryOnly WorktreeStatus = "registry_only" WorktreeGitOnly WorktreeStatus = "git_only" WorktreeBroken WorktreeStatus = "broken" WorktreeDotGitMissing WorktreeStatus = "dotgit_missing" WorktreeGitMetadataMissing WorktreeStatus = "git_metadata_missing" )