Documentation
¶
Overview ¶
Package lifecycle owns the worktree creation, removal, and pruning verbs.
Index ¶
- func LoadAndSync(ctx context.Context, d deps.Deps, sourceDir string, preloaded *config.Config, ...) (config.Config, *hook.PostErr, error)
- func New(ctx context.Context, d deps.Deps, in NewInput) (string, error)
- func OpenWorktree(ctx context.Context, d deps.Deps, openCmd []string, ...) error
- func Prune(ctx context.Context, d deps.Deps, in PruneInput) error
- func Remove(ctx context.Context, d deps.Deps, in RemoveInput) error
- func RemoveWorktreeAndArtifact(ctx context.Context, d deps.Deps, target, main worktree.Worktree, ...) (*hook.PostErr, error)
- type CreateResult
- type NewInput
- type PruneInput
- type RemoveInput
- type SyncTarget
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadAndSync ¶
func LoadAndSync( ctx context.Context, d deps.Deps, sourceDir string, preloaded *config.Config, extraPatterns []string, targets []SyncTarget, repoSlug, outputDir string, ) (config.Config, *hook.PostErr, error)
LoadAndSync syncs configs to all targets. When preloaded is non-nil it is used as-is, otherwise config is loaded from sourceDir. The returned *hook.PostErr is the first post-sync hook failure, already logged as a warning; syncing continued past it.
func New ¶
New creates a new worktree, emits the __TREEPAD_CD__ directive to d.Out, and returns the main worktree path (for callers that need it without an Out writer).
func OpenWorktree ¶
func OpenWorktree( ctx context.Context, d deps.Deps, openCmd []string, branch, wtPath, artifactPath, outputDir string, ) error
OpenWorktree opens the artifact (or worktree path when no artifact) via the configured command.
func RemoveWorktreeAndArtifact ¶
func RemoveWorktreeAndArtifact( ctx context.Context, d deps.Deps, target, main worktree.Worktree, outputDir string, force bool, ) (*hook.PostErr, error)
RemoveWorktreeAndArtifact removes a git worktree, its artifact, and its branch. A non-nil *hook.PostErr means the removal itself succeeded and only the post hook failed; it is logged as a warning here, so a CLI caller can discard it.
Types ¶
type CreateResult ¶
type CreateResult struct {
RC repo.Context
Cfg config.Config
WorktreePath string
ArtifactPath string
PostErr *hook.PostErr
}
CreateResult holds the output of a successful worktree creation. PostErr is non-nil when a post hook failed: the worktree exists and is complete, and the caller decides whether a failed post hook matters to it.
func CreateWorktreeWithSync ¶
func CreateWorktreeWithSync(ctx context.Context, d deps.Deps, branch, base, outputDir string) (CreateResult, error)
CreateWorktreeWithSync creates a worktree, syncs configs, and writes the artifact.
type PruneInput ¶
type RemoveInput ¶
type RemoveInput struct {
Branch string
OutputDir string
Force bool
// Cwd overrides os.Getwd for testing the cwd-inside guard.
Cwd string
}
RemoveInput parameterises a tp remove invocation.
type SyncTarget ¶
SyncTarget is a worktree to sync configs into.