From 27c60c532d33263f9ac74c05d9e8fff183957676 Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Fri, 2 Oct 2026 16:06:06 +0100 Subject: [PATCH 1/2] Fix detection of merge conflicts outside `lib` in the rebuild workflow Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/rebuild.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rebuild.yml b/.github/workflows/rebuild.yml index faa32c65d9..9daf5e6e81 100644 --- a/.github/workflows/rebuild.yml +++ b/.github/workflows/rebuild.yml @@ -70,11 +70,11 @@ jobs: if [ "$MERGE_RESULT" -ne 0 ]; then echo "merge-in-progress=true" >> $GITHUB_OUTPUT - # Check for merge conflicts outside of `lib`. Disable git diff's trailing whitespace check - # since `node_modules/@types/semver/README.md` fails it. - if git -c core.whitespace=-trailing-space diff --check | grep --invert-match '^lib/'; then + # Check for merge conflicts outside of `lib`. + CONFLICTS_OUTSIDE_LIB=$(git diff --name-only --diff-filter=U | grep --invert-match '^lib/' || true) + if [ -n "$CONFLICTS_OUTSIDE_LIB" ]; then echo "Merge conflicts were detected outside of the lib directory. Please resolve them manually." - git -c core.whitespace=-trailing-space diff --check | grep --invert-match '^lib/' || true + echo "$CONFLICTS_OUTSIDE_LIB" exit 1 fi From 56b0d5f02c15aec22d79bfd6e21d4f7829742b54 Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Fri, 2 Oct 2026 16:06:52 +0100 Subject: [PATCH 2/2] Fix the rebuild workflow failing when merging the base branch conflicts Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/rebuild.yml | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/rebuild.yml b/.github/workflows/rebuild.yml index 9daf5e6e81..c9522bf9a9 100644 --- a/.github/workflows/rebuild.yml +++ b/.github/workflows/rebuild.yml @@ -54,20 +54,12 @@ jobs: run: | git fetch origin "$BASE_BRANCH" - # Allow merge conflicts in `lib`, since rebuilding should resolve them. - git merge "origin/$BASE_BRANCH" - MERGE_RESULT=$? - - if [ "$MERGE_RESULT" -eq 0 ]; then + # Allow merge conflicts in `lib`, since rebuilding should resolve them. Conflicts leave the + # merge in progress, so check for `MERGE_HEAD` to tell them apart from failures that don't. + if git merge "origin/$BASE_BRANCH"; then echo "Merge succeeded cleanly." - elif [ "$MERGE_RESULT" -eq 1 ]; then - echo "Merge conflicts detected (exit code $MERGE_RESULT), continuing." - else - echo "git merge failed with unexpected exit code $MERGE_RESULT." - exit 1 - fi - - if [ "$MERGE_RESULT" -ne 0 ]; then + elif git rev-parse --verify MERGE_HEAD >/dev/null 2>&1; then + echo "Merge conflicts detected, continuing." echo "merge-in-progress=true" >> $GITHUB_OUTPUT # Check for merge conflicts outside of `lib`. @@ -80,6 +72,9 @@ jobs: echo "No merge conflicts found outside the lib directory. We should be able to resolve all of" \ "these by rebuilding the Action." + else + echo "git merge failed for a reason other than merge conflicts." + exit 1 fi - name: Compile TypeScript