File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,9 @@ class GitlabMRForbiddenError(GitlabOperationError):
161161 pass
162162
163163
164+ class GitlabMRApprovalError (GitlabOperationError ):
165+ pass
166+
164167class GitlabMRClosedError (GitlabOperationError ):
165168 pass
166169
Original file line number Diff line number Diff line change @@ -2132,6 +2132,30 @@ def changes(self, **kwargs):
21322132 path = '%s/%s/changes' % (self .manager .path , self .get_id ())
21332133 return self .manager .gitlab .http_get (path , ** kwargs )
21342134
2135+ @cli .register_custom_action ('ProjectMergeRequest' , tuple (), ('sha' ))
2136+ @exc .on_http_error (exc .GitlabMRApprovalError )
2137+ def approve (self ,
2138+ sha ,
2139+ ** kwargs ):
2140+ """Approve the merge request.
2141+
2142+ Args:
2143+ sha (str): Head SHA of MR
2144+ **kwargs: Extra options to send to the server (e.g. sudo)
2145+
2146+ Raises:
2147+ GitlabAuthenticationError: If authentication is not correct
2148+ GitlabMRApprovalError: If the approval failed
2149+ """
2150+ path = '%s/%s/approve' % (self .manager .path , self .get_id ())
2151+ data = {}
2152+ if sha :
2153+ data ['sha' ] = sha
2154+
2155+ server_data = self .manager .gitlab .http_post (path , post_data = data ,
2156+ ** kwargs )
2157+ self ._update_attrs (server_data )
2158+
21352159 @cli .register_custom_action ('ProjectMergeRequest' , tuple (),
21362160 ('merge_commit_message' ,
21372161 'should_remove_source_branch' ,
You can’t perform that action at this time.
0 commit comments