@@ -14,13 +14,42 @@ kwargs = Kwargs.kwargs(; coverage=ENV["COVERAGE"],
1414kwargs_reprs = map (kv -> string (kv[1 ], " =" , repr (kv[2 ])), collect (kwargs))
1515kwargs_repr = join (kwargs_reprs, " , " )
1616
17+ # Warn if running on a merge commit (different from branch HEAD)
18+ git_note = " "
19+ if haskey (ENV , " GITHUB_SHA" ) && get (ENV , " GITHUB_EVENT_NAME" , " " ) == " pull_request" && haskey (ENV , " GITHUB_HEAD_REF" )
20+ # For pull_request events, GITHUB_SHA is the merge commit, not the PR head commit
21+ try
22+ merge_commit = ENV [" GITHUB_SHA" ]
23+ pr_branch = ENV [" GITHUB_HEAD_REF" ]
24+ base_branch_name = get (ENV , " GITHUB_BASE_REF" , " " )
25+
26+ # Check if there's any difference between the merge commit and the PR head
27+ # In GitHub Actions, HEAD^2 is the PR head (second parent of merge commit)
28+ # success() returns true if the command exits with 0 (no differences)
29+ has_diff = ! success (` git diff --quiet --exit-code HEAD^2 HEAD` )
30+
31+ if has_diff
32+ base_branch = isempty (base_branch_name) ? " the base branch" : " '$base_branch_name '"
33+ global git_note = """
34+ │ Note: This is being run on merge commit $merge_commit (merge of PR branch '$pr_branch ' into $base_branch ).
35+ │ The content differs from the actual commit on your PR branch.
36+ │ To reproduce locally, update your branch with $base_branch first.
37+ │
38+ """
39+ end
40+ catch e
41+ @warn " Error while checking git diff" exception= (e, catch_backtrace ())
42+ end
43+ end
44+
1745print ("""
1846│
1947│ To reproduce this CI run locally run the following from the same repository state on julia version $VERSION :
2048│
2149│ `import Pkg; Pkg.test(;$kwargs_repr )`
2250│
2351""" )
52+ print (git_note)
2453
2554if parse (Bool, ENV [" ANNOTATE" ]) && v " 1.8pre" < VERSION < v " 1.9.0-beta3"
2655 push! (LOAD_PATH , " @tests-logger-env" ) # access dependencies
0 commit comments