mirror of https://github.com/zulip/zulip.git
webhooks/gitlab: Support Merge Request Hook approved event type.
Such payloads are generated when a GitLab repository has merge request approvals enabled and a project member approves a merge request. Approving is not the same as merging.
This commit is contained in:
parent
44e6d9b54b
commit
8936d03f3a
|
@ -0,0 +1,120 @@
|
|||
{
|
||||
"object_kind":"merge_request",
|
||||
"user":{
|
||||
"name":"Eeshan Garg",
|
||||
"username":"eeshangargtest",
|
||||
"avatar_url":"https://secure.gravatar.com/avatar/36cf0dc28c5302bcd68119fcaaf4d4f3?s=80\u0026d=identicon"
|
||||
},
|
||||
"project":{
|
||||
"id":3319043,
|
||||
"name":"my-awesome-project",
|
||||
"description":"",
|
||||
"web_url":"https://gitlab.com/eeshangarg/my-awesome-project",
|
||||
"avatar_url":null,
|
||||
"git_ssh_url":"git@gitlab.com:eeshangarg/my-awesome-project.git",
|
||||
"git_http_url":"https://gitlab.com/eeshangarg/my-awesome-project.git",
|
||||
"namespace":"eeshangarg",
|
||||
"visibility_level":20,
|
||||
"path_with_namespace":"eeshangarg/my-awesome-project",
|
||||
"default_branch":"feature",
|
||||
"ci_config_path":null,
|
||||
"homepage":"https://gitlab.com/eeshangarg/my-awesome-project",
|
||||
"url":"git@gitlab.com:eeshangarg/my-awesome-project.git",
|
||||
"ssh_url":"git@gitlab.com:eeshangarg/my-awesome-project.git",
|
||||
"http_url":"https://gitlab.com/eeshangarg/my-awesome-project.git"
|
||||
},
|
||||
"object_attributes":{
|
||||
"assignee_id":null,
|
||||
"author_id":1129123,
|
||||
"created_at":"2017-05-31 03:27:26 UTC",
|
||||
"deleted_at":null,
|
||||
"description":"",
|
||||
"head_pipeline_id":null,
|
||||
"id":3673242,
|
||||
"iid":1,
|
||||
"last_edited_at":null,
|
||||
"last_edited_by_id":null,
|
||||
"merge_commit_sha":null,
|
||||
"merge_error":null,
|
||||
"merge_params":{
|
||||
"force_remove_source_branch":null
|
||||
},
|
||||
"merge_status":"can_be_merged",
|
||||
"merge_user_id":null,
|
||||
"merge_when_pipeline_succeeds":false,
|
||||
"milestone_id":null,
|
||||
"source_branch":"changes",
|
||||
"source_project_id":3319043,
|
||||
"state":"opened",
|
||||
"target_branch":"feature",
|
||||
"target_project_id":3319043,
|
||||
"time_estimate":0,
|
||||
"title":"Update the README with author name",
|
||||
"updated_at":"2017-12-18 00:39:44 UTC",
|
||||
"updated_by_id":null,
|
||||
"url":"https://gitlab.com/eeshangarg/my-awesome-project/merge_requests/1",
|
||||
"source":{
|
||||
"id":3319043,
|
||||
"name":"my-awesome-project",
|
||||
"description":"",
|
||||
"web_url":"https://gitlab.com/eeshangarg/my-awesome-project",
|
||||
"avatar_url":null,
|
||||
"git_ssh_url":"git@gitlab.com:eeshangarg/my-awesome-project.git",
|
||||
"git_http_url":"https://gitlab.com/eeshangarg/my-awesome-project.git",
|
||||
"namespace":"eeshangarg",
|
||||
"visibility_level":20,
|
||||
"path_with_namespace":"eeshangarg/my-awesome-project",
|
||||
"default_branch":"feature",
|
||||
"ci_config_path":null,
|
||||
"homepage":"https://gitlab.com/eeshangarg/my-awesome-project",
|
||||
"url":"git@gitlab.com:eeshangarg/my-awesome-project.git",
|
||||
"ssh_url":"git@gitlab.com:eeshangarg/my-awesome-project.git",
|
||||
"http_url":"https://gitlab.com/eeshangarg/my-awesome-project.git"
|
||||
},
|
||||
"target":{
|
||||
"id":3319043,
|
||||
"name":"my-awesome-project",
|
||||
"description":"",
|
||||
"web_url":"https://gitlab.com/eeshangarg/my-awesome-project",
|
||||
"avatar_url":null,
|
||||
"git_ssh_url":"git@gitlab.com:eeshangarg/my-awesome-project.git",
|
||||
"git_http_url":"https://gitlab.com/eeshangarg/my-awesome-project.git",
|
||||
"namespace":"eeshangarg",
|
||||
"visibility_level":20,
|
||||
"path_with_namespace":"eeshangarg/my-awesome-project",
|
||||
"default_branch":"feature",
|
||||
"ci_config_path":null,
|
||||
"homepage":"https://gitlab.com/eeshangarg/my-awesome-project",
|
||||
"url":"git@gitlab.com:eeshangarg/my-awesome-project.git",
|
||||
"ssh_url":"git@gitlab.com:eeshangarg/my-awesome-project.git",
|
||||
"http_url":"https://gitlab.com/eeshangarg/my-awesome-project.git"
|
||||
},
|
||||
"last_commit":{
|
||||
"id":"b1b2824f280e73c5f57c78da5f8eb3cd19990867",
|
||||
"message":"Update the README with author name\n",
|
||||
"timestamp":"2017-05-31T00:55:38-02:30",
|
||||
"url":"https://gitlab.com/eeshangarg/my-awesome-project/commit/b1b2824f280e73c5f57c78da5f8eb3cd19990867",
|
||||
"author":{
|
||||
"name":"Eeshan Garg",
|
||||
"email":"jerryguitarist@gmail.com"
|
||||
}
|
||||
},
|
||||
"work_in_progress":false,
|
||||
"total_time_spent":0,
|
||||
"human_total_time_spent":null,
|
||||
"human_time_estimate":null,
|
||||
"action":"approved"
|
||||
},
|
||||
"labels":[
|
||||
|
||||
],
|
||||
"changes":{
|
||||
|
||||
},
|
||||
"repository":{
|
||||
"name":"my-awesome-project",
|
||||
"url":"git@gitlab.com:eeshangarg/my-awesome-project.git",
|
||||
"description":"",
|
||||
"homepage":"https://gitlab.com/eeshangarg/my-awesome-project"
|
||||
}
|
||||
}
|
|
@ -227,6 +227,17 @@ class GitlabHookTests(WebhookTestCase):
|
|||
HTTP_X_GITLAB_EVENT="Merge Request Hook"
|
||||
)
|
||||
|
||||
def test_merge_request_approved_event_message(self) -> None:
|
||||
expected_subject = u"my-awesome-project / MR #1 Update the README with author ..."
|
||||
expected_message = u"Eeshan Garg approved [MR #1](https://gitlab.com/eeshangarg/my-awesome-project/merge_requests/1)"
|
||||
|
||||
self.send_and_test_stream_message(
|
||||
'merge_request_approved',
|
||||
expected_subject,
|
||||
expected_message,
|
||||
HTTP_X_GITLAB_EVENT="Merge Request Hook"
|
||||
)
|
||||
|
||||
def test_merge_request_updated_event_message(self) -> None:
|
||||
expected_subject = u"my-awesome-project / MR #3 New Merge Request"
|
||||
expected_message = u"Tomasz Kolek updated [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3)(assigned to Tomasz Kolek)\nfrom `tomek` to `master`\n\n~~~ quote\nupdated desc\n~~~"
|
||||
|
|
|
@ -248,6 +248,7 @@ EVENT_FUNCTION_MAPPER = {
|
|||
'Note Hook MergeRequest': get_commented_merge_request_event_body,
|
||||
'Note Hook Issue': get_commented_issue_event_body,
|
||||
'Note Hook Snippet': get_commented_snippet_event_body,
|
||||
'Merge Request Hook approved': partial(get_merge_request_event_body, action='approved'),
|
||||
'Merge Request Hook open': partial(get_merge_request_open_or_updated_body, action='created'),
|
||||
'Merge Request Hook update': get_merge_request_updated_event_body,
|
||||
'Merge Request Hook merge': partial(get_merge_request_event_body, action='merged'),
|
||||
|
|
Loading…
Reference in New Issue