ci: make change-scope classification robust to divergent PR branches
All checks were successful
CI / ci (pull_request) Successful in 4m24s
All checks were successful
CI / ci (pull_request) Successful in 4m24s
The scope step shallow-fetched the base (`--depth=1`) and ran `git diff origin/<base>...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) <noreply@anthropic.com>
This commit is contained in:
@@ -38,8 +38,18 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
BASE="${{ github.base_ref }}"
|
BASE="${{ github.base_ref }}"
|
||||||
git fetch --no-tags --depth=1 origin "$BASE"
|
# Full (not --depth=1) base fetch so the merge-base is present even when
|
||||||
CHANGED=$(git diff --name-only "origin/$BASE...HEAD")
|
# 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"
|
echo "Changed files:"; echo "$CHANGED"
|
||||||
if echo "$CHANGED" | grep -vE '(\.md$|^docs/|^fdroid-metadata/|^fastlane/|^LICENSE$)' | grep -q .; then
|
if echo "$CHANGED" | grep -vE '(\.md$|^docs/|^fdroid-metadata/|^fastlane/|^LICENSE$)' | grep -q .; then
|
||||||
echo "code=true" >> "$GITHUB_OUTPUT"
|
echo "code=true" >> "$GITHUB_OUTPUT"
|
||||||
|
|||||||
Reference in New Issue
Block a user