Skip to content

Commit 08c7c61

Browse files
jyn514calebcartwright
authored andcommitted
should-skip-this: Check for changes between the master branch, not the previous commit.
The previous commit could be part of the current PR.
1 parent 56fa9b4 commit 08c7c61

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@
66
set -euo pipefail
77
IFS=$'\n\t'
88

9+
git fetch "https://github.com/$GITHUB_REPOSITORY" "$GITHUB_BASE_REF"
10+
BASE_COMMIT="$(git merge-base FETCH_HEAD HEAD)"
11+
12+
echo "Searching for toolstate changes between $BASE_COMMIT and $(git rev-parse HEAD)"
913
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
1014

1115
if [[ -z "${CI_ONLY_WHEN_SUBMODULES_CHANGED+x}" ]]; then
1216
echo "Executing the job since there is no skip rule in effect"
13-
elif git diff HEAD^ | grep --quiet "^index .* 160000"; then
17+
elif git diff "$BASE_COMMIT" | grep --quiet "^index .* 160000"; then
1418
# Submodules pseudo-files inside git have the 160000 permissions, so when
1519
# those files are present in the diff a submodule was updated.
1620
echo "Executing the job since submodules are updated"
17-
elif git diff --name-only HEAD^ | grep --quiet src/tools/'\(clippy\|rustfmt\)'; then
21+
elif git diff --name-only "$BASE_COMMIT" | grep --quiet src/tools/'\(clippy\|rustfmt\)'; then
1822
# There is not an easy blanket search for subtrees. For now, manually list
1923
# clippy.
2024
echo "Executing the job since clippy or rustfmt subtree was updated"

0 commit comments

Comments
 (0)