diff options
author | Jeroen Schutrup <jschutrup@bol.com> | 2019-07-11 16:25:21 +0200 |
---|---|---|
committer | Max Wittig <max.wittig95@gmail.com> | 2019-07-21 13:13:38 +0200 |
commit | 3520b453f75c9727eafe8e997ee8274933c6f0fd (patch) | |
tree | 3e1c2fc2d885fa5e7b664f20d1412174b1ca6a06 | |
parent | c8a7e31cb57e3be7287ba237dbda7c4efa195b29 (diff) | |
download | gitlab-rebase-mr.tar.gz |
feat: add mr rebase methodrebase-mr
-rw-r--r-- | docs/gl_objects/mrs.rst | 4 | ||||
-rw-r--r-- | gitlab/exceptions.py | 4 | ||||
-rw-r--r-- | gitlab/v4/objects.py | 16 | ||||
-rw-r--r-- | tools/python_test_v4.py | 3 |
4 files changed, 27 insertions, 0 deletions
diff --git a/docs/gl_objects/mrs.rst b/docs/gl_objects/mrs.rst index b3b5e07..a3e3fa0 100644 --- a/docs/gl_objects/mrs.rst +++ b/docs/gl_objects/mrs.rst @@ -181,3 +181,7 @@ Reset spent time for a merge request:: Get user agent detail for the issue (admin only):: detail = issue.user_agent_detail() + +Attempt to rebase an MR:: + + mr.rebase() diff --git a/gitlab/exceptions.py b/gitlab/exceptions.py index 449b6f0..d644e0f 100644 --- a/gitlab/exceptions.py +++ b/gitlab/exceptions.py @@ -173,6 +173,10 @@ class GitlabMRApprovalError(GitlabOperationError): pass +class GitlabMRRebaseError(GitlabOperationError): + pass + + class GitlabMRClosedError(GitlabOperationError): pass diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index f72a145..c7edae6 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -2712,6 +2712,22 @@ class ProjectMergeRequest( 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.GitlabMRRebaseError) + def rebase(self, **kwargs): + """Attempt to rebase the source branch onto the target branch + + Args: + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabMRRebaseError: If rebasing failed + """ + path = "%s/%s/rebase" % (self.manager.path, self.get_id()) + data = {} + return self.manager.gitlab.http_put(path, post_data=data, **kwargs) + @cli.register_custom_action( "ProjectMergeRequest", tuple(), diff --git a/tools/python_test_v4.py b/tools/python_test_v4.py index 358f2e4..61fcd43 100644 --- a/tools/python_test_v4.py +++ b/tools/python_test_v4.py @@ -686,6 +686,9 @@ assert events event = mr.resourcelabelevents.get(events[0].id) assert event +# rebasing +assert mr.rebase() + # basic testing: only make sure that the methods exist mr.commits() mr.changes() |