Documentation
¶
Overview ¶
Package worktree orchestrates creating a new git worktree: resolving paths from config templates, branching from origin's default branch, copying env files, and installing dependencies.
Index ¶
- func Branch(cfg config.Config, name string) string
- func Dir(cfg config.Config, mainDir string) string
- func Init(mainDir string, w io.Writer) error
- func List(mainDir string, w io.Writer) error
- func New(cfg config.Config, mainDir, name, branch string, w io.Writer) (string, error)
- func Open(cfg config.Config, mainDir, name string, w io.Writer) error
- func Path(cfg config.Config, mainDir, name string) (string, error)
- func Remove(cfg config.Config, mainDir, name string, w io.Writer) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dir ¶
Dir resolves the base directory (parent of all worktrees for this repo) from cfg.WorktreeDir, substituting {repo} and resolving it relative to mainDir.
func Init ¶ added in v0.1.3
Init scaffolds a .wt.toml in mainDir: an install_commands line if installer.Suggest detects one, and an env_files line for any gitignored file whose name looks like local config (see envFileHints) — these are exactly the files a new worktree won't get from git itself. It refuses to overwrite an existing .wt.toml, and fails if nothing was detected (the defaults already fit). Status messages are written to w.
func List ¶
List prints every worktree registered against mainDir (the main checkout included) as a two-column, alignment-padded table: branch first, path second.
func New ¶
New creates a worktree named name (branch defaults to cfg.BranchPattern with name substituted if branch is empty), branching from origin's default branch. It copies configured env files, runs the install command unless disabled, and opens the editor unless disabled. Status messages are written to w. It returns the created worktree's path.
func Open ¶
Open opens the worktree named name in the configured editor — or, if name is empty, prompts the user to pick one via an interactive picker (the main checkout is offered as an option, labeled "(main)"). Status messages are written to w.
func Path ¶
Path returns the worktree path for name — or, if name is empty, prompts the user to pick one via an interactive picker (the main checkout is offered as an option, labeled "(main)"). It doesn't check the path exists.
Types ¶
This section is empty.