Skip to content

Commit ee4584f

Browse files
Compare tree hashes instead of using git diff
Comparing tree hashes is more accurate for detecting content differences between the merge commit and PR head, avoiding false positives when the content is identical but commit SHAs differ.
1 parent 013f11f commit ee4584f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test_harness.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ if haskey(ENV, "GITHUB_SHA") && get(ENV, "GITHUB_EVENT_NAME", "") == "pull_reque
2525

2626
# Check if there's any difference between the merge commit and the PR head
2727
# 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`)
28+
# Compare tree hashes to check if content actually differs
29+
merge_tree = chomp(read(`git rev-parse HEAD^{tree}`, String))
30+
pr_tree = chomp(read(`git rev-parse HEAD^2^{tree}`, String))
31+
has_diff = merge_tree != pr_tree
3032

3133
if has_diff
3234
base_branch = isempty(base_branch_name) ? "the base branch" : "'$base_branch_name'"

0 commit comments

Comments
 (0)