Skip to content

Commit 9af88d3

Browse files
authored
fix release tag check (#486)
1 parent 9d06645 commit 9af88d3

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

‎.github/workflows/release/release.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,10 @@ def cmd_check_commit_exists(args: argparse.Namespace) -> None:
207207

208208

209209
def cmd_check_tag_free(args: argparse.Namespace) -> None:
210+
# /git/ref/ (singular) is an EXACT-match lookup that 404s when the tag is
211+
# free.
210212
try:
211-
gh_api("GET", f"/git/refs/tags/{args.tag}")
213+
gh_api("GET", f"/git/ref/tags/{args.tag}")
212214
print(f"❌ Tag {args.tag} already exists. Pick a different version.")
213215
sys.exit(1)
214216
except GhApiError:

‎.github/workflows/release/test_release.py‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,23 @@ def test_tag_exists(self, capsys):
408408
cmd_check_tag_free(_ns(tag="v1.2.3"))
409409
assert exc.value.code == 1
410410

411+
def test_uses_exact_match_endpoint(self):
412+
# Regression: the check MUST use /git/ref/ (singular, exact match).
413+
# The plural /git/refs/ endpoint does PREFIX matching on GitHub's
414+
# side, so existing v1.2.3-rc* tags made v1.2.3 read as taken and
415+
# the rc -> final release flow always failed validation. The mock
416+
# can't reproduce GitHub's prefix semantics, so the load-bearing
417+
# assertion is the endpoint path itself.
418+
with patch("release.gh_api") as mock_gh:
419+
mock_gh.side_effect = GhApiError("not found")
420+
with pytest.raises(SystemExit):
421+
cmd_check_tag_free(_ns(tag="v1.2.3"))
422+
path = mock_gh.call_args.args[1]
423+
assert path == "/git/ref/tags/v1.2.3", (
424+
f"tag-free check must use the exact-match singular /git/ref/ "
425+
f"endpoint, got: {path}"
426+
)
427+
411428

412429
# ── create-tag ───────────────────────────────────────────────────────────────
413430

@@ -504,5 +521,3 @@ def _git_rev(path: Path, ref: str) -> str:
504521
cwd=str(path), capture_output=True, text=True,
505522
)
506523
return r.stdout.strip()
507-
508-

0 commit comments

Comments
 (0)