From 6896561bd2ca7e54e8027ddf5ef7c944025585b6 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Tue, 17 Nov 2026 11:05:20 +0100 Subject: [PATCH] Use the subpackage's tag name in manual release instructions When pushing a tag fails, TagBot opens an issue with commands to tag and release the version by hand. Those commands used the bare version, so for a subpackage they created `v1.0.0` instead of `Foo-v1.0.0`, and checked for the wrong tag when deciding whether only the release was missing. --- tagbot/action/repo.py | 12 +++++++----- test/action/test_repo.py | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/tagbot/action/repo.py b/tagbot/action/repo.py index db3f84cb..d474c00a 100644 --- a/tagbot/action/repo.py +++ b/tagbot/action/repo.py @@ -1305,7 +1305,8 @@ def _manual_tag_body(self, failures: list[tuple[str, str, str]]) -> str: commands = self._manual_tag_commands(failures) versions_list = "\n".join( - f"- [ ] `{v}` at commit `{sha[:8]}`" for v, sha, _ in failures + f"- [ ] `{self._get_version_tag(v)}` at commit `{sha[:8]}`" + for v, sha, _ in failures ) pat_url = ( "https://docs.github.com/en/authentication/" @@ -1397,12 +1398,13 @@ def _manual_tag_commands(self, failures: list[tuple[str, str, str]]) -> list[str """Build shell commands for manually tagging and releasing versions.""" commands = [] for v, sha, _ in failures: - if self._tag_exists(v): - commands.append(f"gh release create {v} --generate-notes") + tag = self._get_version_tag(v) + if self._tag_exists(tag): + commands.append(f"gh release create {tag} --generate-notes") else: commands.append( - f"git tag -a {v} {sha} -m '{v}' && git push origin {v} && " - f"gh release create {v} --target {sha} --generate-notes" + f"git tag -a {tag} {sha} -m '{tag}' && git push origin {tag} && " + f"gh release create {tag} --target {sha} --generate-notes" ) return commands diff --git a/test/action/test_repo.py b/test/action/test_repo.py index a4fae68a..cc2d5e0c 100644 --- a/test/action/test_repo.py +++ b/test/action/test_repo.py @@ -1431,6 +1431,29 @@ def test_create_release_subdir(): ) +def test_manual_tag_body_subdir(): + r = _repo(subdir="path/to/Foo.jl") + r._repo = Mock() + r._repo.get_contents.return_value.decoded_content = b'name = "Foo"\n' + + def get_git_ref(ref): + if ref != "tags/Foo-v1.0.0": + raise UnknownObjectException(404, "Not Found", {}) + return Mock() + + r._repo.get_git_ref.side_effect = get_git_ref + r._run_url = Mock(return_value="url") + body = r._manual_tag_body( + [("v1.0.0", "abcdef12", "error"), ("v1.1.0", "bcdef123", "error")] + ) + assert "`Foo-v1.0.0` at commit" in body + assert "gh release create Foo-v1.0.0 --generate-notes" in body + assert ( + "git tag -a Foo-v1.1.0 bcdef123 -m 'Foo-v1.1.0' && git push origin Foo-v1.1.0" + " && gh release create Foo-v1.1.0 --target bcdef123 --generate-notes" + ) in body + + @patch("tagbot.action.repo.logger") def test_create_release_handles_403_error(logger): """Test that 403 permission error logs appropriate message and re-raises."""