Run scalafmt hook through Bazel (#6753)

This commit is contained in:
2026-05-24 13:01:56 -07:00
committed by GitHub
parent c08ed8c170
commit e543d7b53f
6 changed files with 856 additions and 3 deletions
+3 -1
View File
@@ -4,8 +4,10 @@
set -e
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
# Run gazelle
bazel run //:gazelle 2>/dev/null
bazel run //:gazelle
# Check if any BUILD files were modified
if ! git diff --quiet -- '*.bazel' '**/BUILD' 'WORKSPACE*'; then
+22
View File
@@ -0,0 +1,22 @@
#!/bin/bash
# Pre-commit hook wrapper for scalafmt.
# Runs the repository-pinned scalafmt CLI through Bazel.
set -e
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
if [ "$#" -eq 0 ]; then
exit 0
fi
repo_root="$(git rev-parse --show-toplevel)"
files=()
for file in "$@"; do
case "$file" in
/*) files+=("$file") ;;
*) files+=("$repo_root/$file") ;;
esac
done
bazel run //tools:scalafmt -- --config "$repo_root/.scalafmt.conf" -i "${files[@]}"