Documentation
¶
Overview ¶
Package worktree creates, starts, stops and removes project worktrees, and drives the docker stack that goes with each one.
Index ¶
- Constants
- func Create(ctx context.Context, o Options) error
- func Exec(ctx context.Context, o Options, service string, command []string) error
- func Path(ctx context.Context, o Options) (string, error)
- func Remove(ctx context.Context, o Options) error
- func Run(ctx context.Context, o Options, command []string) error
- func Start(ctx context.Context, o Options) error
- func Stop(ctx context.Context, o Options) error
- type Entry
- type Options
Constants ¶
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 Exec ¶
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 ¶
Path returns the worktree directory, so a shell can compose with it: `cd $(wtm path feat/x)`.
func Run ¶
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.
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.
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.