Merge lp:~jelmer/brz/fork-disabled into lp:brz/3.1

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/fork-disabled
Merge into: lp:brz/3.1
Diff against target: 27 lines (+10/-0)
1 file modified
breezy/plugins/gitlab/hoster.py (+10/-0)
To merge this branch: bzr merge lp:~jelmer/brz/fork-disabled
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+386359@code.launchpad.net

Description of the change

Raise proper exception when forking isn't available for a project.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/plugins/gitlab/hoster.py'
--- breezy/plugins/gitlab/hoster.py 2020-06-22 02:21:47 +0000
+++ breezy/plugins/gitlab/hoster.py 2020-06-25 00:10:31 +0000
@@ -100,6 +100,14 @@
100 self.error = error100 self.error = error
101101
102102
103class ForkingDisabled(errors.BzrError):
104
105 _fmt = ("Forking on project %(project)s is disabled.")
106
107 def __init__(self, project):
108 self.project = project
109
110
103class MergeRequestExists(Exception):111class MergeRequestExists(Exception):
104 """Raised when a merge requests already exists."""112 """Raised when a merge requests already exists."""
105113
@@ -356,6 +364,8 @@
356 def _fork_project(self, project_name, timeout=50, interval=5):364 def _fork_project(self, project_name, timeout=50, interval=5):
357 path = 'projects/%s/fork' % urlutils.quote(str(project_name), '')365 path = 'projects/%s/fork' % urlutils.quote(str(project_name), '')
358 response = self._api_request('POST', path)366 response = self._api_request('POST', path)
367 if response.status == 404:
368 raise ForkingDisabled(project_name)
359 if response.status not in (200, 201):369 if response.status not in (200, 201):
360 raise errors.InvalidHttpResponse(path, response.text)370 raise errors.InvalidHttpResponse(path, response.text)
361 # The response should be valid JSON, but let's ignore it371 # The response should be valid JSON, but let's ignore it

Subscribers

People subscribed via source and target branches