Files
eagle0/scripts/pre-commit-gazelle.sh
T

22 lines
596 B
Bash
Executable File

#!/bin/bash
# Pre-commit hook wrapper for gazelle that fails if files are modified.
# This ensures BUILD files are in canonical format before committing.
set -e
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
# Run gazelle
bazel run //:gazelle
# Check if any BUILD files were modified
if ! git diff --quiet -- '*.bazel' '**/BUILD' 'WORKSPACE*'; then
echo ""
echo "ERROR: gazelle modified BUILD files. Please stage the changes and retry:"
echo ""
git diff --name-only -- '*.bazel' '**/BUILD' 'WORKSPACE*'
echo ""
echo "Run: git add -u && git commit"
exit 1
fi