diff options
| author | Michael Maltese <mchtly@gmail.com> | 2017-07-18 15:32:35 -0700 |
|---|---|---|
| committer | Michael Maltese <mchtly@gmail.com> | 2017-07-18 15:36:15 -0700 |
| commit | 6939590598feccce9c9090d497f26cfa67deac6b (patch) | |
| tree | 8afa7038d1956c571c78aaf5e26ba6672287b58d /Tools | |
| parent | bcdab8af488d1da562412ba4a172aac712cfba61 (diff) | |
Tools/lint.sh: turn on Bash 'strict mode'
Now fails if any commands fail. I noticed that on the buildbot, the
arguments to this script can be incorrect (somehow?) which can result in
no lint checks happening but the buildbot still passing.
Diffstat (limited to 'Tools')
| -rwxr-xr-x | Tools/lint.sh | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Tools/lint.sh b/Tools/lint.sh index aeab86d7d0..4341192146 100755 --- a/Tools/lint.sh +++ b/Tools/lint.sh @@ -2,13 +2,18 @@ # # Linter script that checks for common style issues in Dolphin's codebase. +set -euo pipefail + fail=0 # Default to staged files, unless a commit was passed. COMMIT=${1:---cached} +# Get modified files (must be on own line for exit-code handling) +modified_files=$(git diff --name-only --diff-filter=ACMRTUXB $COMMIT) + # Loop through each modified file. -for f in $(git diff --name-only --diff-filter=ACMRTUXB $COMMIT); do +for f in ${modified_files}; do # Filter them. if ! echo "${f}" | egrep -q "[.](cpp|h|mm)$"; then continue @@ -18,7 +23,7 @@ for f in $(git diff --name-only --diff-filter=ACMRTUXB $COMMIT); do fi # Check for clang-format issues. - d=$(diff -u "${f}" <(clang-format ${f})) + d=$(clang-format ${f} | (diff -u "${f}" - || true)) if ! [ -z "${d}" ]; then echo "!!! ${f} not compliant to coding style, here is the fix:" echo "${d}" @@ -26,7 +31,8 @@ for f in $(git diff --name-only --diff-filter=ACMRTUXB $COMMIT); do fi # Check for newline at EOF. - if [ -n "$(tail -c 1 ${f})" ]; then + last_line="$(tail -c 1 ${f})" + if [ -n "${last_line}" ]; then echo "!!! ${f} not compliant to coding style:" echo "Missing newline at end of file" fail=1 |
