Skip to content

Commit ea6ec11

Browse files
ci(should-skip-this): only check commits when skip rule enabled
1 parent 4441642 commit ea6ec11

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/ci/scripts/should-skip-this.sh

+10-6
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,27 @@
66
set -euo pipefail
77
IFS=$'\n\t'
88

9+
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
10+
11+
if [[ -z "${CI_ONLY_WHEN_SUBMODULES_CHANGED+x}" ]]; then
12+
echo "Executing the job since there is no skip rule in effect"
13+
exit 0
14+
fi
15+
916
git fetch "https://github.com/$GITHUB_REPOSITORY" "$GITHUB_BASE_REF"
1017
BASE_COMMIT="$(git merge-base FETCH_HEAD HEAD)"
1118

1219
echo "Searching for toolstate changes between $BASE_COMMIT and $(git rev-parse HEAD)"
13-
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
1420

15-
if [[ -z "${CI_ONLY_WHEN_SUBMODULES_CHANGED+x}" ]]; then
16-
echo "Executing the job since there is no skip rule in effect"
17-
elif git diff "$BASE_COMMIT" | grep --quiet "^index .* 160000"; then
21+
if git diff "$BASE_COMMIT" | grep --quiet "^index .* 160000"; then
1822
# Submodules pseudo-files inside git have the 160000 permissions, so when
1923
# those files are present in the diff a submodule was updated.
2024
echo "Executing the job since submodules are updated"
2125
elif git diff --name-only "$BASE_COMMIT" | grep --quiet src/tools/'\(clippy\|rustfmt\)'; then
2226
# There is not an easy blanket search for subtrees. For now, manually list
23-
# clippy.
27+
# the subtrees.
2428
echo "Executing the job since clippy or rustfmt subtree was updated"
2529
else
26-
echo "Not executing this job since no submodules were updated"
30+
echo "Not executing this job since no submodules nor subtrees were updated"
2731
ciCommandSetEnv SKIP_JOB 1
2832
fi

0 commit comments

Comments
 (0)