From 4bce62e1fa80fe9921c8cc538889286c4df3b028 Mon Sep 17 00:00:00 2001 From: codex-bot-andresmgsl Date: Mon, 31 Aug 2026 21:20:35 +0000 Subject: [PATCH] test(labels): prove merge-base fallback --- test/labels-reconcile.test.sh | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/test/labels-reconcile.test.sh b/test/labels-reconcile.test.sh index 9dd71c3..14b7ebc 100755 --- a/test/labels-reconcile.test.sh +++ b/test/labels-reconcile.test.sh @@ -176,10 +176,12 @@ expect "a bare head over an unreadable base still warns" yes \ "$(release_shape_warning 41 2.0.0 "" | grep -qF '::warning::' && echo yes || echo no)" # The pure matrix above proves the warning predicate. These two fixtures drive -# the sweep boundary that chooses WHICH base tree feeds it (#275): Forgejo and -# GitHub both expose the PR's moving base tip beside its fixed merge base, and -# using the former manufactures a downgrade after an intervening release. -release_shape_ref_probe() { # $1 = phantom | bump +# the sweep boundary that chooses WHICH base tree feeds it (#275): the +# reporting Forgejo payload exposes the PR's moving base tip beside its fixed +# merge base, and using the former manufactures a downgrade after an +# intervening release. A missing merge-base field deliberately keeps the +# specified base-tip fallback for backends that do not supply that fact. +release_shape_ref_probe() { # $1 = phantom | bump | fallback ( # shellcheck disable=SC2030 # this probe intentionally isolates its repository fixture REPO=owner/repo @@ -190,9 +192,14 @@ release_shape_ref_probe() { # $1 = phantom | bump : >"$refs" case "$mode" in phantom) - head_ver=1.3.0 base_tip_ver=1.4.0 merge_base_ver=1.3.0 ;; + head_ver=1.3.0 base_tip_ver=1.4.0 merge_base_ver=1.3.0 + merge_base_json='"merge-base"' ;; bump) - head_ver=1.4.0 base_tip_ver=1.3.0 merge_base_ver=1.3.0 ;; + head_ver=1.4.0 base_tip_ver=1.3.0 merge_base_ver=1.3.0 + merge_base_json='"merge-base"' ;; + fallback) + head_ver=1.4.0 base_tip_ver=1.4.0 merge_base_ver=unused + merge_base_json=null ;; *) return 2 ;; esac # shellcheck disable=SC2317 # reached through the GitHub backend selected above @@ -214,8 +221,9 @@ release_shape_ref_probe() { # $1 = phantom | bump *'repos/owner/repo/pulls/701 --jq .requested_reviewers'*) return 0 ;; *repos/owner/repo/pulls/701/reviews*) return 0 ;; *repos/owner/repo/pulls/701) - jq -n '{draft:false,user:{login:"fixture-builder"}, - head:{sha:"head"},base:{sha:"base-tip"},merge_base:"merge-base", + jq -n --argjson merge_base "$merge_base_json" \ + '{draft:false,user:{login:"fixture-builder"}, + head:{sha:"head"},base:{sha:"base-tip"},merge_base:$merge_base, labels:[{name:"state:addressing"},{name:"blocked"}], requested_reviewers:[],created_at:"2026-08-31T20:00:00Z"}' ;; *repos/owner/repo/commits/head*) printf '2026-08-31T20:00:00Z\n' ;; @@ -248,6 +256,12 @@ expect "a genuine version bump relative to the merge base keeps the warning text expect "the genuine-bump guard also compares head with the PR merge base" \ $'head\nmerge-base' "$(cat "$RTMP/release-shape-bump-refs")" +fallback_shape="$(release_shape_ref_probe fallback)" +expect "a null merge base falls back to the base tip without guessing a warning" \ + no "$(grep -q 'release-shaped' <<<"$fallback_shape" && echo yes || echo no)" +expect "the null merge-base fallback compares head with the base tip" \ + $'head\nbase-tip' "$(cat "$RTMP/release-shape-fallback-refs")" + # -- drafts are building, whoever is requested -------------------------------- DRAFT=true HEAD_SHA=head1 REQUESTED="" REVIEWS_JSON='[]' expect "draft PR is building" state:building "$(decide_state)"