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."""