Improve bd-my64 fix based on oracle review
Oracle identified a critical race condition in the initial fix: - Pre-push hook checked for changes but didn't flush first - Pending 5s-debounced flushes could land after the check - Result: stale JSONL could still be pushed Improvements: 1. Pre-push now flushes pending changes FIRST (bd sync --flush-only) 2. Uses git status --porcelain to catch ALL change types: - Staged, unstaged, untracked, deleted, renamed, conflicts 3. Handles both beads.jsonl and issues.jsonl (backward compat) 4. Works even without bd installed (git-only check) 5. Pre-commit stages both JSONL files (simpler loop) This completely eliminates the race condition.
This commit is contained in:
@@ -35,17 +35,10 @@ if ! bd sync --flush-only >/dev/null 2>&1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find the JSONL file (could be issues.jsonl or beads.jsonl)
|
||||
JSONL_FILE=""
|
||||
if [ -f .beads/beads.jsonl ]; then
|
||||
JSONL_FILE=".beads/beads.jsonl"
|
||||
elif [ -f .beads/issues.jsonl ]; then
|
||||
JSONL_FILE=".beads/issues.jsonl"
|
||||
fi
|
||||
|
||||
# If the JSONL file was modified, stage it
|
||||
if [ -n "$JSONL_FILE" ] && [ -f "$JSONL_FILE" ]; then
|
||||
git add "$JSONL_FILE" 2>/dev/null || true
|
||||
fi
|
||||
# Stage both possible JSONL files (backward compatibility)
|
||||
# git add is harmless if file doesn't exist
|
||||
for f in .beads/beads.jsonl .beads/issues.jsonl; do
|
||||
[ -f "$f" ] && git add "$f" 2>/dev/null || true
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user