revive but worktree subcommands#14189
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d187730672
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| command::legacy::worktree::handle(cmd, &mut ctx, out) | ||
| .emit_metrics(metrics_ctx) | ||
| .show_root_cause_error_then_exit_without_destructors(output) | ||
| .map_err(CliError::from) |
There was a problem hiding this comment.
Update the bundled CLI skill for worktree
crates/but/AGENTS.md requires updating crates/but/skill/ after CLI command or workflow changes. This commit revives the but worktree CLI path here, but rg "worktree" crates/but/skill still returns no coverage, so bundled agents will keep stale CLI guidance and miss the revived worktree workflow.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
This PR revives the legacy but worktree CLI subcommands by reworking the but-worktrees crate into more “plumbing-style” APIs (taking gix::Repository/but_graph::Workspace inputs instead of a full but_ctx::Context), updating the legacy CLI command wiring, and adding integration/destroy behavior around auto-created worktree branches.
Changes:
- Reintroduced/covered
but worktree new/list/integrate/destroyvia legacy CLI routing and new end-to-end CLI tests. - Refactored
but-worktreesAPIs (new/list/destroy/integrate) to operate onRepository + Workspace (+ metadata)and switched integration to the graph rebase editor flow, addingNothingToIntegrate. - Ensured cleanup of auto-created
refs/heads/gitbutler/worktree/<id>branches on destroy/integrate; improved serde support for worktree IDs/fields.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/but/tests/but/command/worktree.rs | Adds CLI-level journey + destroy + “nothing to integrate” tests for legacy but worktree. |
| crates/but/tests/but/command/mod.rs | Includes the new legacy worktree test module behind the legacy feature. |
| crates/but/src/lib.rs | Wires legacy Worktree subcommand to return CliError like other subcommands. |
| crates/but/src/command/legacy/worktree.rs | Adds human output for NothingToIntegrate during integrate --dry. |
| crates/but-api/src/legacy/worktree.rs | Adapts legacy API endpoints to the refactored but-worktrees plumbing signatures. |
| crates/but-worktrees/src/new.rs | Refactors worktree creation to take repo/ws/data_dir and uses the shared branch namespace constant. |
| crates/but-worktrees/src/list.rs | Refactors list to accept &gix::Repository. |
| crates/but-worktrees/src/destroy.rs | Refactors destroy to accept &gix::Repository and deletes auto-created worktree branches. |
| crates/but-worktrees/src/integrate.rs | Moves integration to graph editor/rebase; adds NothingToIntegrate status and working-dir conflict prediction. |
| crates/but-worktrees/src/git.rs | Improves git worktree command logging, fixes remove error message, and adds delete_worktree_branch(). |
| crates/but-worktrees/src/lib.rs | Adds WORKTREE_BRANCH_NAMESPACE and updates serde handling for worktree ID/ref/base fields. |
| crates/but-worktrees/tests/worktree/*.rs | Updates tests to use new util plumbing and adds coverage for “fresh worktree doesn’t obscure branch”. |
| crates/but-worktrees/Cargo.toml | Updates dependencies (adds but-graph, but-serde, moves but-ctx to dev-deps). |
| crates/but-serde/src/lib.rs | Adds deserialize() for bstring_lossy to support #[serde(with = ...)] on WorktreeId. |
| Cargo.lock | Locks dependency graph updates from the above crate changes. |
| if !ws.refname_is_segment(refname) { | ||
| bail!("Branch not found in workspace"); | ||
| } |
| Integratable { | ||
| /// The cherry pick produced when integrating will be conflicted. | ||
| cherry_pick_conflicts: bool, | ||
| /// Commits above where this worktree will be cherry-picked are going to | ||
| /// end up conflicted. |
Branches auto-created for GitButler-managed worktrees (refs/heads/gitbutler/worktree/*) point at the same commit as their source branch until work happens in the worktree. They participated in segment-name disambiguation, where two metadata-less branches on one commit yield no name at all: the source branch lost its segment boundary and vanished from the workspace, breaking status, worktree new, and integrate for that branch. Exclude the namespace from naming, consistent with the projection already treating gitbutler/* refs as implementation details. This hunk was part of the original branch but got lost in the squash, which is why fresh_worktree_does_not_obscure_its_branch was failing in CI.
d187730 to
8f549b2
Compare
Pull request was closed
|
replaced by #14213 |
@estib-vega @Caleb-T-Owens - this may not be the final form of this, but with this change the worktree stuff seems to be alive once again.