Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

integration: Remove branch names from Gitea edited PR event.

Joelute946b4e73ca6d
diff --git a/zerver/webhooks/gitea/tests.py b/zerver/webhooks/gitea/tests.py
index 4e6610be270..9decd6185e7 100644
--- a/zerver/webhooks/gitea/tests.py
+++ b/zerver/webhooks/gitea/tests.py
@@ -36,7 +36,9 @@ class GiteaHookTests(WebhookTestCase):
def test_pull_request_edited(self) -> None:
expected_topic = "test / PR #1906 test 2"
- expected_message = """kostekIV edited [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) from `d` to `master`."""
+ expected_message = (
+ """kostekIV edited [PR #5](https://try.gitea.io/kostekIV/test/pulls/5)."""
+ )
self.check_webhook("pull_request__edited", expected_topic, expected_message)
def test_pull_request_reopened(self) -> None:
diff --git a/zerver/webhooks/gitea/view.py b/zerver/webhooks/gitea/view.py
index f58deba9abe..dae6ceae47c 100644
--- a/zerver/webhooks/gitea/view.py
+++ b/zerver/webhooks/gitea/view.py
@@ -28,8 +28,11 @@ def format_pull_request_event(payload: WildValue, include_title: bool = False) -
url = payload["pull_request"]["html_url"].tame(check_string)
number = payload["pull_request"]["number"].tame(check_int)
- target_branch = payload["pull_request"]["head"]["ref"].tame(check_string)
- base_branch = payload["pull_request"]["base"]["ref"].tame(check_string)
+ target_branch = None
+ base_branch = None
+ if action != "edited":
+ target_branch = payload["pull_request"]["head"]["ref"].tame(check_string)
+ base_branch = payload["pull_request"]["base"]["ref"].tame(check_string)
title = payload["pull_request"]["title"].tame(check_string) if include_title else None
stringified_assignee = assignee["login"].tame(check_string) if assignee else None