Skip to content

Commit 2980151

Browse files
foriequal0mergify[bot]
authored andcommitted
Fix not to swallow errors
1 parent 580f985 commit 2980151

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

.travis/check-change

+13-8
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,26 @@ esac
101101
git log --oneline --decorate --all --graph | head -n 10;
102102
echo "Check changes for: ${COMMIT_RANGE}"
103103

104-
# `grep` uses return value to report both result and error.
105-
# So `set -e` should be disabled to catch them.
106-
set +e
107-
git diff --name-only "${COMMIT_RANGE}" | grep -qvE "$1"
108-
case $? in
109-
0)
104+
FILE_CHANGES=$(git diff --name-only "${COMMIT_RANGE}")
105+
RESULT=$?
106+
if [[ "$RESULT" -ne 0 ]]
107+
then
108+
echo "Error: cannot get changed files"
109+
exit $RESULT
110+
fi
111+
112+
grep -qvE "$1" <<< "$FILE_CHANGES" && RESULT=0 || RESULT=$?
113+
case $RESULT in
114+
0)
110115
noskip_travis
111116
;;
112117
1)
113118
echo "Only '$1' were updated, or there's no change, not running the CI."
114119
skip_travis
115120
;;
116-
*)
121+
*)
117122
echo "Error in grep pattern"
118-
exit -1
123+
exit $RESULT
119124
;;
120125
esac
121126

.travis/check-mergify-merge

+6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ esac
3737

3838
MERGIFY_COMMITTER="mergify[bot] <mergify[bot]@users.noreply.github.com>"
3939
COMMITTER=$(git show --format="%cN <%cE>" --no-patch "${TRAVIS_COMMIT}")
40+
RESULT=$?
41+
if [[ "$RESULT" -ne 0 ]]
42+
then
43+
echo "Error: cannot get the committer"
44+
exit $RESULT
45+
fi
4046

4147
if [[ "${COMMITTER}" = "${MERGIFY_COMMITTER}" ]]
4248
then

0 commit comments

Comments
 (0)