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):
161
161
pass
162
162
163
163
164
+ class GitlabMRApprovalError (GitlabOperationError ):
165
+ pass
166
+
164
167
class GitlabMRClosedError (GitlabOperationError ):
165
168
pass
166
169
Original file line number Diff line number Diff line change @@ -2132,6 +2132,30 @@ def changes(self, **kwargs):
2132
2132
path = '%s/%s/changes' % (self .manager .path , self .get_id ())
2133
2133
return self .manager .gitlab .http_get (path , ** kwargs )
2134
2134
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
+
2135
2159
@cli .register_custom_action ('ProjectMergeRequest' , tuple (),
2136
2160
('merge_commit_message' ,
2137
2161
'should_remove_source_branch' ,
You can’t perform that action at this time.
0 commit comments