Skip to content

feat: rename worktree hooks with deprecation support#131

Merged
avihut merged 2 commits intomasterfrom
daft-84/hook-names
Feb 1, 2026
Merged

feat: rename worktree hooks with deprecation support#131
avihut merged 2 commits intomasterfrom
daft-84/hook-names

Conversation

@avihut
Copy link
Owner

@avihut avihut commented Feb 1, 2026

Summary

  • Rename 4 worktree-scoped hooks with a worktree- prefix (pre-createworktree-pre-create, etc.) for clarity
  • Old hook filenames remain functional with deprecation warnings until v2.0.0
  • Add git daft hooks migrate command to automatically rename deprecated hook files
  • git daft hooks status now detects and warns about deprecated hook names
  • Config keys fall back to deprecated keys for backwards compatibility

Fixes #84

Details

Current New Scope
post-clone post-clone (unchanged) repo
post-init post-init (unchanged) repo
pre-create worktree-pre-create worktree
post-create worktree-post-create worktree
pre-remove worktree-pre-remove worktree
post-remove worktree-post-remove worktree

Deprecation behavior:

  • Before v2.0.0: Old filenames are discovered, executed, and a deprecation warning is emitted
  • v2.0.0+: Controlled by flipping EXECUTE_DEPRECATED_HOOKS from true to false

Migration command:

git daft hooks migrate [--dry-run]

Scans all worktree .daft/hooks/ directories and ~/.config/daft/hooks/, renames deprecated files, handles conflicts when both old and new names exist.

Test plan

  • All 140 unit tests pass (cargo test)
  • cargo clippy -- -D warnings passes clean
  • cargo fmt -- --check passes clean
  • New unit tests for deprecated_filename(), from_filename(), deprecated_config_key()
  • New unit tests for deprecated hook discovery and both-names-exist conflict
  • New integration tests: deprecated hook warning, migrate basic, migrate dry-run, migrate conflict
  • CI integration tests pass on Linux and macOS
  • Manual testing: create hook with old name, verify warning, run migrate, verify clean status

🤖 Generated with Claude Code

avihut and others added 2 commits February 1, 2026 08:49
Rename 4 worktree-scoped hooks with a `worktree-` prefix to better
distinguish them from repo-scoped hooks. Old names remain functional
with deprecation warnings until v2.0.0.

Renames:
- pre-create -> worktree-pre-create
- post-create -> worktree-post-create
- pre-remove -> worktree-pre-remove
- post-remove -> worktree-post-remove

post-clone and post-init are unchanged (repo-scoped).

Key changes:
- Hook filenames and config keys updated to new canonical names
- Deprecated filenames discovered and executed with warnings
- EXECUTE_DEPRECATED_HOOKS constant controls v2.0.0 cutoff
- Config keys fall back to deprecated keys for backwards compat
- `git daft hooks migrate` command renames old files automatically
- `git daft hooks status` detects and warns about deprecated names
- HookDiscovery struct replaces Vec<PathBuf> from find_hooks()

Fixes #84

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The migrate command now requires running from within a worktree and
only migrates hooks in that worktree's .daft/hooks/ directory, rather
than scanning all worktrees and the user hooks directory.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@avihut avihut merged commit f758e07 into master Feb 1, 2026
5 checks passed
@avihut avihut deleted the daft-84/hook-names branch February 1, 2026 09:22
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.

Consider better hook names

1 participant