Merge lp:~jelmer/brz/git-http-username 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/git-http-username
Merge into: lp:brz
Diff against target: 39 lines (+12/-3)
2 files modified
breezy/git/__init__.py (+8/-1)
breezy/git/remote.py (+4/-2)
To merge this branch: bzr merge lp:~jelmer/brz/git-http-username
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+363182@code.launchpad.net

Description of the change

Strip username from URLs before passing them to httplib.

This fixes access to Git HTTP repositories with authentication, such as bitbucket.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Thanks! Should have a test that passes in a username.

review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Thanks. There is a long outstanding bug report about testing git over HTTP.

On 14 February 2019 11:53:08 GMT, Martin Packman <email address hidden> wrote:
>Review: Approve
>
>Thanks! Should have a test that passes in a username.
>--
>https://code.launchpad.net/~jelmer/brz/git-http-username/+merge/363182
>You are the owner of lp:~jelmer/brz/git-http-username.

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

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-11-16 12:25:18 +0000
3+++ breezy/git/__init__.py 2019-02-14 19:10:58 +0000
4@@ -145,10 +145,17 @@
5 class RemoteGitProber(Prober):
6
7 def probe_http_transport(self, transport):
8+ # This function intentionally doesn't use any of the support code under
9+ # breezy.git, since it's called for every repository that's
10+ # accessed over HTTP, whether it's Git, Bzr or something else.
11+ # Importing Dulwich and the other support code adds unnecessray slowdowns.
12 from .. import urlutils
13 base_url, _ = urlutils.split_segment_parameters(
14 transport.external_url())
15- url = urlutils.join(base_url, "info/refs") + "?service=git-upload-pack"
16+ url = urlutils.URL.from_string(base_url)
17+ url.user = url.quoted_user = None
18+ url.password = url.quoted_password = None
19+ url = urlutils.join(str(url), "info/refs") + "?service=git-upload-pack"
20 from ..transport.http import Request
21 headers = {"Content-Type": "application/x-git-upload-pack-request",
22 "Accept": "application/x-git-upload-pack-result",
23
24=== modified file 'breezy/git/remote.py'
25--- breezy/git/remote.py 2019-02-01 16:56:56 +0000
26+++ breezy/git/remote.py 2019-02-14 19:10:58 +0000
27@@ -660,8 +660,10 @@
28
29 def __init__(self, transport, *args, **kwargs):
30 self.transport = transport
31- super(BzrGitHttpClient, self).__init__(
32- transport.external_url(), *args, **kwargs)
33+ url = urlutils.URL.from_string(transport.external_url())
34+ url.user = url.quoted_user = None
35+ url.password = url.quoted_password = None
36+ super(BzrGitHttpClient, self).__init__(str(url), *args, **kwargs)
37
38 def _http_request(self, url, headers=None, data=None,
39 allow_compression=False):

Subscribers

People subscribed via source and target branches