Skip to content

refactor: delete dead code paths left by completed cut-overs - #2931

Merged
max-sixty merged 1 commit into
mainfrom
simplifications
May 28, 2026
Merged

max-sixty merged 1 commit into
mainfrom
simplifications

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Three independent dead-code removals, each a parallel implementation left behind by a completed cut-over and kept alive only by tests (or nothing). About 610 net lines removed, no behavior change.

What's removed

git — the by-ref integration API. src/git/repository/integration.rs carried every integration probe twice: a SHA-keyed form (what production uses) and a ref-taking wrapper that resolved the ref then delegated to it. Dropped the ref-taking same_commit, trees_match, has_merge_conflicts, merge_integration_probe, is_ancestor, and has_added_changes, the fully-unused head_tree_matches_branch, and the resolve_ref / resolve_preferring_branch helpers that only served them. The single production caller (the push.rs fast-forward check) now resolves HEAD to a SHA and calls is_ancestor_by_sha. Tag-vs-branch disambiguation is preserved structurally: SHAs come from RefSnapshot, which resolves branches via git for-each-ref.

list — the ListItem serde + display-string layer. wt list JSON flows only through JsonItem; the model types were never serialized. Removed the dead Serialize impls and the pre-rendered DisplayFields strings nothing read (commits_display, branch_diff_display, upstream_display, status_display, working_diff_display), the never-written ci_status_display and its unreachable render branch, and the always_show_zeros flag that was false at every production site.

worktree — the dead OperationMode. CreateOrSwitch had no caller and resolve_worktree_arg was always invoked with Remove. Dropped the enum, its unreachable branch, and the now-constant context / config parameters.

Testing

Full pre-merge gate green locally (3869 tests, plus doc, doctest, clippy, fmt). JSON output is byte-for-byte identical: no wt list / --json / statusline snapshot changed, which is the strongest evidence the removed layer was dead. Several integration tests that exercised the deleted ref-API were converted to drive the SHA-keyed forms rather than dropped, so the underlying merge-tree / ancestry / probe logic stays covered.

This was written by Claude Code on behalf of max

Three independent removals, each a parallel implementation kept alive only by
tests (or nothing):

- git: drop the by-ref integration API (resolve_ref plus the ref-taking
  same_commit / trees_match / has_merge_conflicts / merge_integration_probe /
  is_ancestor / has_added_changes, and the unused head_tree_matches_branch).
  Production resolves to SHAs first and uses the SHA-keyed forms; push.rs now
  calls is_ancestor_by_sha.
- list: drop the ListItem serde Serialize surface and the pre-rendered
  display-string layer (DisplayFields, ci_status_display, working_diff_display,
  always_show_zeros). JSON output flows only through JsonItem, unchanged.
- worktree: drop the dead OperationMode enum, its unreachable CreateOrSwitch
  branch, and the now-constant context/config parameters of resolve_worktree_arg.

About 610 net lines removed. No behavior change: JSON output is byte-for-byte
identical and the full test suite passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@worktrunk-bot

Copy link
Copy Markdown
Collaborator

test (windows) failed on a single test with an unrelated transient flake — test_bare_repo_background_logs_location panicked at testing/mod.rs:671 when creating its cd temp file: PathError { path: "D:\\tmp\\.tmpYrz7Nw", err: Os { code: 5, kind: PermissionDenied, message: "Access is denied." } }. 3409 passed, 1 failed; the failure is in test-harness temp-file creation, not in any path this PR touches. Leaving the approval in place.

@max-sixty
max-sixty merged commit 5eb17d4 into main May 28, 2026
48 of 49 checks passed
@max-sixty
max-sixty deleted the simplifications branch May 28, 2026 20:09
@max-sixty max-sixty mentioned this pull request May 30, 2026
max-sixty added a commit that referenced this pull request May 30, 2026
v0.55.0.

