lifecycle

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package lifecycle owns the worktree creation, removal, and pruning verbs.

Index

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

func New(ctx context.Context, d deps.Deps, in NewInput) (string, error)

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 Prune

func Prune(ctx context.Context, d deps.Deps, in PruneInput) error

Prune removes merged (or all non-main) worktrees.

func Remove

func Remove(ctx context.Context, d deps.Deps, in RemoveInput) error

Remove removes a worktree and its artifact.

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 NewInput

type NewInput struct {
	Branch    string
	Base      string
	Open      bool
	Current   bool
	OutputDir string
}

NewInput parameterises a tp new invocation.

type PruneInput

type PruneInput struct {
	Base      string
	OutputDir string
	DryRun    bool
	All       bool
	Yes       bool
	// Cwd overrides os.Getwd for testing the cwd-inside guard.
	Cwd string
}

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

type SyncTarget struct {
	Path   string
	Branch string
}

SyncTarget is a worktree to sync configs into.

Jump to

Keyboard shortcuts

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