Skip to content

Commit 5bd6350

Browse files
committed
script/cibuild: make trailing whitespace check fatal
We currently intend for our CI check for trailing whitespace to be fatal; that is, if any trailing whitespace is present, our CI script should fail. However, currently that doesn't work, since apparently set -e is not concerned with a negated pipeline having a nonzero exit code. To make things more robust, let's make this into an if statement and exit 1 if we match any files (that is, if grep returns 0). Note that this used to work because it was the last command in the file, but it no longer does for the above reason.
1 parent 29859cd commit 5bd6350

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

script/cibuild

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ pushd t >/dev/null
3838
popd >/dev/null
3939

4040
echo "Looking for trailing whitespace..."
41-
! git grep -lE '[[:space:]]+$' | \
42-
grep -vE '(^vendor/|\.git/(objects/|index)|\.bat$)'
41+
if git grep -lE '[[:space:]]+$' | \
42+
grep -vE '(^vendor/|\.git/(objects/|index)|\.bat$)'
43+
then
44+
exit 1
45+
fi
4346

4447
echo "Formatting files..."
4548
# Building and installing goimports and goversioninfo will have modified go.mod

0 commit comments

Comments
 (0)