Skip to content

Commit 9d58933

Browse files
bpo-40548: Fix "Check for source changes (pull_request)" GH Action job (GH-21806) (GH-92342)
On Git 2.28, "git diff master..." (3 dots) no longer works when "fetch --depth=1" is used, whereas it works on Git 2.26. Replace "..." (3 dots) with ".." (2 dots) in the "git diff" command computing the list of modified files between the base branch and the PR branch. (cherry picked from commit eaa5517) Co-authored-by: Victor Stinner <[email protected]>
1 parent 9da3502 commit 9d58933

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

.github/workflows/build.yml

+15-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,21 @@ jobs:
2626
if [ -z "$GITHUB_BASE_REF" ]; then
2727
echo '::set-output name=run_tests::true'
2828
else
29-
git fetch origin $GITHUB_BASE_REF
30-
git diff --name-only origin/$GITHUB_BASE_REF... | grep -qvE '(\.rst$|^Doc|^Misc)' && echo '::set-output name=run_tests::true' || true
29+
git fetch origin $GITHUB_BASE_REF --depth=1
30+
# git diff "origin/$GITHUB_BASE_REF..." (3 dots) may be more
31+
# reliable than git diff "origin/$GITHUB_BASE_REF.." (2 dots),
32+
# but it requires to download more commits (this job uses
33+
# "git fetch --depth=1").
34+
#
35+
# git diff "origin/$GITHUB_BASE_REF..." (3 dots) works with Git
36+
# 2.26, but Git 2.28 is stricter and fails with "no merge base".
37+
#
38+
# git diff "origin/$GITHUB_BASE_REF.." (2 dots) should be enough on
39+
# GitHub, since GitHub starts by merging origin/$GITHUB_BASE_REF
40+
# into the PR branch anyway.
41+
#
42+
# https://github.com/python/core-workflow/issues/373
43+
git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qvE '(\.rst$|^Doc|^Misc)' && echo '::set-output name=run_tests::true' || true
3144
fi
3245
3346
check_abi:

0 commit comments

Comments
 (0)