Merge lp:~jelmer/brz/fix-git-http into lp:brz

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/fix-git-http
Merge into: lp:brz
Diff against target: 83 lines (+9/-10)
4 files modified
breezy/git/__init__.py (+4/-5)
breezy/git/remote.py (+4/-3)
breezy/plugins/propose/github.py (+0/-1)
breezy/transport/http/__init__.py (+1/-1)
To merge this branch: bzr merge lp:~jelmer/brz/fix-git-http
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+368582@code.launchpad.net

Commit message

Fix Git HTTP support.

Description of the change

Fix Git HTTP support.

This was broken after the recent changes to the HTTP API. Unfortunately we still don't have good tests for Git over HTTP.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/git/__init__.py'
2--- breezy/git/__init__.py 2019-05-20 02:22:53 +0000
3+++ breezy/git/__init__.py 2019-06-08 16:03:01 +0000
4@@ -164,19 +164,18 @@
5 if host == "github.com":
6 # GitHub requires we lie.
7 # https://github.com/dulwich/dulwich/issues/562
8- req.add_header("User-Agent", user_agent_for_github())
9+ headers["User-Agent"] = user_agent_for_github()
10 elif host == "bazaar.launchpad.net":
11 # Don't attempt Git probes against bazaar.launchpad.net; pad.lv/1744830
12 raise brz_errors.NotBranchError(transport.base)
13 resp = transport.request('GET', url, headers=headers)
14 if resp.status in (404, 405):
15 raise brz_errors.NotBranchError(transport.base)
16- else:
17- raise errors.InvalidHttpResponse(
18+ elif resp.status != 200:
19+ raise brz_errors.InvalidHttpResponse(
20 url, 'Unable to handle http code %d' % resp.status)
21
22- headers = resp.headers
23- ct = headers.get("Content-Type")
24+ ct = resp.getheader("Content-Type")
25 if ct is None:
26 raise brz_errors.NotBranchError(transport.base)
27 if ct.startswith("application/x-git"):
28
29=== modified file 'breezy/git/remote.py'
30--- breezy/git/remote.py 2019-06-06 22:22:47 +0000
31+++ breezy/git/remote.py 2019-06-08 16:03:01 +0000
32@@ -698,6 +698,7 @@
33
34 response = self.transport.request(
35 ('GET' if data is None else 'POST'),
36+ url,
37 body=data,
38 headers=headers, retries=8)
39
40@@ -721,15 +722,15 @@
41
42 def __init__(self, response):
43 self._response = response
44- self.status = response.code
45+ self.status = response.status
46 self.content_type = response.getheader("Content-Type")
47- self.redirect_location = response.geturl()
48+ self.redirect_location = response._actual.geturl()
49
50 def readlines(self):
51 return self._response.readlines()
52
53 def close(self):
54- self._response.close()
55+ pass
56
57 return WrapResponse(response), read
58
59
60=== modified file 'breezy/plugins/propose/github.py'
61--- breezy/plugins/propose/github.py 2019-06-03 23:26:04 +0000
62+++ breezy/plugins/propose/github.py 2019-06-08 16:03:01 +0000
63@@ -27,7 +27,6 @@
64 MergeProposalBuilder,
65 MergeProposalExists,
66 PrerequisiteBranchUnsupported,
67- CommitMessageUnsupported,
68 UnsupportedHoster,
69 )
70
71
72=== modified file 'breezy/transport/http/__init__.py'
73--- breezy/transport/http/__init__.py 2019-05-28 23:08:46 +0000
74+++ breezy/transport/http/__init__.py 2019-06-08 16:03:01 +0000
75@@ -2305,7 +2305,7 @@
76 headers={'Content-Type': 'application/octet-stream'})
77 if response.status not in (200, 403):
78 raise errors.InvalidHttpResponse(
79- url, 'Unexpected status %d' % response.status)
80+ abspath, 'Unexpected status %d' % response.status)
81 code = response.status
82 data = handle_response(
83 abspath, code, response.getheader, response)

Subscribers

People subscribed via source and target branches