Skip to content

refactor(approvals): move approval handlers to config module - #2286

Merged
max-sixty merged 2 commits into
mainfrom
approvals-location
Apr 18, 2026
Merged

max-sixty merged 2 commits into
mainfrom
approvals-location

Conversation

@max-sixty

@max-sixty max-sixty commented Apr 18, 2026 •

Copy link
Copy Markdown
Owner

After #2282 moved the approvals subcommand from wt hook to wt config, the handler functions still lived in src/commands/hook_commands.rs. Move them to a new src/commands/config/approvals.rs so file location matches the user-facing path.

Tidy two related tests in tests/integration_tests/hook_show.rs that were left behind:

  • test_hook_clear_with_approvals — moved to approvals.rs and renamed test_clear_approvals_legacy_config_storage to reflect what it actually verifies (the [projects.X] fallback in config.toml).
  • test_hook_clear_no_approvals — dropped as a duplicate; identical command, identical output as the existing test_clear_approvals_no_approvals.

The move surfaced a few previously uncovered lines in add_approvals that codecov flagged as new patch content. The second commit fixes that gap:

  • test_add_approvals_all_already_approved previously fabricated a project_id that didn't match what wt computes at runtime, so it never actually hit the "all already approved" branch it was named after.
  • New PTY-based accept/decline tests for wt config approvals add cover the success and decline branches after approve_command_batch.

src/commands/config/approvals.rs is now at 100% line coverage. No behavior change.

This was written by Claude Code on behalf of Maximilian

`add_approvals` and `clear_approvals` no longer back any `wt hook`
subcommand — they're invoked through `wt config approvals`. Move them
into `src/commands/config/approvals.rs` so the file location matches
the user-facing path.

Tidy the related test names: `test_hook_clear_with_approvals` exercised
the legacy `[projects.X]` storage in `config.toml` — move it to
`approvals.rs` and rename to `test_clear_approvals_legacy_config_storage`.
Drop `test_hook_clear_no_approvals` as a duplicate (same command, same
output as `test_clear_approvals_no_approvals`).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@worktrunk-bot

Copy link
Copy Markdown
Collaborator

codecov/patch fails at 90.14% — a rename false positive. The 7 uncovered lines in src/commands/config/approvals.rs (L49-50, L62, L66-67, L69, L72, covering the "all commands already approved" short-circuit and the post-approve_command_batch success/decline branches) map 1:1 to 7 pre-existing uncovered lines in src/commands/hook_commands.rs on main (L426-427, L439, L443-444, L446, L449). Pure move, no new gap.

After moving the approval handlers, codecov flagged seven previously
uncovered lines in `src/commands/config/approvals.rs` as new patch
coverage. The lines were uncovered on main too — the move just resurfaced
the gap.

- `test_add_approvals_all_already_approved` previously fabricated a
  project_id (`{root}/origin`) that didn't match what wt computes at
  runtime, so it never actually hit the "all already approved" branch
  it was named after. Remove origin first and call `repo.project_id()`
  for the canonical id.
- Add PTY-based accept/decline tests for `wt config approvals add` so
  the success and decline branches after `approve_command_batch` are
  exercised. Modeled on the existing `tests/integration_tests/approval_pty.rs`
  patterns.

Result: `src/commands/config/approvals.rs` is now at 100% line coverage.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 80a4b0b into main Apr 18, 2026
25 checks passed
@max-sixty
max-sixty deleted the approvals-location branch April 18, 2026 18:56
max-sixty added a commit that referenced this pull request Apr 18, 2026
)

Three clear-approvals tests fabricated `format!(\"{}/origin\", root)` as
the project_id, which doesn't match what
`Repository::project_identifier` computes after `git remote remove
origin`. The manually-written approvals were stored under the wrong key,
so the tests silently exercised the "no approvals to clear" branch
instead of the count branch their names imply.

Replaced with `repo.project_id()`, the same fix already applied to
`test_add_approvals_all_already_approved` in #2286. Snapshots now show
"Cleared 1 approval" and "Cleared 3 approvals" — the `after_clear`
snapshot is unchanged but now actually exercises the
clear-then-clear-again path.

> _This was written by Claude Code on behalf of @max-sixty_

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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