ci(patch): fall back to develop when the base ref has no frappe branch

The Patch Test fetches the frappe repo using this erpnext PR's base branch
name. For an ordinary PR that is develop, which exists in frappe/frappe. For a
stacked PR the base is an erpnext feature branch with no counterpart there, so
the fetch fails and the step exits 128 before any patch runs:

    fatal: couldn't find remote ref pg-audit/bom-amount-per-line

This affects every stacked PR. It has been latent rather than absent: earlier
stacks passed only because their Patch Test ran while they still targeted
develop, before being retargeted onto the layer below.

Fall back to develop when the base ref does not resolve. Ordinary PRs and
version-branch PRs are unaffected -- their base exists in frappe, so the first
fetch succeeds and the fallback never runs.
This commit is contained in:
Mihir Kandoi
2026-08-02 20:26:47 +05:30
parent 78f9be257b
commit 1a83fc516e

View File

@@ -171,7 +171,11 @@ jobs:
update_to_version 16 3.14
echo "Updating to latest version"
git -C "apps/frappe" fetch --depth 1 upstream "${GITHUB_BASE_REF:-${GITHUB_REF##*/}}"
# a stacked PR's base is an erpnext feature branch with no counterpart in frappe,
# so fall back to the repository's default branch
base_ref="${GITHUB_BASE_REF:-${GITHUB_REF##*/}}"
git -C "apps/frappe" fetch --depth 1 upstream "$base_ref" \
|| git -C "apps/frappe" fetch --depth 1 upstream develop
git -C "apps/frappe" checkout -q -f FETCH_HEAD
git -C "apps/erpnext" checkout -q -f "$GITHUB_SHA"