[PR #560] Add core hooks support and worktree coverage #567

Closed
opened 2026-03-02 04:14:00 +03:00 by kerem · 0 comments
Owner

Original Pull Request: https://github.com/git-ai-project/git-ai/pull/560

State: closed
Merged: No


Summary

  • Core hooks support: Adds core_hooks.rs module enabling hook installation via core.hooksPath as an alternative to wrapper-binary mode, with full lifecycle handling (commit, rebase, reset, stash, push, fetch, cherry-pick, merge, checkout, switch)
  • Worktree support: Comprehensive test coverage for git worktree operations across all hook modes (wrapper, hooks, both), including worktree-aware test infrastructure (WorktreeRepo, with_worktree_mode, snapshot variants)
  • Dual skip mechanism: Internal git commands now set both GITAI_SKIP_MANAGED_HOOKS and GIT_AI_SKIP_CORE_HOOKS env vars to prevent hook re-entry in either mode
  • Non-managed hook passthrough: Core hooks mode now syncs lightweight passthrough scripts for user hooks not managed by git-ai, preventing silent hook loss when core.hooksPath redirects

Built on top of the codex/global-hooks-dual-mode branch (repo-local hook management rewrite).

Changes

New files

  • src/commands/core_hooks.rs — Core hooks dispatch and lifecycle management (1,300+ LOC)
  • tests/corehooks_wrapper_regression.rs — Regression tests for dual-mode event recording
  • tests/worktrees.rs — 850+ LOC worktree integration test suite

Modified

  • src/commands/git_handlers.rs — Set both hook-skip env vars on child processes
  • src/git/repository.rs — Add GIT_AI_SKIP_CORE_HOOKS to exec_git* functions
  • src/commands/install_hooks.rs — Core hooks installation integration + non-managed hook sync
  • src/commands/hooks/stash_hooks.rs — Stash attribution fixes for core hooks mode
  • tests/repos/test_repo.rs — Worktree-aware test infrastructure, hooks-mode authorship fallback
  • tests/repos/mod.rsworktree_test_wrappers! macro for mode-parameterized tests
  • tests/rebase.rs — Windows cfg-gate for non-portable worktree rebase tests
  • Multiple test files — Added worktree variant coverage via macro wrappers

Test plan

  • cargo check passes
  • cargo clippy passes clean
  • cargo test --no-run compiles all test binaries
  • CI matrix: wrapper mode, hooks mode, both mode
  • Worktree tests pass in all three modes

Replaces #556 (closed due to fork deletion).

🤖 Generated with Claude Code


Open with Devin
**Original Pull Request:** https://github.com/git-ai-project/git-ai/pull/560 **State:** closed **Merged:** No --- ## Summary - **Core hooks support**: Adds `core_hooks.rs` module enabling hook installation via `core.hooksPath` as an alternative to wrapper-binary mode, with full lifecycle handling (commit, rebase, reset, stash, push, fetch, cherry-pick, merge, checkout, switch) - **Worktree support**: Comprehensive test coverage for git worktree operations across all hook modes (wrapper, hooks, both), including worktree-aware test infrastructure (`WorktreeRepo`, `with_worktree_mode`, snapshot variants) - **Dual skip mechanism**: Internal git commands now set both `GITAI_SKIP_MANAGED_HOOKS` and `GIT_AI_SKIP_CORE_HOOKS` env vars to prevent hook re-entry in either mode - **Non-managed hook passthrough**: Core hooks mode now syncs lightweight passthrough scripts for user hooks not managed by git-ai, preventing silent hook loss when `core.hooksPath` redirects Built on top of the `codex/global-hooks-dual-mode` branch (repo-local hook management rewrite). ## Changes ### New files - `src/commands/core_hooks.rs` — Core hooks dispatch and lifecycle management (1,300+ LOC) - `tests/corehooks_wrapper_regression.rs` — Regression tests for dual-mode event recording - `tests/worktrees.rs` — 850+ LOC worktree integration test suite ### Modified - `src/commands/git_handlers.rs` — Set both hook-skip env vars on child processes - `src/git/repository.rs` — Add `GIT_AI_SKIP_CORE_HOOKS` to `exec_git*` functions - `src/commands/install_hooks.rs` — Core hooks installation integration + non-managed hook sync - `src/commands/hooks/stash_hooks.rs` — Stash attribution fixes for core hooks mode - `tests/repos/test_repo.rs` — Worktree-aware test infrastructure, hooks-mode authorship fallback - `tests/repos/mod.rs` — `worktree_test_wrappers!` macro for mode-parameterized tests - `tests/rebase.rs` — Windows cfg-gate for non-portable worktree rebase tests - Multiple test files — Added worktree variant coverage via macro wrappers ## Test plan - [x] `cargo check` passes - [ ] `cargo clippy` passes clean - [ ] `cargo test --no-run` compiles all test binaries - [ ] CI matrix: wrapper mode, hooks mode, both mode - [ ] Worktree tests pass in all three modes Replaces #556 (closed due to fork deletion). 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/git-ai-project/git-ai/pull/560" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end -->
kerem 2026-03-02 04:14:00 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/git-ai#567
No description provided.