Expand description
The worktree operation layer (issue #95).
Workspace is the public, stateless surface: discovered from a
directory, it enumerates, creates, and removes worktrees and reads their
wt.* metadata with no prompting, no terminal, and no
Cx — outcomes and warnings are returned as data and the
caller decides how (or whether) to present them. The wt CLI and TUI are
thin interactive wrappers over this module; embedders (karet) call it
directly and must resolve worktree paths through it rather than
reimplementing the .wt.toml layout rules.
rows is the crate-internal row assembly on top: enriched listing rows,
worktree-less branch rows (issue #47), sorting, and the remove/prune guard
evaluation shared by the CLI and TUI.
Every type reachable through the public API is re-exported here. A doctest
compiles as its own crate, so this one fails exactly when an embedder could
not name what CreatedWorktree and RemovedWorktree hand back — which
a crate-internal test cannot catch, since service is visible in-crate:
use wt::worktree::{
CreatedWorktree, HookOutcome, RemovedWorktree, SubmoduleSeeding, SubmodulesOutcome,
};
fn inspect(created: &CreatedWorktree, removed: &RemovedWorktree) {
let _: &SubmoduleSeeding = &created.submodule_seeding;
let _: &SubmodulesOutcome = &created.submodules;
let _: &HookOutcome = &created.post_create;
let _: &HookOutcome = &removed.pre_remove;
}Re-exports§
pub use crate::config::wtconfig::SCHEMA_VERSION;
Structs§
- Create
Options - Options for
Workspace::create. - Created
Worktree - The outcome of
Workspace::create. - Meta
Update - A
wt.<branch>.*metadata update forWorkspace::write_meta: everySomefield is written and everyNonefield leaves the recorded value untouched, so a caller refreshing one key cannot clobber the rest. - Remove
Options - Options for
Workspace::remove. The worktree-removal force is decoupled from the branch-deletion force: the TUI confirm dialog forces removal of a dirty worktree without ever force-deleting an unmerged branch (spec §10/§12). - Removed
Worktree - The outcome of
Workspace::remove. - Repo
Lock - A held advisory repository lock (issue #99): while alive, no other
wt(or embedder going through this library) can mutate worktrees orwt.*metadata in the repository. Released on drop. - Submodule
Seeding - What the local-mirror seeding step managed to do, as counts plus the
failures. Purely informational: seeding is always followed by a stock
git submodule update --init --recursive, so a non-emptyfailedhere does not mean the submodules are unpopulated. - Workspace
- A discovered repository with its resolved configuration and environment snapshot: the entry point of the stateless worktree API.
Enums§
- Hook
Outcome - How a hook invocation went, reported as data (the service never prints).
- Submodules
Outcome - How the post-create submodule initialization went.