Skip to content

feat(config): add [remove] delete-branch config option - #2589

Merged
max-sixty merged 2 commits into
mainfrom
feat/remove-config-section
May 4, 2026
Merged

max-sixty merged 2 commits into
mainfrom
feat/remove-config-section

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Summary

Adds a [remove] config section that lets users default wt remove to keeping branches, requested in #2587. Setting delete-branch = false is equivalent to passing --no-delete-branch every time; CLI flags still override the config.

[remove]
delete-branch = false   # never delete branches when removing worktrees

Implementation mirrors the existing [merge] pattern: new RemoveConfig section, a [projects."<id>".remove] override path, and a tri-state CLI flag pair (--delete-branch / --no-delete-branch) so users can override config either direction.

Test plan

  • Unit tests for RemoveConfig parse/default/merge + project override (src/config/user/tests.rs)
  • Integration test: [remove] delete-branch = false keeps the branch on wt remove
  • Integration test: explicit --delete-branch overrides the config
  • All existing wt remove tests still pass (83 tests)
  • cargo test --lib --bins and cargo clippy --tests --all-features clean
  • Help/docs snapshots regenerated (test_docs_are_in_sync)

Closes #2587.

Adds a new [remove] config section with a delete-branch boolean, mirroring
the existing [merge] pattern. Setting delete-branch = false is equivalent
to passing --no-delete-branch on every wt remove invocation. CLI flags
(--delete-branch / --no-delete-branch) override the config, and project
overrides are supported via [projects."<id>".remove].

Closes #2587.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-authored review — flagging one concrete issue and one phrasing note. Not approving (GitHub blocks self-approval).

The two new integration tests bypass the repo.wt_command() helper and only set WORKTRUNK_CONFIG_PATH / WORKTRUNK_APPROVALS_PATH manually. repo.wt_command() additionally sets HOME, WORKTRUNK_SYSTEM_CONFIG_PATH, mock command paths, and the git config isolation env — tests/CLAUDE.md calls this out as required to prevent host-environment leakage. Inline suggestions below switch them over.

The conflict error in src/main.rs:884 still hard-codes the CLI flag name (Cannot use --force-delete with --no-delete-branch). Now that delete_branch=false can come from [remove] delete-branch = false in config, a user who only types wt remove --force-delete and has never seen --no-delete-branch will get a confusing message. Worth softening, e.g. Cannot use --force-delete with delete-branch=false or expanding to mention either source.

Comment thread tests/integration_tests/remove.rs Resolved
Comment thread tests/integration_tests/remove.rs Resolved
- Switch new integration tests to repo.wt_command() so they pick up
  HOME, WORKTRUNK_SYSTEM_CONFIG_PATH, mock command paths, and git
  config isolation (per tests/CLAUDE.md).
- Soften the conflict error to mention either source of
  delete-branch=false, since it can now come from config rather than
  only --no-delete-branch.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Softened the conflict error in 060d3b9:

Cannot use --force-delete with delete-branch=false (set via --no-delete-branch or [remove] delete-branch = false)

Snapshot regenerated.

@max-sixty
max-sixty merged commit 1d97bb7 into main May 4, 2026
27 of 29 checks passed
@max-sixty
max-sixty deleted the feat/remove-config-section branch May 4, 2026 18:26
@max-sixty max-sixty mentioned this pull request May 5, 2026
2 of 3 tasks
max-sixty added a commit that referenced this pull request May 5, 2026
## Summary
Release v0.48.0. See
[CHANGELOG.md](https://github.com/max-sixty/worktrunk/blob/release/CHANGELOG.md)
for the full notes.

Highlights:
- `--format=json` extends to seven step + hook commands (#2560)
- `wt step commit` / `wt step squash` gain `--dry-run` (#2557)
- New `dirname` / `basename` template filters (#2592, #2605)
- New `[remove] delete-branch` config option (#2589)
- `wt-perf timeline` subcommand (#2558)
- Faster `wt list` on dirty worktrees (#2602) and faster alias dispatch
(#2556, #2573)
- Short-SHA display honors `core.abbrev` (#2576)
- Cleaner `wt config show` shell-integration section for new users

## Test plan
- [x] `cargo run -- hook pre-merge --yes` (3497 tests, lints clean)
- [x] `cargo semver-checks check-release -p worktrunk` consulted; minor
bump confirmed
- [ ] CI green
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Config option for automatic wt remove --no-delete-branch

2 participants