mirror of https://github.com/zulip/zulip.git
integration: Modify branch names for Gitlab MR events.
This is a follow up to #24673, we want to modify every webhook events to follow the same pattern and consistency where branch name should only show on opened and merged events.
This commit is contained in:
parent
b65b94894f
commit
0a3fcbb649
|
@ -369,7 +369,7 @@ A trivial change that should probably be ignored.
|
|||
|
||||
def test_merge_request_updated_event_message(self) -> None:
|
||||
expected_topic = "my-awesome-project / MR #3 New Merge Request"
|
||||
expected_message = "Tomasz Kolek updated [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3) (assigned to Tomasz Kolek) from `tomek` to `master`:\n\n~~~ quote\nupdated desc\n~~~"
|
||||
expected_message = "Tomasz Kolek updated [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3) (assigned to Tomasz Kolek):\n\n~~~ quote\nupdated desc\n~~~"
|
||||
self.check_webhook(
|
||||
"merge_request_hook__merge_request_updated", expected_topic, expected_message
|
||||
)
|
||||
|
@ -383,7 +383,7 @@ A trivial change that should probably be ignored.
|
|||
|
||||
def test_merge_request_merged_event_message(self) -> None:
|
||||
expected_topic = "my-awesome-project / MR #3 New Merge Request"
|
||||
expected_message = "Tomasz Kolek merged [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3)."
|
||||
expected_message = "Tomasz Kolek merged [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3) from `tomek` to `master`."
|
||||
|
||||
self.check_webhook(
|
||||
"merge_request_hook__merge_request_merged", expected_topic, expected_message
|
||||
|
@ -589,7 +589,7 @@ A trivial change that should probably be ignored.
|
|||
|
||||
def test_system_merge_request_merged_event_message(self) -> None:
|
||||
expected_topic = "my-awesome-project / MR #3 New Merge Request"
|
||||
expected_message = "Tomasz Kolek merged [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3)."
|
||||
expected_message = "Tomasz Kolek merged [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3) from `tomek` to `master`."
|
||||
|
||||
self.check_webhook("system_hook__merge_request_merged", expected_topic, expected_message)
|
||||
|
||||
|
|
|
@ -132,11 +132,19 @@ def get_merge_request_updated_event_body(payload: WildValue, include_title: bool
|
|||
|
||||
def get_merge_request_event_body(payload: WildValue, action: str, include_title: bool) -> str:
|
||||
pull_request = payload["object_attributes"]
|
||||
target_branch = None
|
||||
base_branch = None
|
||||
if action == "merged":
|
||||
target_branch = pull_request["source_branch"].tame(check_string)
|
||||
base_branch = pull_request["target_branch"].tame(check_string)
|
||||
|
||||
return get_pull_request_event_message(
|
||||
get_issue_user_name(payload),
|
||||
action,
|
||||
pull_request["url"].tame(check_string),
|
||||
pull_request["iid"].tame(check_int),
|
||||
target_branch=target_branch,
|
||||
base_branch=base_branch,
|
||||
type="MR",
|
||||
title=payload["object_attributes"]["title"].tame(check_string) if include_title else None,
|
||||
)
|
||||
|
@ -151,8 +159,8 @@ def get_merge_request_open_or_updated_body(
|
|||
action,
|
||||
pull_request["url"].tame(check_string),
|
||||
pull_request["iid"].tame(check_int),
|
||||
pull_request["source_branch"].tame(check_string),
|
||||
pull_request["target_branch"].tame(check_string),
|
||||
pull_request["source_branch"].tame(check_string) if action == "created" else None,
|
||||
pull_request["target_branch"].tame(check_string) if action == "created" else None,
|
||||
pull_request["description"].tame(check_string),
|
||||
assignees=replace_assignees_username_with_name(get_assignees(payload)),
|
||||
type="MR",
|
||||
|
|
Loading…
Reference in New Issue