@@ -180,8 +180,16 @@ def test_tags_the_approved_release_merge(self):
180180 def test_skips_an_ordinary_push_after_a_tagged_release (self ):
181181 self .assertEqual ("skip" , self .decide (None , {"v9.0.0+tibiash.3" : OLD }))
182182
183- def test_skips_a_direct_push (self ):
184- self .assertEqual ("skip" , self .decide (None ))
183+ def test_fails_an_untagged_version_with_no_merged_pr (self ):
184+ # A release merge that commits/{sha}/pulls did not list yet, or a direct push of an untagged version.
185+ self .assertEqual ("fail" , self .decide (None ))
186+
187+ def test_fails_an_untagged_version_with_no_merged_pr_and_no_tags (self ):
188+ self .assertEqual ("fail" , self .decide (None , {}))
189+
190+ def test_skips_an_ordinary_merge_while_the_version_is_untagged (self ):
191+ ordinary = merged_pr (head = {"ref" : "fix/parser" , "sha" : "c" * 40 }, user = {"login" : "someone" , "type" : "User" })
192+ self .assertEqual ("skip" , self .decide (ordinary ))
185193
186194 def test_skips_an_upstream_version (self ):
187195 self .assertEqual ("skip" , self .decide (None , version = "9.1.0" ))
@@ -298,7 +306,11 @@ def tag_decision(self, pr: object) -> tuple[int, str]:
298306 def test_prints_the_decision_and_the_version (self ):
299307 self .assertEqual ((0 , "decision=tag\n version=9.0.0+tibiash.3\n " ), self .tag_decision (merged_pr ()))
300308
301- def test_null_pr_is_a_skip (self ):
309+ def test_null_pr_with_an_untagged_version_fails (self ):
310+ self .assertEqual ((0 , "decision=fail\n version=9.0.0+tibiash.3\n " ), self .tag_decision (None ))
311+
312+ def test_null_pr_with_a_tagged_version_skips (self ):
313+ self .write ("tags.txt" , f"{ OLD } refs/tags/v9.0.0+tibiash.3\n " )
302314 self .assertEqual ((0 , "decision=skip\n version=9.0.0+tibiash.3\n " ), self .tag_decision (None ))
303315
304316 def test_head_must_be_a_full_sha (self ):
@@ -571,8 +583,9 @@ def test_decides_with_the_script_and_fails_red(self):
571583 noop) echo "v$version already points at $GITHUB_SHA." ;;
572584 skip) echo "$GITHUB_SHA is not drptbl's merge of the App's release pull request, so nothing is tagged." ;;
573585 fail)
574- echo "::error::v$version cannot be tagged at $GITHUB_SHA." \\
575- "The version is not x.y.z+tibiash.N, or the tag points at another commit."
586+ echo "::error::v$version cannot be tagged at $GITHUB_SHA. The version is not x.y.z+tibiash.N," \\
587+ "its tag points at another commit, or it has no tag and no merged pull request was found." \\
588+ "For a release merge, re-run this run once the pull request shows as merged."
576589 exit 1
577590 ;;
578591 *)
0 commit comments