Skip to content

test(hooks): exercise the pre-create alias direction post-revert - #2877

Merged
max-sixty merged 1 commit into
mainfrom
2857
May 22, 2026
Merged

max-sixty merged 1 commit into
mainfrom
2857

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Follow-up to #2857. That PR reverted the docs half of the pre-start/post-start → pre-create/post-create hook rename while keeping the code that accepts both names. Its self-review landed 26 seconds after the merge, so none of its findings were addressed — several tests still described the pre-revert direction and exercised only canonical names, so they would pass even if the deprecated alias broke.

Changes

The three deprecated-alias tests now use pre-create/post-create in their fixtures (or invoke wt hook pre-create), so they exercise the migration and the CLI alias rather than canonical names: test_hook_show_accepts_deprecated_create_hooks, test_deprecated_create_hook_key_runs_silently, test_standalone_hook_create_alias_runs_silently.

test_parse_hook_type_aliases had the same defect — it parsed only the canonical names — and now parses both forms and asserts they map to the same HookType.

Added unit tests for migrate_create_hooks_doc (every value shape, per-project tables, skip-when-canonical-exists, invalid TOML) plus a migration-diff snapshot; the revert removed the migrate_start_hooks_doc tests with no equivalent.

Deleted Deprecations::pre_start/post_start — always-false dead fields once the revert removed their detection.

Deleted test_config_show_displays_start_hook_migration: post-revert there is no detection for pre-create, so wt config show shows no migration diff and the test verified nothing (its regenerated snapshot confirmed this).

Also corrected reversed-direction comments in deprecation.rs and hook_commands.rs.

🤖 Generated with Claude Code

PR #2857 reverted the docs half of the pre-start/post-start →
pre-create/post-create rename while keeping code that accepts both
names. Its post-merge self-review flagged tests that still describe the
pre-revert direction and exercise no alias.

- The deprecated-alias tests (hook show, switch --create, wt hook) now
  use pre-create/post-create in fixtures or invoke `wt hook pre-create`,
  so they exercise the migration and CLI alias instead of canonical
  names.
- test_parse_hook_type_aliases parsed only canonical names; it now
  parses both forms and asserts they map to the same HookType.
- Added unit tests for migrate_create_hooks_doc (every value shape,
  per-project, skip-when-canonical-exists, invalid TOML) plus a
  migration-diff snapshot.
- Fixed reversed-direction comments in deprecation.rs and
  hook_commands.rs.
- Deleted Deprecations::pre_start/post_start — always-false dead fields
  after the revert removed their detection.
- Deleted test_config_show_displays_start_hook_migration — post-revert
  `wt config show` shows no diff for pre-create, so it verified nothing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@max-sixty
max-sixty merged commit 9131aa6 into main May 22, 2026
36 checks passed
@max-sixty
max-sixty deleted the 2857 branch May 22, 2026 15:16
max-sixty added a commit that referenced this pull request May 23, 2026
Two small follow-ups noticed while fixing the test comments in #2877.

**`pre_create` docstring was wrong.** It read "Commands to execute
before worktree creation (blocking)", but `pre-start` actually runs
*after* the worktree is created (`switch.rs:1142` executes it against
"the new worktree (created just above)", and the renamed test below
asserts the worktree exists after a failing pre-start). The wrong
wording entered in #2840 as part of the mechanical `pre-start` →
`pre-create` rename — someone "corrected" the docstring to match the new
name. #2857 reverted the name but left the docstring. Restoring "after
worktree creation (blocking, fail-fast)" matches the actual behavior,
`docs/content/hook.md` ("Runs once when a new worktree is created,
blocking…"), and the parallel `post_create` docstring. Because
`HooksConfig` derives `JsonSchema`, this docstring is user-visible in
generated schema descriptions.

**`test_user_post_start_hook_failure` was misnamed.** The fixture is
`[pre-start]`, the comment and assertion describe a failing pre-start,
and only the function name said post-start. Renamed to
`test_user_pre_start_hook_failure` along with its snapshot name and file
(`git mv`, so the rename shows as a rename).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
max-sixty added a commit that referenced this pull request May 23, 2026
Follow-up to #2857. That PR reverted the docs half of the
`pre-start`/`post-start` → `pre-create`/`post-create` hook rename while
keeping the code that accepts both names. Its self-review landed 26
seconds after the merge, so none of its findings were addressed —
several tests still described the pre-revert direction and exercised
only canonical names, so they would pass even if the deprecated alias
broke.

## Changes

The three deprecated-alias tests now use `pre-create`/`post-create` in
their fixtures (or invoke `wt hook pre-create`), so they exercise the
migration and the CLI alias rather than canonical names:
`test_hook_show_accepts_deprecated_create_hooks`,
`test_deprecated_create_hook_key_runs_silently`,
`test_standalone_hook_create_alias_runs_silently`.

`test_parse_hook_type_aliases` had the same defect — it parsed only the
canonical names — and now parses both forms and asserts they map to the
same `HookType`.

Added unit tests for `migrate_create_hooks_doc` (every value shape,
per-project tables, skip-when-canonical-exists, invalid TOML) plus a
migration-diff snapshot; the revert removed the
`migrate_start_hooks_doc` tests with no equivalent.

Deleted `Deprecations::pre_start`/`post_start` — always-false dead
fields once the revert removed their detection.

Deleted `test_config_show_displays_start_hook_migration`: post-revert
there is no detection for `pre-create`, so `wt config show` shows no
migration diff and the test verified nothing (its regenerated snapshot
confirmed this).

Also corrected reversed-direction comments in `deprecation.rs` and
`hook_commands.rs`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
max-sixty added a commit that referenced this pull request May 23, 2026
Two small follow-ups noticed while fixing the test comments in #2877.

**`pre_create` docstring was wrong.** It read "Commands to execute
before worktree creation (blocking)", but `pre-start` actually runs
*after* the worktree is created (`switch.rs:1142` executes it against
"the new worktree (created just above)", and the renamed test below
asserts the worktree exists after a failing pre-start). The wrong
wording entered in #2840 as part of the mechanical `pre-start` →
`pre-create` rename — someone "corrected" the docstring to match the new
name. #2857 reverted the name but left the docstring. Restoring "after
worktree creation (blocking, fail-fast)" matches the actual behavior,
`docs/content/hook.md` ("Runs once when a new worktree is created,
blocking…"), and the parallel `post_create` docstring. Because
`HooksConfig` derives `JsonSchema`, this docstring is user-visible in
generated schema descriptions.

**`test_user_post_start_hook_failure` was misnamed.** The fixture is
`[pre-start]`, the comment and assertion describe a failing pre-start,
and only the function name said post-start. Renamed to
`test_user_pre_start_hook_failure` along with its snapshot name and file
(`git mv`, so the rename shows as a rename).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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