Improve pre-push hook: suggest bd sync with auto-sync option
The pre-push hook now provides better guidance when beads JSONL has uncommitted changes: - Interactive terminals: Prompts to auto-run 'bd sync' (y/N) - Non-interactive/CI: Shows 'bd sync' command to run - Fallback: Manual git commands if bd not available This addresses the UX issue where users weren't sure they should run 'bd sync' instead of manual git commands. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -48,14 +48,57 @@ if [ -n "$FILES" ]; then
|
|||||||
echo "❌ Error: Beads JSONL has uncommitted changes" >&2
|
echo "❌ Error: Beads JSONL has uncommitted changes" >&2
|
||||||
echo "" >&2
|
echo "" >&2
|
||||||
echo "You made changes to bd issues between your last commit and this push." >&2
|
echo "You made changes to bd issues between your last commit and this push." >&2
|
||||||
echo "Please commit the updated JSONL before pushing:" >&2
|
|
||||||
echo "" >&2
|
echo "" >&2
|
||||||
# shellcheck disable=SC2086
|
|
||||||
echo " git add $FILES" >&2
|
# Check if bd is available and offer auto-sync
|
||||||
echo ' git commit -m "Update bd JSONL"' >&2
|
if command -v bd >/dev/null 2>&1; then
|
||||||
echo " git push" >&2
|
# Check if we're in an interactive terminal
|
||||||
echo "" >&2
|
if [ -t 0 ]; then
|
||||||
exit 1
|
echo "Would you like to run 'bd sync' now to commit and push these changes? [y/N]" >&2
|
||||||
|
read -r response
|
||||||
|
case "$response" in
|
||||||
|
[yY][eE][sS]|[yY])
|
||||||
|
echo "" >&2
|
||||||
|
echo "Running: bd sync" >&2
|
||||||
|
if bd sync; then
|
||||||
|
echo "" >&2
|
||||||
|
echo "✓ Sync complete. Continuing with push..." >&2
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "" >&2
|
||||||
|
echo "❌ Sync failed. Push aborted." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "" >&2
|
||||||
|
echo "Push aborted. Run 'bd sync' manually when ready:" >&2
|
||||||
|
echo "" >&2
|
||||||
|
echo " bd sync" >&2
|
||||||
|
echo " git push" >&2
|
||||||
|
echo "" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
# Non-interactive: just show the message
|
||||||
|
echo "Run 'bd sync' to commit these changes:" >&2
|
||||||
|
echo "" >&2
|
||||||
|
echo " bd sync" >&2
|
||||||
|
echo "" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# bd not available, fall back to manual git commands
|
||||||
|
echo "Please commit the updated JSONL before pushing:" >&2
|
||||||
|
echo "" >&2
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
echo " git add $FILES" >&2
|
||||||
|
echo ' git commit -m "Update bd JSONL"' >&2
|
||||||
|
echo " git push" >&2
|
||||||
|
echo "" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Improved
|
||||||
|
|
||||||
|
- **Git Pre-Push Hook**: Better error messaging and auto-sync option
|
||||||
|
- Error message now suggests `bd sync` instead of manual git commands
|
||||||
|
- Interactive prompt offers to run `bd sync` automatically
|
||||||
|
- Falls back to manual instructions in non-interactive terminals or when bd is unavailable
|
||||||
|
- Improves user experience when beads JSONL has uncommitted changes
|
||||||
|
|
||||||
## [0.24.2] - 2025-11-22
|
## [0.24.2] - 2025-11-22
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -48,14 +48,57 @@ if [ -n "$FILES" ]; then
|
|||||||
echo "❌ Error: Beads JSONL has uncommitted changes" >&2
|
echo "❌ Error: Beads JSONL has uncommitted changes" >&2
|
||||||
echo "" >&2
|
echo "" >&2
|
||||||
echo "You made changes to bd issues between your last commit and this push." >&2
|
echo "You made changes to bd issues between your last commit and this push." >&2
|
||||||
echo "Please commit the updated JSONL before pushing:" >&2
|
|
||||||
echo "" >&2
|
echo "" >&2
|
||||||
# shellcheck disable=SC2086
|
|
||||||
echo " git add $FILES" >&2
|
# Check if bd is available and offer auto-sync
|
||||||
echo ' git commit -m "Update bd JSONL"' >&2
|
if command -v bd >/dev/null 2>&1; then
|
||||||
echo " git push" >&2
|
# Check if we're in an interactive terminal
|
||||||
echo "" >&2
|
if [ -t 0 ]; then
|
||||||
exit 1
|
echo "Would you like to run 'bd sync' now to commit and push these changes? [y/N]" >&2
|
||||||
|
read -r response
|
||||||
|
case "$response" in
|
||||||
|
[yY][eE][sS]|[yY])
|
||||||
|
echo "" >&2
|
||||||
|
echo "Running: bd sync" >&2
|
||||||
|
if bd sync; then
|
||||||
|
echo "" >&2
|
||||||
|
echo "✓ Sync complete. Continuing with push..." >&2
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "" >&2
|
||||||
|
echo "❌ Sync failed. Push aborted." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "" >&2
|
||||||
|
echo "Push aborted. Run 'bd sync' manually when ready:" >&2
|
||||||
|
echo "" >&2
|
||||||
|
echo " bd sync" >&2
|
||||||
|
echo " git push" >&2
|
||||||
|
echo "" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
# Non-interactive: just show the message
|
||||||
|
echo "Run 'bd sync' to commit these changes:" >&2
|
||||||
|
echo "" >&2
|
||||||
|
echo " bd sync" >&2
|
||||||
|
echo "" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# bd not available, fall back to manual git commands
|
||||||
|
echo "Please commit the updated JSONL before pushing:" >&2
|
||||||
|
echo "" >&2
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
echo " git add $FILES" >&2
|
||||||
|
echo ' git commit -m "Update bd JSONL"' >&2
|
||||||
|
echo " git push" >&2
|
||||||
|
echo "" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -48,14 +48,57 @@ if [ -n "$FILES" ]; then
|
|||||||
echo "❌ Error: Beads JSONL has uncommitted changes" >&2
|
echo "❌ Error: Beads JSONL has uncommitted changes" >&2
|
||||||
echo "" >&2
|
echo "" >&2
|
||||||
echo "You made changes to bd issues between your last commit and this push." >&2
|
echo "You made changes to bd issues between your last commit and this push." >&2
|
||||||
echo "Please commit the updated JSONL before pushing:" >&2
|
|
||||||
echo "" >&2
|
echo "" >&2
|
||||||
# shellcheck disable=SC2086
|
|
||||||
echo " git add $FILES" >&2
|
# Check if bd is available and offer auto-sync
|
||||||
echo ' git commit -m "Update bd JSONL"' >&2
|
if command -v bd >/dev/null 2>&1; then
|
||||||
echo " git push" >&2
|
# Check if we're in an interactive terminal
|
||||||
echo "" >&2
|
if [ -t 0 ]; then
|
||||||
exit 1
|
echo "Would you like to run 'bd sync' now to commit and push these changes? [y/N]" >&2
|
||||||
|
read -r response
|
||||||
|
case "$response" in
|
||||||
|
[yY][eE][sS]|[yY])
|
||||||
|
echo "" >&2
|
||||||
|
echo "Running: bd sync" >&2
|
||||||
|
if bd sync; then
|
||||||
|
echo "" >&2
|
||||||
|
echo "✓ Sync complete. Continuing with push..." >&2
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "" >&2
|
||||||
|
echo "❌ Sync failed. Push aborted." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "" >&2
|
||||||
|
echo "Push aborted. Run 'bd sync' manually when ready:" >&2
|
||||||
|
echo "" >&2
|
||||||
|
echo " bd sync" >&2
|
||||||
|
echo " git push" >&2
|
||||||
|
echo "" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
# Non-interactive: just show the message
|
||||||
|
echo "Run 'bd sync' to commit these changes:" >&2
|
||||||
|
echo "" >&2
|
||||||
|
echo " bd sync" >&2
|
||||||
|
echo "" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# bd not available, fall back to manual git commands
|
||||||
|
echo "Please commit the updated JSONL before pushing:" >&2
|
||||||
|
echo "" >&2
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
echo " git add $FILES" >&2
|
||||||
|
echo ' git commit -m "Update bd JSONL"' >&2
|
||||||
|
echo " git push" >&2
|
||||||
|
echo "" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user