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 wtm 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 is the counterpart of Exec: it stays on the machine, with the worktree as working directory, for editors, agents and anything else working on the files rather than in the running application.
Types ¶
type Entry ¶
type Options ¶
type Options struct {
Name string // project name in the registry
Project config.Project
Branch string
Base string
NoStart bool
NoPostCreate bool // skip the project's post_create on this create
// RunAfter and ExecAfter are the commands of `create --run` and
// `create --exec`, played once the create is done: the first on the host
// from the worktree, the second in the application container. Both are
// shell lines and never persisted, unlike post_create.
RunAfter string
ExecAfter string
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
// Confirm asks a yes-or-no question, and is nil when nobody is there to
// answer. The memory advisory is its only caller: it rests on an average
// over the running stacks, which predicts neither a light stack nor a heavy
// one, so it is worth a question to a person and never worth failing the
// create of a script or an agent.
Confirm func(question string) bool
}