Fix GH#254: bd init now detects and chains with existing git hooks

- Detect existing git hooks (pre-commit framework, custom scripts)
- Prompt user with 3 options: chain (recommended), overwrite, skip
- Chain mode preserves existing hooks by calling them first
- Overwrite mode creates timestamped backups
- Add tests for hook detection and installation
- Update documentation with chaining feature

Fixes silent overwrites of pre-commit framework hooks that caused
test failures to slip through.

Amp-Thread-ID: https://ampcode.com/threads/T-37164fd7-6452-40b0-b5dd-c13672dcb843
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-11-07 15:55:19 -08:00
parent f5726fc437
commit 046e852861
3 changed files with 446 additions and 23 deletions

View File

@@ -28,7 +28,7 @@ These git hooks ensure bd changes are always synchronized with your commits and
## Installation
### Quick Install
### Quick Install (Recommended)
From your repository root:
@@ -36,10 +36,20 @@ From your repository root:
./examples/git-hooks/install.sh
```
This will:
Or use `bd init --quiet` to install hooks automatically.
**Hook Chaining (New in v0.23):** If you already have git hooks installed (e.g., pre-commit framework), bd will:
- Detect existing hooks
- Offer to chain with them (recommended)
- Preserve your existing hooks while adding bd functionality
- Back up hooks if you choose to overwrite
This prevents bd from silently overwriting workflows like pre-commit framework, which previously caused test failures to slip through.
The installer will:
- Copy hooks to `.git/hooks/`
- Make them executable
- Back up any existing hooks
- Detect and preserve existing hooks
### Manual Install