-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Norihiro Watanabe
committed
Mar 11, 2016
1 parent
c132ad6
commit 99983a3
Showing
2 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
# | ||
# Modified from https://github.com/google/closure-library/tree/master/scripts/ci | ||
# | ||
# Script to determine if files in Pull Request are properly formatted. | ||
# Exits with non 0 exit code if formatting is needed. | ||
|
||
CLANG_FORMAT_DIFF=clang-format-diff-3.7 | ||
|
||
FILES_TO_CHECK=$(git diff --name-only master | grep -E "\.h|\.cpp$") | ||
|
||
if [ -z "${FILES_TO_CHECK}" ]; then | ||
echo "No files to check for formatting." | ||
exit 0 | ||
fi | ||
|
||
FORMAT_DIFF=$(git diff -U0 master -- ${FILES_TO_CHECK} | | ||
${CLANG_FORMAT_DIFF} -p1 -style=file) | ||
|
||
if [ -z "${FORMAT_DIFF}" ]; then | ||
# No formatting necessary. | ||
echo "All files in PR properly formatted." | ||
exit 0 | ||
else | ||
# Found diffs. | ||
echo "ERROR: Found formatting errors!" | ||
echo "${FORMAT_DIFF}" | ||
echo "See https://goo.gl/wUEkW9 for instructions to format your PR." | ||
exit 1 | ||
fi |