Repository navigation
feat(cli): move approvals subcommand from hook to config - #2282
Merged
Merged
Conversation
Approvals now cover both project hooks AND project aliases (the latter via `approve_alias_commands`), so `wt hook approvals` mis-scoped what the command actually does. The canonical home is now `wt config approvals`; `wt hook approvals` stays as a hidden alias that emits a deprecation warning and forwards. `add` walks both hook and alias commands, so a project that only declares aliases can now bulk-pre-approve them in one go (regression test `test_add_approvals_includes_aliases` covers this). The shared `approvals.toml` and per-run prompt flow are unchanged; only the CLI namespace and the `add` collector moved. Co-Authored-By: Claude <[email protected]>
Codecov flagged the deprecated `HookCommand::Approvals` arm in src/main.rs as uncovered. Add a parameterized test that runs both `wt hook approvals add` and `wt hook approvals clear` against a non-interactive shell, asserting the deprecation warning fires and the handler still runs. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
approved these changes
Apr 18, 2026
4 tasks done
max-sixty
added a commit
that referenced
this pull request
Apr 18, 2026
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_ --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Apr 18, 2026
Resolves conflicts with main's two major landings since the branch diverged: - Global `-y`/`--yes` flag (PR #2279): `AliasOptions` no longer carries a `yes` field — approval skip comes from the top-level global. The post-alias `--yes` form now errors as an unknown flag, and post-alias `-y` falls into the positional-args branch. - Approvals module split (PR #2282): `add_approvals` / `clear_approvals` moved from `hook_commands` into `src/commands/config/approvals.rs`. The alias changes in this branch are compatible with both landings: - `AliasOptions` drops both `dry_run` and `yes`, keeping only `name`, `vars`, and `positional_args`. - `run_alias` uses `global_yes` from main's signature as the sole source for skipping approval. - `--dry-run` remains a parser-level error pointing at `wt config alias dry-run <name>`. - Existing `wt config alias dry-run` integration tests dropped the unused `-y` flag — dry-run never needs approval because it doesn't execute. 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.
Approvals cover both project hooks and project aliases (via
approve_alias_commands), sowt hook approvalsmis-scoped the command. Canonicalize the home towt config approvals; keepwt hook approvalsas a hidden alias that emits a deprecation warning and forwards.addnow walks both hook and alias commands. A project that only declares aliases can bulk-pre-approve them in one shot — seetest_add_approvals_includes_aliases. The sharedapprovals.tomland the per-run interactive flow are unchanged; only the CLI namespace and theaddcollector moved.Reviewer notes:
src/cli/config.rs— newApprovalsvariant onConfigCommandwith help text and the<!-- subdoc: approvals -->placeholder added insrc/cli/mod.rsso the config docs page renders the subcommand inline.src/cli/hook.rs— oldApprovalsvariant markedhide = true;src/main.rsemits the warning before forwarding to the same handlers.src/commands/project_config.rs— newcollect_commands_for_aliasesmirrors the per-step name fallback inapprove_alias_commandsso the prompt label is stable.src/git/error.rs:751— non-interactive hint now points atwt config approvals add.wt hookcompletion test loses one entry (12 → 11) since the deprecated subcommand is hidden.