This commit is contained in:
Steve Yegge
2025-11-27 00:54:20 -08:00
3 changed files with 17752 additions and 7735 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,11 @@
#!/bin/sh
# bd-hooks-version: 0.25.1
# bd-hooks-version: 0.26.0
#
# bd (beads) post-checkout hook
#
# This hook syncs the bd database after a branch checkout:
# 1. Checks if any .beads/*.jsonl file was updated
# 2. Runs 'bd sync --import-only' to import changes
# 2. Runs 'bd sync --import-only --no-git-history' to import changes
#
# Arguments provided by git:
# $1 = ref of previous HEAD
@@ -19,6 +19,12 @@ if [ "$3" != "1" ]; then
exit 0
fi
# Skip during rebase - git checks out commits during rebase and we must not
# modify working tree files (like deletions.jsonl) or the rebase will fail
if [ -d .git/rebase-merge ] || [ -d .git/rebase-apply ]; then
exit 0
fi
# Check if bd is available
if ! command -v bd >/dev/null 2>&1; then
exit 0
@@ -34,8 +40,9 @@ if ! ls .beads/*.jsonl >/dev/null 2>&1; then
exit 0
fi
# Run bd sync --import-only to import the updated JSONL
if ! output=$(bd sync --import-only 2>&1); then
# Run bd sync --import-only --no-git-history to import the updated JSONL
# --no-git-history prevents writes to deletions.jsonl (critical during rebase)
if ! output=$(bd sync --import-only --no-git-history 2>&1); then
echo "Warning: Failed to sync bd changes after checkout" >&2
echo "$output" >&2
echo "" >&2

View File

@@ -1,11 +1,11 @@
#!/bin/sh
# bd-hooks-version: 0.25.1
# bd-hooks-version: 0.26.0
#
# 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
# 2. Runs 'bd sync --import-only --no-git-history' to import changes
#
# Installation:
# cp examples/git-hooks/post-merge .git/hooks/post-merge
@@ -14,6 +14,12 @@
# Or use the install script:
# examples/git-hooks/install.sh
# Skip during rebase - git may run post-merge during rebase operations
# and we must not modify working tree files or the rebase will fail
if [ -d .git/rebase-merge ] || [ -d .git/rebase-apply ]; then
exit 0
fi
# 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
@@ -31,10 +37,11 @@ if ! ls .beads/*.jsonl >/dev/null 2>&1; then
exit 0
fi
# Run bd sync --import-only to import the updated JSONL
# Run bd sync --import-only --no-git-history to import the updated JSONL
# --no-git-history prevents writes to deletions.jsonl during hook operations
# This is more robust than direct import as it handles all edge cases
# Capture both stdout and stderr to show user what went wrong
if ! output=$(bd sync --import-only 2>&1); then
if ! output=$(bd sync --import-only --no-git-history 2>&1); then
echo "Warning: Failed to sync bd changes after merge" >&2
echo "$output" >&2
echo "" >&2