Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Added approve method for Mergerequests#685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
max-wittig merged 2 commits intopython-gitlab:masterfromJoustie:master
Jan 21, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletionsgitlab/exceptions.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -170,6 +170,10 @@ class GitlabMRForbiddenError(GitlabOperationError):
pass


class GitlabMRApprovalError(GitlabOperationError):
pass


class GitlabMRClosedError(GitlabOperationError):
pass

Expand Down
41 changes: 32 additions & 9 deletionsgitlab/v4/objects.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2277,23 +2277,46 @@ def changes(self, **kwargs):
path = '%s/%s/changes' % (self.manager.path, self.get_id())
return self.manager.gitlab.http_get(path, **kwargs)

@cli.register_custom_action('ProjectMergeRequest')
@exc.on_http_error(exc.GitlabListError)
defpipelines(self, **kwargs):
"""List the merge request pipelines.
@cli.register_custom_action('ProjectMergeRequest', tuple(), ('sha'))
@exc.on_http_error(exc.GitlabMRApprovalError)
defapprove(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
GitlabListError: If the list could not be retrieved
GitlabMRApprovalError: If the approval failed
"""
path = '%s/%s/approve' % (self.manager.path, self.get_id())
data = {}
if sha:
data['sha'] = sha

Returns:
RESTObjectList: List of changes
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/pipelines' % (self.manager.path, self.get_id())
return self.manager.gitlab.http_get(path, **kwargs)
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',
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp