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

Proposed by Jelmer Vernooij on 2018-09-09
Status: Merged
Approved by: Jelmer Vernooij on 2018-09-13
Approved revision: 7098
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/fix-git-reidrecits
Merge into: lp:brz
Diff against target: 66 lines (+11/-4)
4 files modified
breezy/git/__init__.py (+3/-2)
breezy/git/dir.py (+6/-1)
breezy/git/remote.py (+1/-0)
breezy/transport/http/__init__.py (+1/-1)
To merge this branch: bzr merge lp:~jelmer/brz/fix-git-reidrecits
Reviewer Review Type Date Requested Status
Martin Packman 2018-09-09 Approve on 2018-09-10
Review via email: mp+354534@code.launchpad.net

Commit message

Fix HTTP redirects for Git repositories.

Description of the change

Fix HTTP redirects for Git repositories.

To post a comment you must log in.
Martin Packman (gz) wrote :

Branch misspelt redirects, but attribute has it correct per the _urllib2_wrappers code.

review: Approve

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 2018-08-04 17:32:58 +0000
3+++ breezy/git/__init__.py 2018-09-13 00:20:52 +0000
4@@ -148,7 +148,9 @@
5 base_url, _ = urlutils.split_segment_parameters(transport.external_url())
6 url = urlutils.join(base_url, "info/refs") + "?service=git-upload-pack"
7 from ..transport.http import Request
8- headers = {"Content-Type": "application/x-git-upload-pack-request"}
9+ headers = {"Content-Type": "application/x-git-upload-pack-request",
10+ "Accept": "application/x-git-upload-pack-result",
11+ }
12 req = Request('GET', url, accepted_errors=[200, 403, 404, 405],
13 headers=headers)
14 (scheme, user, password, host, port, path) = urlutils.parse_url(req.get_full_url())
15@@ -158,7 +160,6 @@
16 elif host == "bazaar.launchpad.net":
17 # Don't attempt Git probes against bazaar.launchpad.net; pad.lv/1744830
18 raise bzr_errors.NotBranchError(transport.base)
19- req.follow_redirections = True
20 resp = transport._perform(req)
21 if resp.code in (404, 405):
22 raise bzr_errors.NotBranchError(transport.base)
23
24=== modified file 'breezy/git/dir.py'
25--- breezy/git/dir.py 2018-08-04 17:32:58 +0000
26+++ breezy/git/dir.py 2018-09-13 00:20:52 +0000
27@@ -341,8 +341,13 @@
28
29 """
30 from .transportgit import TransportRepo
31- gitrepo = TransportRepo(transport, self.bare,
32+ def _open(transport):
33+ return TransportRepo(transport, self.bare,
34 refs_text=getattr(self, "_refs_text", None))
35+ def redirected(transport, e, redirection_notice):
36+ trace.note(redirection_notice)
37+ return transport._redirected_to(e.source, e.target)
38+ gitrepo = do_catching_redirections(_open, transport, redirected)
39 if not gitrepo._controltransport.has('HEAD'):
40 raise bzr_errors.NotBranchError(path=transport.base)
41 return LocalGitDir(transport, gitrepo, self)
42
43=== modified file 'breezy/git/remote.py'
44--- breezy/git/remote.py 2018-09-11 19:38:39 +0000
45+++ breezy/git/remote.py 2018-09-13 00:20:52 +0000
46@@ -644,6 +644,7 @@
47 ('GET' if data is None else 'POST'),
48 url, data, headers,
49 accepted_errors=[200, 404])
50+ request.follow_redirections = True
51
52 response = self.transport._perform(request)
53
54
55=== modified file 'breezy/transport/http/__init__.py'
56--- breezy/transport/http/__init__.py 2018-08-01 19:37:07 +0000
57+++ breezy/transport/http/__init__.py 2018-09-13 00:20:52 +0000
58@@ -611,7 +611,7 @@
59 # determine the excess tail - the relative path that was in
60 # the original request but not part of this transports' URL.
61 excess_tail = parsed_source.path[pl:].strip("/")
62- if not target.endswith(excess_tail):
63+ if not parsed_target.path.endswith(excess_tail):
64 # The final part of the url has been renamed, we can't handle the
65 # redirection.
66 return None

Subscribers

People subscribed via source and target branches