From c503199e06ce380405cbdda5d419a91af5f74453 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Sun, 21 Jun 2026 13:32:30 +0200 Subject: [PATCH] ci: make change-scope classification robust to divergent PR branches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The scope step shallow-fetched the base (`--depth=1`) and ran `git diff origin/...HEAD`. The three-dot diff needs the merge-base, which a depth-1 tip doesn't contain once a branch has forked a few commits back — git aborts with "no merge base" (exit 128) and the whole CI job fails before lint/test/build ever run. Fetch the base fully, resolve the merge-base explicitly, and diff from it. If no common ancestor is found, default to code=true so the build still runs rather than being wrongly skipped. Co-Authored-By: Claude Opus 4.8 (1M context) --- .gitea/workflows/ci.yaml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 799d73a..1132547 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -38,8 +38,18 @@ jobs: run: | set -e BASE="${{ github.base_ref }}" - git fetch --no-tags --depth=1 origin "$BASE" - CHANGED=$(git diff --name-only "origin/$BASE...HEAD") + # Full (not --depth=1) base fetch so the merge-base is present even when + # the PR branch forked several commits back; a shallow tip has no merge + # base with a divergent branch and `git diff base...HEAD` aborts. + git fetch --no-tags origin "$BASE" + MB=$(git merge-base "origin/$BASE" HEAD 2>/dev/null || true) + if [ -z "$MB" ]; then + # No common ancestor available — don't risk skipping the build. + echo "No merge base with origin/$BASE — running the full build to be safe." + echo "code=true" >> "$GITHUB_OUTPUT" + exit 0 + fi + CHANGED=$(git diff --name-only "$MB" HEAD) echo "Changed files:"; echo "$CHANGED" if echo "$CHANGED" | grep -vE '(\.md$|^docs/|^fdroid-metadata/|^fastlane/|^LICENSE$)' | grep -q .; then echo "code=true" >> "$GITHUB_OUTPUT"