mirror of https://github.com/zulip/zulip.git
integration: Move assignee message to the end for git integrations.
Previously, the assignee message would stick around in the middle of the event message. This doesn't look as good as if we put it to the end of the event message. These changes does just that and move the assignee messages towards the end of the event message to make it look better and cleaner for the readers.
This commit is contained in:
parent
d564025d6a
commit
4dc85dddc1
|
@ -190,6 +190,13 @@ def get_pull_request_event_message(
|
|||
else:
|
||||
main_message = PULL_REQUEST_OR_ISSUE_MESSAGE_TEMPLATE.format(**kwargs)
|
||||
|
||||
if target_branch and base_branch:
|
||||
branch_info = PULL_REQUEST_BRANCH_INFO_TEMPLATE.format(
|
||||
target=target_branch,
|
||||
base=base_branch,
|
||||
)
|
||||
main_message = f"{main_message} {branch_info}"
|
||||
|
||||
if assignees:
|
||||
assignees_string = ""
|
||||
if len(assignees) == 1:
|
||||
|
@ -210,13 +217,6 @@ def get_pull_request_event_message(
|
|||
assignee_info = PULL_REQUEST_OR_ISSUE_ASSIGNEE_INFO_TEMPLATE.format(assignee=assignee)
|
||||
main_message = f"{main_message} {assignee_info}"
|
||||
|
||||
if target_branch and base_branch:
|
||||
branch_info = PULL_REQUEST_BRANCH_INFO_TEMPLATE.format(
|
||||
target=target_branch,
|
||||
base=base_branch,
|
||||
)
|
||||
main_message = f"{main_message} {branch_info}"
|
||||
|
||||
punctuation = ":" if message else "."
|
||||
if (
|
||||
assignees
|
||||
|
|
|
@ -116,7 +116,7 @@ class Bitbucket2HookTests(WebhookTestCase):
|
|||
self.check_webhook("issue_commented", expected_topic, expected_message)
|
||||
|
||||
def test_bitbucket2_on_pull_request_created_event(self) -> None:
|
||||
expected_message = "Tomasz created [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) (assigned to Tomasz Kolek) from `new-branch` to `master`:\n\n~~~ quote\ndescription\n~~~"
|
||||
expected_message = "Tomasz created [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) from `new-branch` to `master` (assigned to Tomasz Kolek):\n\n~~~ quote\ndescription\n~~~"
|
||||
self.check_webhook(
|
||||
"pull_request_created_or_updated",
|
||||
TOPIC_PR_EVENTS,
|
||||
|
@ -125,7 +125,7 @@ class Bitbucket2HookTests(WebhookTestCase):
|
|||
)
|
||||
|
||||
def test_bitbucket2_on_pull_request_created_without_reviewer_username_event(self) -> None:
|
||||
expected_message = "Tomasz created [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) (assigned to Tomasz Kolek) from `new-branch` to `master`:\n\n~~~ quote\ndescription\n~~~"
|
||||
expected_message = "Tomasz created [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) from `new-branch` to `master` (assigned to Tomasz Kolek):\n\n~~~ quote\ndescription\n~~~"
|
||||
self.check_webhook(
|
||||
"pull_request_created_or_updated_without_username",
|
||||
TOPIC_PR_EVENTS,
|
||||
|
@ -136,7 +136,7 @@ class Bitbucket2HookTests(WebhookTestCase):
|
|||
def test_bitbucket2_on_pull_request_created_with_custom_topic_in_url(self) -> None:
|
||||
self.url = self.build_webhook_url(topic="notifications")
|
||||
expected_topic = "notifications"
|
||||
expected_message = "Tomasz created [PR #1 new commit](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) (assigned to Tomasz Kolek) from `new-branch` to `master`:\n\n~~~ quote\ndescription\n~~~"
|
||||
expected_message = "Tomasz created [PR #1 new commit](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) from `new-branch` to `master` (assigned to Tomasz Kolek):\n\n~~~ quote\ndescription\n~~~"
|
||||
self.check_webhook(
|
||||
"pull_request_created_or_updated",
|
||||
expected_topic,
|
||||
|
|
|
@ -51,7 +51,7 @@ class GiteaHookTests(WebhookTestCase):
|
|||
|
||||
def test_pull_request_assigned(self) -> None:
|
||||
expected_topic = "test / PR #1906 test 2"
|
||||
expected_message = """kostekIV assigned [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) (assigned to kostekIV) from `d` to `master`."""
|
||||
expected_message = """kostekIV assigned [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) from `d` to `master` (assigned to kostekIV)."""
|
||||
self.check_webhook("pull_request__assigned", expected_topic, expected_message)
|
||||
|
||||
def test_issues_opened(self) -> None:
|
||||
|
|
|
@ -162,7 +162,7 @@ class GitHubWebhookTest(WebhookTestCase):
|
|||
|
||||
def test_pull_request_opened_with_preassigned_assignee_msg(self) -> None:
|
||||
expected_topic = "Scheduler / PR #4 Improve README"
|
||||
expected_message = "eeshangarg opened [PR #4](https://github.com/eeshangarg/Scheduler/pull/4) (assigned to eeshangarg) from `eeshangarg:improve-readme-2` to `eeshangarg:master`."
|
||||
expected_message = "eeshangarg opened [PR #4](https://github.com/eeshangarg/Scheduler/pull/4) from `eeshangarg:improve-readme-2` to `eeshangarg:master` (assigned to eeshangarg)."
|
||||
self.check_webhook(
|
||||
"pull_request__opened_with_preassigned_assignee", expected_topic, expected_message
|
||||
)
|
||||
|
|
|
@ -304,7 +304,7 @@ class GitlabHookTests(WebhookTestCase):
|
|||
|
||||
def test_merge_request_created_with_assignee_event_message(self) -> None:
|
||||
expected_topic = "my-awesome-project / MR #3 New Merge Request"
|
||||
expected_message = "Tomasz Kolek created [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3) (assigned to Tomasz Kolek) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~"
|
||||
expected_message = "Tomasz Kolek created [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3) from `tomek` to `master` (assigned to Tomasz Kolek):\n\n~~~ quote\ndescription of merge request\n~~~"
|
||||
self.check_webhook(
|
||||
"merge_request_hook__merge_request_created_with_assignee",
|
||||
expected_topic,
|
||||
|
@ -314,7 +314,7 @@ class GitlabHookTests(WebhookTestCase):
|
|||
def test_merge_request_created_with_multiple_assignees_event_message(self) -> None:
|
||||
expected_topic = "Demo Project / MR #1 Make a trivial change to the README."
|
||||
expected_message = """
|
||||
Hemanth V. Alluri created [MR #1](https://gitlab.com/Hypro999/demo-project/-/merge_requests/1) (assigned to Hemanth V. Alluri and Hemanth V. Alluri) from `devel` to `master`:
|
||||
Hemanth V. Alluri created [MR #1](https://gitlab.com/Hypro999/demo-project/-/merge_requests/1) from `devel` to `master` (assigned to Hemanth V. Alluri and Hemanth V. Alluri):
|
||||
|
||||
~~~ quote
|
||||
A trivial change that should probably be ignored.
|
||||
|
@ -576,7 +576,7 @@ A trivial change that should probably be ignored.
|
|||
|
||||
def test_system_merge_request_created_with_assignee_event_message(self) -> None:
|
||||
expected_topic = "my-awesome-project / MR #3 New Merge Request"
|
||||
expected_message = "Tomasz Kolek created [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3) (assigned to Tomasz Kolek) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~"
|
||||
expected_message = "Tomasz Kolek created [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3) from `tomek` to `master` (assigned to Tomasz Kolek):\n\n~~~ quote\ndescription of merge request\n~~~"
|
||||
self.check_webhook(
|
||||
"system_hook__merge_request_created_with_assignee", expected_topic, expected_message
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue