Repository navigation
refactor(approvals): move approval handlers to config module - #2286
Merged
Merged
Conversation
`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
approved these changes
Apr 18, 2026
Collaborator
|
|
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]>
worktrunk-bot
approved these changes
Apr 18, 2026
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After #2282 moved the
approvalssubcommand fromwt hooktowt config, the handler functions still lived insrc/commands/hook_commands.rs. Move them to a newsrc/commands/config/approvals.rsso file location matches the user-facing path.Tidy two related tests in
tests/integration_tests/hook_show.rsthat were left behind:test_hook_clear_with_approvals— moved toapprovals.rsand renamedtest_clear_approvals_legacy_config_storageto reflect what it actually verifies (the[projects.X]fallback inconfig.toml).test_hook_clear_no_approvals— dropped as a duplicate; identical command, identical output as the existingtest_clear_approvals_no_approvals.The move surfaced a few previously uncovered lines in
add_approvalsthat codecov flagged as new patch content. The second commit fixes that gap:test_add_approvals_all_already_approvedpreviously 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.wt config approvals addcover the success and decline branches afterapprove_command_batch.src/commands/config/approvals.rsis now at 100% line coverage. No behavior change.