Add bd hooks install command with embedded git hooks (bd-908z)
- Embed git hooks in binary using go:embed and templates directory - Add bd hooks install/uninstall/list subcommands - Install hooks with automatic backup of existing hooks - Update AGENTS.md to reference 'bd hooks install' instead of install.sh - Add comprehensive tests for hooks commands - Update hook version to 0.22.1 Closes bd-908z
This commit is contained in:
42
cmd/bd/templates/hooks/post-merge
Executable file
42
cmd/bd/templates/hooks/post-merge
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
# bd-hooks-version: 0.22.1
|
||||
#
|
||||
# bd (beads) post-merge hook
|
||||
#
|
||||
# This hook syncs the bd database after a git pull or merge:
|
||||
# 1. Checks if any .beads/*.jsonl file was updated
|
||||
# 2. Runs 'bd sync --import-only' to import changes
|
||||
#
|
||||
# Installation:
|
||||
# cp examples/git-hooks/post-merge .git/hooks/post-merge
|
||||
# chmod +x .git/hooks/post-merge
|
||||
#
|
||||
# Or use the install script:
|
||||
# examples/git-hooks/install.sh
|
||||
|
||||
# Check if bd is available
|
||||
if ! command -v bd >/dev/null 2>&1; then
|
||||
echo "Warning: bd command not found, skipping post-merge sync" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check if we're in a bd workspace
|
||||
if [ ! -d .beads ]; then
|
||||
# Not a bd workspace, nothing to do
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check if any JSONL file exists in .beads/
|
||||
if ! ls .beads/*.jsonl >/dev/null 2>&1; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Run bd sync --import-only to import the updated JSONL
|
||||
# This is more robust than direct import as it handles all edge cases
|
||||
if ! bd sync --import-only >/dev/null 2>&1; then
|
||||
echo "Warning: Failed to sync bd changes after merge" >&2
|
||||
echo "Run 'bd sync --import-only' manually" >&2
|
||||
# Don't fail the merge, just warn
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user