Skip to content

Commit

Permalink
git/hooks: Prevent pre-push from looping format check (envoyproxy#29580)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <[email protected]>
  • Loading branch information
phlax authored Sep 12, 2023
1 parent 8f42e90 commit be9974a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions support/hooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,17 @@ do
# `$CLANG_FORMAT` and `$BUILDIFY` are defined, or that the default values it
# assumes for these variables correspond to real binaries on the system. If
# either of these things aren't true, the check fails.
for i in $(git diff --name-only "$RANGE" --diff-filter=ACMR --ignore-submodules=all 2>&1); do
echo -ne " Checking format for $i - "
bazel run //tools/code_format:check_format -- check "$i" || exit 1

# TODO(phlax): It seems this is not running in CI anymore and is now finding issues
# in merged PRs. Unify this hook and format checks in CI when the new format tool is rolled
# out.
# echo " Checking spelling for $i"
# "$SCRIPT_DIR"/spelling/check_spelling_pedantic.py check "$i" || exit 1
done
_CHANGES=$(git diff --name-only "$RANGE" --diff-filter=ACMR --ignore-submodules=all 2>&1 | tr '\n' ' ')
IFS=' ' read -ra CHANGES <<< "$_CHANGES"

echo -ne " Checking format for ${CHANGES[*]} - "
bazel run //tools/code_format:check_format -- check "${CHANGES[@]}" || exit 1
# TODO(phlax): It seems this is not running in CI anymore and is now finding issues
# in merged PRs. Unify this hook and format checks in CI when the new format tool is rolled
# out.
# echo " Checking spelling for $i"
# "$SCRIPT_DIR"/spelling/check_spelling_pedantic.py check "${CHANGES[@]}" || exit 1

# TODO(mattklein123): Optimally we would be able to do this on a per-file basis.
"$SCRIPT_DIR"/proto_format/proto_format.sh check || exit 1
Expand Down
2 changes: 1 addition & 1 deletion tools/code_format/check_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def excluded_prefixes(self):
self.config.paths["excluded"] + tuple(self.args.add_excluded_prefixes)
if self.args.add_excluded_prefixes else self.config.paths["excluded"])

@property
@cached_property
def error_messages(self):
return []

Expand Down

0 comments on commit be9974a

Please sign in to comment.