Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions tagbot/action/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down Expand Up @@ -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

Expand Down
23 changes: 23 additions & 0 deletions test/action/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
Loading