-
Notifications
You must be signed in to change notification settings - Fork 461
Open
Labels
Description
Bug description
Problem
The aicommits hook install and aicommits hook uninstall commands break when run inside git worktrees because they assume .git is always a directory.
Root Cause
In git worktrees, .git is a file (not a directory) containing a reference to the main repository's git directory:
gitdir: /path/to/main/repo/.git/worktrees/
The current code (src/commands/hook.ts:11) always attempts to use .git/hooks/${hookName} as the hook path, which doesn't exist in worktrees.
Expected Behavior
Worktrees have their own hooks directory located at:
- .git/worktrees//hooks/ (relative to main repo)
- Or accessible via git rev-parse --git-common-dir and git rev-parse --git-path hooks
The install/uninstall should:
- Detect if running in a worktree
- Use the worktree-specific hooks directory instead of the main repo's hooks
- Allow installing hooks per-worktree without affecting other worktrees
Current Code Location
src/commands/hook.ts:11, 39 - hardcodes .git/hooks/ path without handling worktree scenarios
aicommits version
v2.0.0
Environment
System:
OS: macOS 26.2
CPU: (10) arm64 Apple M1 Pro
Memory: 174.03 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.12.0 - /Users/vivin/.nvm/versions/node/v24.12.0/bin/node
npm: 11.6.2 - /Users/vivin/.nvm/versions/node/v24.12.0/bin/npm
pnpm: 10.20.0 - /Users/vivin/.local/share/pnpm/pnpm
bun: 1.3.1 - /Users/vivin/.bun/bin/bunCan you contribute a fix?
- I’m interested in opening a pull request for this issue.
Reactions are currently unavailable