feat(hooks): make template hooks sync.branch aware (bd-8ib)

Update the embedded template hooks (used by bd init) to also check
for sync.branch configuration. This complements the earlier update
to examples/git-hooks/.

Changes:
- templates/hooks/pre-push: Skip uncommitted check when sync.branch set
- templates/hooks/pre-commit: Skip flush/staging when sync.branch set
- Bump version to 0.27.1 for all hooks
- Add sync.branch hooks change to --whats-new

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-11-30 10:52:07 -08:00
parent 5c013ab072
commit d02905a4fa
6 changed files with 36 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
#!/bin/sh
# bd-hooks-version: 0.27.0
# bd-hooks-version: 0.27.1
#
# bd (beads) pre-commit hook
#
@@ -7,6 +7,9 @@
# .beads/beads.jsonl before the commit is created, preventing the
# race condition where daemon auto-flush fires after the commit.
#
# When sync.branch is configured, .beads changes are committed to a separate
# branch via worktree, so auto-staging is skipped for the main branch.
#
# Installation:
# cp examples/git-hooks/pre-commit .git/hooks/pre-commit
# chmod +x .git/hooks/pre-commit
@@ -26,6 +29,16 @@ if [ ! -d .beads ]; then
exit 0
fi
# Check if sync.branch is configured - if so, .beads changes go to a separate
# branch via worktree, not the current branch
# Use --json to get clean output (human-readable format prints "(not set)")
SYNC_BRANCH=$(bd config get sync.branch --json 2>/dev/null | grep -o '"value": *"[^"]*"' | sed 's/"value": *"\([^"]*\)"/\1/')
if [ -n "$SYNC_BRANCH" ]; then
# sync.branch is configured, skip flush and auto-staging
# Changes are synced to the separate branch via 'bd sync'
exit 0
fi
# Flush pending changes to JSONL
# Use --flush-only to skip git operations (we're already in a git hook)
# Suppress output unless there's an error