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 to Gogs edited PR event.

Joelute78a9d716ec9b
diff --git a/zerver/webhooks/gogs/tests.py b/zerver/webhooks/gogs/tests.py
index 6f2a1934d04..350033eecb4 100644
--- a/zerver/webhooks/gogs/tests.py
+++ b/zerver/webhooks/gogs/tests.py
@@ -85,7 +85,7 @@ class GogsHookTests(WebhookTestCase):
def test_pull_request_edited(self) -> None:
expected_topic = "test / PR #1349 Test"
- expected_message = """kostekIV edited [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`."""
+ expected_message = """kostekIV edited [PR #2](https://try.gogs.io/kostekIV/test/pulls/2)."""
self.check_webhook("pull_request__edited", expected_topic, expected_message)
def test_pull_request_assigned(self) -> None:
diff --git a/zerver/webhooks/gogs/view.py b/zerver/webhooks/gogs/view.py
index ecc6dd14cbb..51fb7d323e5 100644
--- a/zerver/webhooks/gogs/view.py
+++ b/zerver/webhooks/gogs/view.py
@@ -81,8 +81,11 @@ def format_pull_request_event(payload: WildValue, include_title: bool = False) -
action = payload["action"].tame(check_string)
url = payload["pull_request"]["html_url"].tame(check_string)
number = payload["pull_request"]["number"].tame(check_int)
- target_branch = payload["pull_request"]["head_branch"].tame(check_string)
- base_branch = payload["pull_request"]["base_branch"].tame(check_string)
+ target_branch = None
+ base_branch = None
+ if action != "edited":
+ target_branch = payload["pull_request"]["head_branch"].tame(check_string)
+ base_branch = payload["pull_request"]["base_branch"].tame(check_string)
title = payload["pull_request"]["title"].tame(check_string) if include_title else None
return get_pull_request_event_message(