Skip to content

Commit f26ea9c

Browse files
authored
Update formatting.md
1 parent 78eebc1 commit f26ea9c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

docs/formatting.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,12 @@ fi
181181
# Get staged files and format them
182182
git diff --cached --diff-filter=AM --name-only -z | xargs --null --no-run-if-empty bash -c '
183183
if [ $# -gt 0 ]; then
184-
bazel run //:format -- "$@"
184+
# Avoid building the target if it was already placed in the bazel_env output
185+
if [ -e "bazel-out/bazel_env-opt/bin/tools/bazel_env/bin/format" ]; then
186+
bazel-out/bazel_env-opt/bin/tools/bazel_env/bin/format "$@"
187+
else
188+
bazel run //:format -- "$@"
189+
fi
185190
186191
if ! git diff --quiet -- "$@"; then
187192
echo "❌ Some staged files were modified by the pre-commit hook."

0 commit comments

Comments
 (0)