From 1aad54be554aa99e4a6d5b713bdfca887d4dc434 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Tue, 14 Oct 2025 17:23:43 -0700 Subject: [PATCH] feat: Add post-push hook to auto-install bd CLI after git push MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hook automatically rebuilds and installs bd CLI when Go files change. Usage in new clones: ./scripts/install-hooks.sh Files: - scripts/hooks/post-push: Hook that runs go install after successful push - scripts/install-hooks.sh: Installer to set up hooks in new clones 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- scripts/hooks/post-push | 17 +++++++++++++++++ scripts/install-hooks.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100755 scripts/hooks/post-push create mode 100755 scripts/install-hooks.sh diff --git a/scripts/hooks/post-push b/scripts/hooks/post-push new file mode 100755 index 00000000..5edcd633 --- /dev/null +++ b/scripts/hooks/post-push @@ -0,0 +1,17 @@ +#!/bin/bash +# Post-push hook: Rebuild and install bd CLI after successful push + +set -e + +# Check if any Go files changed in the push +# Use the reflog to find what was just pushed +if git log --name-only -1 origin/main..HEAD 2>/dev/null | grep -q '\.go$' || \ + git diff --name-only HEAD~1 HEAD 2>/dev/null | grep -q '\.go$'; then + echo "" + echo "Go files changed, rebuilding bd CLI..." + go install ./cmd/bd + echo "✓ bd CLI installed successfully" + echo "" +fi + +exit 0 diff --git a/scripts/install-hooks.sh b/scripts/install-hooks.sh new file mode 100755 index 00000000..9413cb58 --- /dev/null +++ b/scripts/install-hooks.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# Install git hooks from scripts/hooks/ to .git/hooks/ + +set -e + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +HOOKS_DIR="$REPO_ROOT/scripts/hooks" +GIT_HOOKS_DIR="$REPO_ROOT/.git/hooks" + +if [ ! -d "$GIT_HOOKS_DIR" ]; then + echo "Error: Not in a git repository" + exit 1 +fi + +echo "Installing git hooks..." + +for hook in "$HOOKS_DIR"/*; do + if [ -f "$hook" ]; then + hook_name=$(basename "$hook") + echo " Installing $hook_name" + cp "$hook" "$GIT_HOOKS_DIR/$hook_name" + chmod +x "$GIT_HOOKS_DIR/$hook_name" + fi +done + +echo "✓ Git hooks installed successfully" +echo "" +echo "Installed hooks:" +ls -1 "$GIT_HOOKS_DIR" | grep -v ".sample" || true