Update post-merge hook to use bd sync --import-only and auto-detect *.jsonl files (bd-126)

This commit is contained in:
Steve Yegge
2025-10-27 18:27:01 -07:00
parent 9411c879db
commit 897edc6ce7

View File

@@ -2,8 +2,9 @@
# #
# bd (beads) post-merge hook # bd (beads) post-merge hook
# #
# This hook imports updated issues from .beads/issues.jsonl after a # This hook syncs the bd database after a git pull or merge:
# git pull or merge, ensuring the database stays in sync with git. # 1. Checks if any .beads/*.jsonl file was updated
# 2. Runs 'bd sync --import-only' to import changes
# #
# Installation: # Installation:
# cp examples/git-hooks/post-merge .git/hooks/post-merge # cp examples/git-hooks/post-merge .git/hooks/post-merge
@@ -14,7 +15,7 @@
# Check if bd is available # Check if bd is available
if ! command -v bd >/dev/null 2>&1; then if ! command -v bd >/dev/null 2>&1; then
echo "Warning: bd command not found, skipping post-merge import" >&2 echo "Warning: bd command not found, skipping post-merge sync" >&2
exit 0 exit 0
fi fi
@@ -24,17 +25,16 @@ if [ ! -d .beads ]; then
exit 0 exit 0
fi fi
# Check if issues.jsonl exists and was updated # Check if any JSONL file exists in .beads/
if [ ! -f .beads/issues.jsonl ]; then if ! ls .beads/*.jsonl >/dev/null 2>&1; then
exit 0 exit 0
fi fi
# Import the updated JSONL # Run bd sync --import-only to import the updated JSONL
# The auto-import feature should handle this, but we force it here # This is more robust than direct import as it handles all edge cases
# to ensure immediate sync after merge if ! bd sync --import-only >/dev/null 2>&1; then
if ! bd import -i .beads/issues.jsonl --resolve-collisions >/dev/null 2>&1; then echo "Warning: Failed to sync bd changes after merge" >&2
echo "Warning: Failed to import bd changes after merge" >&2 echo "Run 'bd sync --import-only' manually" >&2
echo "Run 'bd import -i .beads/issues.jsonl --resolve-collisions' manually" >&2
# Don't fail the merge, just warn # Don't fail the merge, just warn
fi fi