diff --git a/tools/release/pr_discord.py b/tools/release/pr_discord.py index 84fe0265b..77a576208 100644 --- a/tools/release/pr_discord.py +++ b/tools/release/pr_discord.py @@ -158,7 +158,7 @@ def sync(mode, repo, number, discord, sha="", apk="", release=""): "allowed_mentions": {"parse": []}, "flags": 4}) return try: - commit = github(f"repos/{repo}/commits/{sha}") + commit = github(f"repos/{repo}/commits/{sha}") or {} except RuntimeError: commit = {} commit_message = (commit.get("commit") or {}).get("message", "") diff --git a/tools/tests/test_pr_discord.py b/tools/tests/test_pr_discord.py index 2a1394d3b..a80efdff7 100644 --- a/tools/tests/test_pr_discord.py +++ b/tools/tests/test_pr_discord.py @@ -250,6 +250,13 @@ class PrDiscordTest(unittest.TestCase): self.assertEqual("POST", self.discord.request.call_args.args[0]) self.assertNotIn("Latest commit:", self.discord.request.call_args.args[2]["content"]) + def test_empty_commit_response_does_not_block_announcement(self): + self.github.side_effect = lambda path, method="GET", body=None: ( + self.pull if "/pulls/" in path else None if "/commits/" in path else self.comment) + self.publish() + self.assertEqual("POST", self.discord.request.call_args.args[0]) + self.assertNotIn("Latest commit:", self.discord.request.call_args.args[2]["content"]) + original_report = module.report_comment