worktree

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package worktree creates, starts, stops and removes project worktrees, and drives the docker stack that goes with each one.

Index

Constants

View Source
const StatusUnknown = "-"

StatusUnknown is shown when docker did not answer in time. A listing is a read-only question about git and must never hang on an unresponsive daemon.

Variables

This section is empty.

Functions

func Create

func Create(ctx context.Context, o Options) error

Create builds the worktree and, unless NoStart, brings its stack up.

func Exec

func Exec(ctx context.Context, o Options, service string, command []string) error

Exec runs a command inside the worktree's application container. Doing it by hand means knowing the compose project name wtc derives, which is internal knowledge no user should need.

func Path

func Path(ctx context.Context, o Options) (string, error)

Path returns the worktree directory, so a shell can compose with it: `cd $(wtm path feat/x)`.

func Remove

func Remove(ctx context.Context, o Options) error

Remove stops the stack then removes the worktree, keeping the local branch.

func Run

func Run(ctx context.Context, o Options, command []string) error

Run executes a command on the host with the worktree as working directory. This is the counterpart of Exec: Exec goes inside the stack's container, Run stays on the machine, for editors, agents and anything else that works on the files rather than in the running application.

func Start

func Start(ctx context.Context, o Options) error

Start brings an existing worktree's stack back up. Without it, restarting a stopped worktree means calling wtc with the index it derives, which is exactly the internal knowledge this tool exists to hide.

func Stop

func Stop(ctx context.Context, o Options) error

Stop takes the stack down and leaves the worktree in place.

Types

type Entry

type Entry struct {
	stack.Worktree
	// Status is "up", "down", or "-" when docker could not be reached.
	Status string
}

Entry is one worktree as `wtm list` shows it.

func List

func List(ctx context.Context, o Options) ([]Entry, error)

List returns the project's worktrees along with the state of their stack.

type Options

type Options struct {
	Name       string // project name in the registry
	Project    config.Project
	Branch     string
	Base       string
	NoStart    bool
	Force      bool // remove despite uncommitted tracked changes
	BackupsDir string
	Runner     execx.Runner
	Out        io.Writer
	Stack      *stack.Client
	Resolver   *index.Resolver // resolves and records each branch's stable index
}

Options carries everything a worktree command needs.

Jump to

Keyboard shortcuts

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