Replace full shell script hooks with thin shims that delegate to
'bd hooks run <hook-name>'. This eliminates hook version drift -
upgrading bd automatically updates hook behavior.
Changes:
- Add 'bd hooks run' subcommand with hook logic in Go
- Convert templates to minimal shims (~17 lines each)
- Shims use '# bd-shim v1' marker (format version, not bd version)
- Update version checking to recognize shim format
- Shims are never marked as "outdated"
Benefits:
- No more manual 'bd hooks install --force' after upgrades
- Hook logic always matches installed bd version
- Follows pattern used by husky, pre-commit, lefthook
Migration: Run 'bd hooks install --force' one final time.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds comprehensive Git worktree support for beads issue tracking:
Core changes:
- New internal/git/gitdir.go package for worktree detection
- GetGitDir() returns proper .git location (main repo, not worktree)
- Updated all hooks to use git.GetGitDir() instead of local helper
- BeadsDir() now prioritizes main repository's .beads directory
Features:
- Hooks auto-install in main repo when run from worktree
- Shared .beads directory across all worktrees
- Config option no-install-hooks to disable auto-install
- New bd worktree subcommand for diagnostics
Documentation:
- New docs/WORKTREES.md with setup instructions
- Updated CHANGELOG.md and AGENT_INSTRUCTIONS.md
Testing:
- Updated tests to use exported git.GetGitDir()
- Added worktree detection tests
Co-authored-by: Claude <noreply@anthropic.com>
Closes: #478
Tests were hardcoding '.git' paths directly, which fails in git worktrees
where .git is a file (not a directory) containing a pointer to the actual
git directory.
Changes:
- Replace hardcoded '.git' paths with getGitDir() calls in all hook tests
- Add os.MkdirAll() calls to ensure hooks directory exists before writing
Fixes test failures in:
- TestInstallHooks, TestInstallHooksBackup, TestInstallHooksForce,
TestUninstallHooks, TestInstallHooksShared (hooks_test.go)
- TestDetectExistingHooks, TestInstallGitHooks_NoExistingHooks,
TestInstallGitHooks_ExistingHookBackup (init_hooks_test.go)
Cherry-picked from PR #472
Co-Authored-By: matt wilkie <maphew@gmail.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replaces manual working directory save/restore patterns
with Go's built-in `t.Chdir()` helper across 23 test files.
The manual pattern involved calling `os.Getwd()` to save
the original directory, using `defer os.Chdir(origWd)` for
restoration, and manually handling errors during directory
changes. This boilerplate has been replaced with single
`t.Chdir(path)` calls that handle cleanup automatically.
The `t.Chdir()` method automatically restores the working
directory when the test completes, eliminating the need for
manual defer statements and error handling.
Total:
~75 instances replaced (assuming Claude's math is right)
Co-authored-by: Claude <noreply@anthropic.com>
Use `git rev-parse --git-dir` instead of hardcoded `.git` path to find
the actual git directory. In worktrees, `.git` is a file containing a
gitdir pointer, not a directory.
Changes:
- Add getGitDir() helper in hooks.go
- Update installHooks(), uninstallHooks(), CheckGitHooks() to use it
- Update hooksInstalled(), detectExistingHooks(), installGitHooks() in init.go
- Update checkHooksQuick() in doctor.go
- Update GitHooks() in doctor/fix/hooks.go
- Update tests to use real git repos via `git init`
Fixes bd-63l
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fix existing tests to work with new installHooks signature
- Add TestInstallHooksShared to verify shared hooks functionality
- Update git-hooks README with comprehensive --shared documentation
- Document benefits, use cases, and workflow for shared hooks