This commit is contained in:
+2
-1
@@ -113,7 +113,8 @@ def publish(tag, prerelease, paths, api, repo, sha):
|
||||
and asset_digest(asset, api) == digests[name]
|
||||
for name, size in wanted.items()
|
||||
):
|
||||
check_tag_commit(api, repo, tag, sha)
|
||||
if not check_tag_commit(api, repo, tag, sha):
|
||||
raise ValueError("published release has no Git tag")
|
||||
print(f"Release {tag} is already complete")
|
||||
return
|
||||
if not release.get("draft"):
|
||||
|
||||
@@ -114,6 +114,20 @@ class ReleaseTest(unittest.TestCase):
|
||||
self.assertEqual(fake.uploads, 0)
|
||||
self.assertFalse(fake.release["draft"])
|
||||
|
||||
def test_complete_release_without_git_tag_is_not_accepted(self):
|
||||
with TemporaryDirectory() as directory:
|
||||
path = Path(directory) / "image.tar.gz"
|
||||
path.write_bytes(b"image")
|
||||
fake = FakeGitea()
|
||||
fake.release = {"id": 7, "tag_name": "v1.2.3",
|
||||
"target_commitish": "a" * 40, "draft": False}
|
||||
fake.assets = [{"id": 1, "name": path.name, "size": path.stat().st_size}]
|
||||
with patch.object(release, "request", fake.request), \
|
||||
patch.object(release, "asset_digest", lambda *_: release.sha256_file(path)):
|
||||
with self.assertRaisesRegex(ValueError, "no Git tag"):
|
||||
release.publish("v1.2.3", False, [path], "https://api",
|
||||
"org/repo", "a" * 40)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user