worktree

package
v0.35.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package worktree manages native-Git effort worktrees.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreationError

type CreationError struct {
	Message         string
	Condition       string
	ChangedEffort   bool
	ChangedTopology bool
	Cause           error
	RollbackCause   error
	Steps           []string
}

CreationError describes a failed managed creation after its compensating finish attempt. It retains the legacy error text while exposing every changed axis and recovery sequence to the command presentation boundary.

func (*CreationError) Diagnostic

func (e *CreationError) Diagnostic() (presentation.Diagnostic, error)

Diagnostic maps failed creation while retaining both mechanism identities.

func (*CreationError) Error

func (e *CreationError) Error() string

Error preserves the legacy managed-creation failure message.

func (*CreationError) Unwrap

func (e *CreationError) Unwrap() []error

Unwrap exposes both the creation and compensating-rollback mechanism causes.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func Open

func Open(roots awfgit.ControlRoots, open OpenCheckout, efforts *effort.Service) (*Manager, error)

Open composes a manager over the control roots and dependencies it is given. The roots arrive already resolved so one command resolves them once and the manager and its effort service provably reason about the same repository identity. Both dependencies are required: a manager silently defaulting its Git access or its effort authority would make the composition root's choices unverifiable.

func (*Manager) Add

func (m *Manager) Add(ctx context.Context, slug, base string) (Result, error)

func (*Manager) Integrate

func (m *Manager) Integrate(ctx context.Context, slug, gateCommand string) (Result, error)

func (*Manager) NewEffort

func (m *Manager) NewEffort(ctx context.Context, input effort.NewInput, base string) (effort.Record, Result, error)

NewEffort publishes the effort residents, then creates its managed worktree via the same standalone Add machinery (ADR-0189). On Add failure it invokes the narrow identity-bound creation rollback, removing the effort only when actual managed topology is proven absent.

func (*Manager) Remove

func (m *Manager) Remove(ctx context.Context, slug string) (Result, error)

type OpenCheckout

type OpenCheckout func(root string) (Runner, error)

OpenCheckout opens the Git surface of the checkout rooted at root. The manager reasons about two checkouts at once - the one it was invoked from and the managed one it is creating or retiring - so it opens each by root instead of holding a single handle.

type RefusalError

type RefusalError struct {
	Category        string
	Condition       string
	ChangedTopology bool
	NextAction      string
	NextActions     []string
	Err             error
}

func (*RefusalError) Diagnostic

func (e *RefusalError) Diagnostic() (presentation.Diagnostic, error)

Diagnostic maps a typed refusal into the common readable diagnostic.

func (*RefusalError) Error

func (e *RefusalError) Error() string

func (*RefusalError) Unwrap

func (e *RefusalError) Unwrap() error

type Result

type Result struct {
	Condition       string
	ChangedTopology bool
	NextAction      string
	Path            string
	Branch          string
}

Result carries structured managed-topology facts for orchestration and presentation mapping.

func (Result) Mutation

func (r Result) Mutation() (presentation.Mutation, error)

Mutation maps managed-topology facts into the common readable mutation.

type Runner

type Runner interface {
	WorktreeList(ctx context.Context) ([]awfgit.WorktreeRegistration, error)
	WorktreeAdd(ctx context.Context, path, branch, base string) error
	WorktreeRemove(ctx context.Context, path string) error
	WorktreePrune(ctx context.Context) error
	BranchExists(ctx context.Context, name string) (bool, error)
	BranchDelete(ctx context.Context, name string) error
	Ancestor(ctx context.Context, older, newer string) (bool, error)
	MergeBase(ctx context.Context, a, b string) (string, error)
	MergeFastForward(ctx context.Context, rev string) error
	MergeNoCommit(ctx context.Context, rev string) error
	ResolveCommit(ctx context.Context, revision string) (string, error)
	CurrentBranch(ctx context.Context) (string, error)
	ChangeCounts(ctx context.Context) (tracked, untracked int, err error)
	GitPath(ctx context.Context, name string) (string, error)
}

Runner is this package's own contract on one checkout's Git surface. It names exactly the operations the manager performs and nothing more, so the manager depends on what it uses rather than on a repository object; the composition root satisfies it with the Git seam's handle.

Jump to

Keyboard shortcuts

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