Merge lp:~jelmer/brz/gitlab-show-400 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/gitlab-show-400
Merge into: lp:brz/3.1
Diff against target: 51 lines (+14/-2)
2 files modified
breezy/plugins/gitlab/hoster.py (+13/-1)
breezy/transport/http/urllib.py (+1/-1)
To merge this branch: bzr merge lp:~jelmer/brz/gitlab-show-400
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+400293@code.launchpad.net

Commit message

Handle 400s when creating gitlab merge requests.

Description of the change

Handle 400s when creating gitlab merge requests.

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
1=== modified file 'breezy/plugins/gitlab/hoster.py'
2--- breezy/plugins/gitlab/hoster.py 2021-03-26 18:37:14 +0000
3+++ breezy/plugins/gitlab/hoster.py 2021-03-27 10:45:12 +0000
4@@ -79,6 +79,16 @@
5 self.url = url
6
7
8+class GitLabError(errors.BzrError):
9+
10+ _fmt = "GitLab error: %(error)s"
11+
12+ def __init__(self, error, full_response):
13+ errors.BzrError.__init__(self)
14+ self.error = error
15+ self.full_response = full_response
16+
17+
18 class GitLabUnprocessable(errors.BzrError):
19
20 _fmt = "GitLab can not process request: %(error)s."
21@@ -562,6 +572,8 @@
22 if labels:
23 fields['labels'] = labels
24 response = self._api_request('POST', path, fields=fields)
25+ if response.status == 400:
26+ raise GitLabError(data.get('message'), data)
27 if response.status == 403:
28 raise errors.PermissionDenied(response.text)
29 if response.status == 409:
30@@ -669,7 +681,7 @@
31 if response.status == 200:
32 self._current_user = json.loads(response.data)
33 return
34- if response == 401:
35+ if response.status == 401:
36 if json.loads(response.data) == {"message": "401 Unauthorized"}:
37 raise GitLabLoginMissing()
38 else:
39
40=== modified file 'breezy/transport/http/urllib.py'
41--- breezy/transport/http/urllib.py 2020-12-26 18:24:48 +0000
42+++ breezy/transport/http/urllib.py 2021-03-27 10:45:12 +0000
43@@ -181,7 +181,7 @@
44 """
45
46 # Some responses have bodies in which we have no interest
47- _body_ignored_responses = [301, 302, 303, 307, 308, 400, 401, 403, 404, 501]
48+ _body_ignored_responses = [301, 302, 303, 307, 308, 403, 404, 501]
49
50 # in finish() below, we may have to discard several MB in the worst
51 # case. To avoid buffering that much, we read and discard by chunks

Subscribers

People subscribed via source and target branches