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

Appearance settings

Commit 3520b45

Browse filesBrowse files
jeroen92max-wittig
authored andcommitted
feat: add mr rebase method
1 parent c8a7e31 commit 3520b45
Copy full SHA for 3520b45

File tree

Expand file treeCollapse file tree

4 files changed

+27
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+27
-0
lines changed
Open diff view settings
Collapse file

‎docs/gl_objects/mrs.rst‎

Copy file name to clipboardExpand all lines: docs/gl_objects/mrs.rst
+4Lines changed: 4 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,7 @@ Reset spent time for a merge request::
181181
Get user agent detail for the issue (admin only)::
182182

183183
detail = issue.user_agent_detail()
184+
185+
Attempt to rebase an MR::
186+
187+
mr.rebase()
Collapse file

‎gitlab/exceptions.py‎

Copy file name to clipboardExpand all lines: gitlab/exceptions.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ class GitlabMRApprovalError(GitlabOperationError):
173173
pass
174174

175175

176+
class GitlabMRRebaseError(GitlabOperationError):
177+
pass
178+
179+
176180
class GitlabMRClosedError(GitlabOperationError):
177181
pass
178182

Collapse file

‎gitlab/v4/objects.py‎

Copy file name to clipboardExpand all lines: gitlab/v4/objects.py
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2712,6 +2712,22 @@ def unapprove(self, **kwargs):
27122712
server_data = self.manager.gitlab.http_post(path, post_data=data, **kwargs)
27132713
self._update_attrs(server_data)
27142714

2715+
@cli.register_custom_action("ProjectMergeRequest")
2716+
@exc.on_http_error(exc.GitlabMRRebaseError)
2717+
def rebase(self, **kwargs):
2718+
"""Attempt to rebase the source branch onto the target branch
2719+
2720+
Args:
2721+
**kwargs: Extra options to send to the server (e.g. sudo)
2722+
2723+
Raises:
2724+
GitlabAuthenticationError: If authentication is not correct
2725+
GitlabMRRebaseError: If rebasing failed
2726+
"""
2727+
path = "%s/%s/rebase" % (self.manager.path, self.get_id())
2728+
data = {}
2729+
return self.manager.gitlab.http_put(path, post_data=data, **kwargs)
2730+
27152731
@cli.register_custom_action(
27162732
"ProjectMergeRequest",
27172733
tuple(),
Collapse file

‎tools/python_test_v4.py‎

Copy file name to clipboardExpand all lines: tools/python_test_v4.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,9 @@
686686
event = mr.resourcelabelevents.get(events[0].id)
687687
assert event
688688

689+
# rebasing
690+
assert mr.rebase()
691+
689692
# basic testing: only make sure that the methods exist
690693
mr.commits()
691694
mr.changes()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.