`cargo semver-checks` reports breaking library API changes (9 inherent methods removed from `Repository` / `ShellConfig` by the dead-code cut-overs in #2931 — `is_ancestor`, `same_commit`, `has_added_changes`, `trees_match`, `head_tree_matches_branch`, `has_merge_conflicts`, `has_merge_conflicts_by_tree`, `merge_integration_probe`, `is_posix`). None are intentional public API, but they force a minor bump pre-1.0.

Headline user-visible changes:
- `wt switch` accepts forge PR/MR URLs anywhere `pr:N` / `mr:N` works (#2898, thanks @thiagowfx for the request).
- Claude Code plugin keeps unmerged branches during worktree cleanup — the `WorktreeRemove` hook drops `-D` (#2940, thanks @jbeda for reporting).
- `wt list` and `wt step prune` degrade gracefully on unborn worktrees (#2937, thanks @nedtwigg for reporting).
- `-vv` startup pointer now names `diagnostic.md` (#2919).
- Doc-site and `--help` prose cleanup (#2922, #2925); internal cut-over of duplicated/dead code paths (#2931, #2932, #2934).

Full CHANGELOG entry in this PR.

> _This was written by Claude Code on behalf of max_
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
worktrunk 0.55.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## Release Notes

### Improved

- **`wt switch` accepts forge PR/MR URLs**: `wt switch https://github.com/owner/repo/pull/123` now resolves the same way as `wt switch pr:123`, and the URL form works anywhere a `pr:N` / `mr:N` shortcut does (positional argument and `--base`). Detection is shape-based, not host-based — any `http(s)://` URL whose path contains `/pull/N`, `/pulls/N`, `/-/merge_requests/N`, or `/pullrequest/N` matches, covering GitHub (including Enterprise), GitLab, Gitea, and Azure DevOps, including self-hosted instances. ([#2898](max-sixty/worktrunk#2898), thanks @thiagowfx for the request)

- **`-vv` startup pointer names `diagnostic.md`**: The `-vv` pointer now lists the shared log directory once with all three files it will contain — `trace.log`, `subprocess.log`, and `diagnostic.md` — so the diagnostic bundle is discoverable at startup rather than only when the gist hint fires at exit. The pointer verb reads `Writing to …` instead of `Tracing to …`. ([#2919](max-sixty/worktrunk#2919))

### Fixed

- **Claude Code plugin keeps unmerged branches during worktree cleanup**: The plugin's `WorktreeRemove` hook passed `-D` (`--force-delete`) to `wt remove`, which removes a branch even when it carries commits that aren't merged or pushed. The hook now uses the default removal: a merged or integrated branch is removed cleanly, while one with unmerged commits is kept, with a `wt remove -D <branch>` hint for deleting it deliberately. ([#2940](max-sixty/worktrunk#2940), thanks @jbeda for reporting)

- **`wt list` and `wt step prune` degrade gracefully on unborn worktrees**: A linked worktree created with `git worktree add --orphan` sits on an unborn branch whose `HEAD` is the null OID. `wt list` used to show `working-tree-diff (fatal: ambiguous argument 'HEAD')` and a merge-tree error in its columns, and `wt step prune` aborted its entire scan with `fatal: Needed a single revision`, blocking pruning of every other worktree. Both now treat an unborn worktree as having no commits: `wt list` renders `·` for the commit-dependent columns, and `wt step prune` skips it (as it does locked worktrees) and continues. ([#2937](max-sixty/worktrunk#2937), thanks @nedtwigg for reporting)

### Documentation

- **Doc-site and `--help` prose cleanup**: A writing-prose pass across the FAQ, config, list, remove, Claude Code, hook, LLM-commits, and Tips & Patterns pages (some via `--help` text in `after_long_help`). ([#2922](max-sixty/worktrunk#2922), [#2925](max-sixty/worktrunk#2925))

### Internal

- **Collapsed duplicated code paths and removed dead code left by completed cut-overs**: A net reduction across the shell, git, and command layers. ([#2931](max-sixty/worktrunk#2931), [#2932](max-sixty/worktrunk#2932), [#2934](max-sixty/worktrunk#2934))

## Install worktrunk 0.55.0

### Install prebuilt binaries via shell script

```sh
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/max-sixty/worktrunk/releases/download/v0.55.0/worktrunk-installer.sh | sh && wt config shell install
```

### Install prebuilt binaries via powershell script

```sh
powershell -ExecutionPolicy Bypass -c "irm https://github.com/max-sixty/worktrunk/releases/download/v0.55.0/worktrunk-installer.ps1 | iex"; git-wt config shell install
```

### Install prebuilt binaries via Homebrew

```sh
brew install worktrunk && wt config shell install
```

## Download worktrunk 0.55.0

|  File  | Platform | Checksum |
|--------|----------|----------|
| [worktrunk-aarch64-apple-darwin.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.55.0/worktrunk-aarch64-apple-darwin.tar.xz) | Apple Silicon macOS | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.55.0/worktrunk-aarch64-apple-darwin.tar.xz.sha256) |
| [worktrunk-x86_64-apple-darwin.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.55.0/worktrunk-x86_64-apple-darwin.tar.xz) | Intel macOS | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.55.0/worktrunk-x86_64-apple-darwin.tar.xz.sha256) |
| [worktrunk-x86_64-pc-windows-msvc.zip](https://github.com/max-sixty/worktrunk/releases/download/v0.55.0/worktrunk-x86_64-pc-windows-msvc.zip) | x64 Windows | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.55.0/worktrunk-x86_64-pc-windows-msvc.zip.sha256) |
| [worktrunk-aarch64-unknown-linux-musl.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.55.0/worktrunk-aarch64-unknown-linux-musl.tar.xz) | ARM64 MUSL Linux | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.55.0/worktrunk-aarch64-unknown-linux-musl.tar.xz.sha256) |
| [worktrunk-x86_64-unknown-linux-musl.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.55.0/worktrunk-x86_64-unknown-linux-musl.tar.xz) | x64 MUSL Linux | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.55.0/worktrunk-x86_64-unknown-linux-musl.tar.xz.sha256) |



### Install via Cargo

```sh
cargo install worktrunk && wt config shell install
```

### Install via Winget (Windows)

```sh
winget install max-sixty.worktrunk && git-wt config shell install
```

### Install via AUR (Arch Linux)

```sh
paru worktrunk-bin && wt config shell install
```
</pre>
  <p>View the full release notes at <a href="https://github.com/max-sixty/worktrunk/releases/tag/v0.55.0">https://github.com/max-sixty/worktrunk/releases/tag/v0.55.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!9819
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.

2 participants