Commit 3520b453 authored by Jeroen Schutrup's avatar Jeroen Schutrup Committed by Max Wittig
Browse files

feat: add mr rebase method

parent c8a7e31c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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()
+4 −0
Original line number Diff line number Diff line
@@ -173,6 +173,10 @@ class GitlabMRApprovalError(GitlabOperationError):
    pass


class GitlabMRRebaseError(GitlabOperationError):
    pass


class GitlabMRClosedError(GitlabOperationError):
    pass

+16 −0
Original line number Diff line number Diff line
@@ -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(),
+3 −0
Original line number Diff line number Diff line
@@ -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()