Skip to content

feat(cli): move approvals subcommand from hook to config - #2282

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

Copy link
Copy Markdown
Owner

Approvals cover both project hooks and project aliases (via approve_alias_commands), so wt hook approvals mis-scoped the command. Canonicalize the home to wt config approvals; keep wt hook approvals as a hidden alias that emits a deprecation warning and forwards.

add now walks both hook and alias commands. A project that only declares aliases can bulk-pre-approve them in one shot — see test_add_approvals_includes_aliases. The shared approvals.toml and the per-run interactive flow are unchanged; only the CLI namespace and the add collector moved.

Reviewer notes:

  • src/cli/config.rs — new Approvals variant on ConfigCommand with help text and the <!-- subdoc: approvals --> placeholder added in src/cli/mod.rs so the config docs page renders the subcommand inline.
  • src/cli/hook.rs — old Approvals variant marked hide = true; src/main.rs emits the warning before forwarding to the same handlers.
  • src/commands/project_config.rs — new collect_commands_for_aliases mirrors the per-step name fallback in approve_alias_commands so the prompt label is stable.
  • src/git/error.rs:751 — non-interactive hint now points at wt config approvals add.
  • Tests retargeted to the canonical path; the wt hook completion test loses one entry (12 → 11) since the deprecated subcommand is hidden.

This was written by Claude Code on behalf of Maximilian Roos

max-sixty and others added 2 commits April 17, 2026 23:46
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]>
@max-sixty
max-sixty merged commit 64e1b4e into main Apr 18, 2026
25 checks passed
@max-sixty
max-sixty deleted the approvals-location branch April 18, 2026 07:46
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]>
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