Skip to content

Commit 99e41d1

Browse files
committed
More reliable way to check differences before acutal merge
1 parent 2def7c2 commit 99e41d1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

.github/actions/ensure-release-branch/ensure-release-branch.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,14 @@ if execute_command git ls-remote --heads origin "$RELEASE_VERSION_BRANCH" | grep
111111

112112
if [ "$COMMITS_TO_MERGE" -gt 0 ]; then
113113
# Compare the two branches to see if there are actual file differences
114-
execute_command --ignore-exit-code 1 --no-std -- git diff --quiet "origin/$RELEASE_VERSION_BRANCH" "origin/$RELEASE_BRANCH"
115-
if [ "$last_cmd_result" -eq 1 ]; then
114+
# The reliable way to check the differences ignoring merges from version
115+
# branch into release branch is to perform a merge and check the result
116+
execute_command --no-std -- git switch -c tmp-rvb "origin/$RELEASE_VERSION_BRANCH"
117+
execute_command --no-std -- git merge --no-commit --no-ff "origin/$RELEASE_BRANCH"
118+
execute_command --ignore-exit-code 1 --no-std -- git diff --quiet --cached "origin/$RELEASE_VERSION_BRANCH"
119+
diff_result=$last_cmd_result
120+
execute_command --ignore-errors --no-std -- git merge --abort
121+
if [ "$diff_result" -eq 1 ]; then
116122
echo "Found file differences between $RELEASE_BRANCH and $RELEASE_VERSION_BRANCH"
117123
execute_command --no-std -- git diff --name-only "origin/$RELEASE_VERSION_BRANCH" "origin/$RELEASE_BRANCH"
118124
console_output 1 gray "$last_cmd_stdout"

0 commit comments

Comments
 (0)