summaryrefslogtreecommitdiff
path: root/gitlab/v4/objects.py
diff options
context:
space:
mode:
authorJoost Evertse <joustie@gmail.com>2019-01-14 15:22:20 +0100
committerJoost <joustie@gmail.com>2019-01-19 21:49:20 +0100
commit53f7de7bfe0056950a8e7271632da3f89e3ba3b3 (patch)
treec3f607edabedf0bc224cf5931a723fbc77e4f1df /gitlab/v4/objects.py
parentbdbec678b1df23fd57b2e3c538e3eeac8d236690 (diff)
downloadgitlab-53f7de7bfe0056950a8e7271632da3f89e3ba3b3.tar.gz
feat: Added approve & unapprove method for Mergerequests
Offical GitLab API supports this for GitLab EE
Diffstat (limited to 'gitlab/v4/objects.py')
-rw-r--r--gitlab/v4/objects.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index 9327e06..fdd02ae 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -2132,6 +2132,47 @@ class ProjectMergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin,
path = '%s/%s/changes' % (self.manager.path, self.get_id())
return self.manager.gitlab.http_get(path, **kwargs)
+ @cli.register_custom_action('ProjectMergeRequest', tuple(), ('sha'))
+ @exc.on_http_error(exc.GitlabMRApprovalError)
+ def approve(self, sha=None, **kwargs):
+ """Approve the merge request.
+
+ Args:
+ sha (str): Head SHA of MR
+ **kwargs: Extra options to send to the server (e.g. sudo)
+
+ Raises:
+ GitlabAuthenticationError: If authentication is not correct
+ GitlabMRApprovalError: If the approval failed
+ """
+ path = '%s/%s/approve' % (self.manager.path, self.get_id())
+ data = {}
+ if sha:
+ data['sha'] = sha
+
+ server_data = self.manager.gitlab.http_post(path, post_data=data,
+ **kwargs)
+ self._update_attrs(server_data)
+
+ @cli.register_custom_action('ProjectMergeRequest')
+ @exc.on_http_error(exc.GitlabMRApprovalError)
+ def unapprove(self, **kwargs):
+ """Unapprove the merge request.
+
+ Args:
+ **kwargs: Extra options to send to the server (e.g. sudo)
+
+ Raises:
+ GitlabAuthenticationError: If authentication is not correct
+ GitlabMRApprovalError: If the unapproval failed
+ """
+ path = '%s/%s/unapprove' % (self.manager.path, self.get_id())
+ data = {}
+
+ server_data = self.manager.gitlab.http_post(path, post_data=data,
+ **kwargs)
+ self._update_attrs(server_data)
+
@cli.register_custom_action('ProjectMergeRequest', tuple(),
('merge_commit_message',
'should_remove_source_branch',