| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -170,6 +170,10 @@ class GitlabMRForbiddenError(GitlabOperationError): | |||
| 170 | 170 | pass | |
| 171 | 171 | ||
| 172 | 172 | ||
| 173 | + class GitlabMRApprovalError(GitlabOperationError): | ||
| 174 | + pass | ||
| 175 | + | ||
| 176 | + | ||
| 173 | 177 | class GitlabMRClosedError(GitlabOperationError): | |
| 174 | 178 | pass | |
| 175 | 179 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2277,23 +2277,46 @@ def changes(self, **kwargs): | |||
| 2277 | 2277 | path = '%s/%s/changes' % (self.manager.path, self.get_id()) | |
| 2278 | 2278 | return self.manager.gitlab.http_get(path, **kwargs) | |
| 2279 | 2279 | ||
| 2280 | - @cli.register_custom_action('ProjectMergeRequest') | ||
| 2281 | - @exc.on_http_error(exc.GitlabListError) | ||
| 2282 | - def pipelines(self, **kwargs): | ||
| 2283 | - """List the merge request pipelines. | ||
| 2280 | + @cli.register_custom_action('ProjectMergeRequest', tuple(), ('sha')) | ||
| 2281 | + @exc.on_http_error(exc.GitlabMRApprovalError) | ||
| 2282 | + def approve(self, sha=None, **kwargs): | ||
| 2283 | + """Approve the merge request. | ||
| 2284 | 2284 | ||
| 2285 | 2285 | Args: | |
| 2286 | + sha (str): Head SHA of MR | ||
| 2286 | 2287 | **kwargs: Extra options to send to the server (e.g. sudo) | |
| 2287 | 2288 | ||
| 2288 | 2289 | Raises: | |
| 2289 | 2290 | GitlabAuthenticationError: If authentication is not correct | |
| 2290 | - GitlabListError: If the list could not be retrieved | ||
| 2291 | + GitlabMRApprovalError: If the approval failed | ||
| 2292 | + """ | ||
| 2293 | + path = '%s/%s/approve' % (self.manager.path, self.get_id()) | ||
| 2294 | + data = {} | ||
| 2295 | + if sha: | ||
| 2296 | + data['sha'] = sha | ||
| 2291 | 2297 | ||
| 2292 | - Returns: | ||
| 2293 | - RESTObjectList: List of changes | ||
| 2298 | + server_data = self.manager.gitlab.http_post(path, post_data=data, | ||
| 2299 | + **kwargs) | ||
| 2300 | + self._update_attrs(server_data) | ||
| 2301 | + | ||
| 2302 | + @cli.register_custom_action('ProjectMergeRequest') | ||
| 2303 | + @exc.on_http_error(exc.GitlabMRApprovalError) | ||
| 2304 | + def unapprove(self, **kwargs): | ||
| 2305 | + """Unapprove the merge request. | ||
| 2306 | + | ||
| 2307 | + Args: | ||
| 2308 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 2309 | + | ||
| 2310 | + Raises: | ||
| 2311 | + GitlabAuthenticationError: If authentication is not correct | ||
| 2312 | + GitlabMRApprovalError: If the unapproval failed | ||
| 2294 | 2313 | """ | |
| 2295 | - path = '%s/%s/pipelines' % (self.manager.path, self.get_id()) | ||
| 2296 | - return self.manager.gitlab.http_get(path, **kwargs) | ||
| 2314 | + path = '%s/%s/unapprove' % (self.manager.path, self.get_id()) | ||
| 2315 | + data = {} | ||
| 2316 | + | ||
| 2317 | + server_data = self.manager.gitlab.http_post(path, post_data=data, | ||
| 2318 | + **kwargs) | ||
| 2319 | + self._update_attrs(server_data) | ||
| 2297 | 2320 | ||
| 2298 | 2321 | @cli.register_custom_action('ProjectMergeRequest', tuple(), | |
| 2299 | 2322 | ('merge_commit_message', | |
| Back | FazBrowse Home | New Git URL |
0 commit comments