/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/git/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2019-07-07 17:22:07 UTC
  • mfrom: (7363 work)
  • mto: This revision was merged to the branch mainline in revision 7378.
  • Revision ID: jelmer@jelmer.uk-20190707172207-nnugeuwvxsxo62wa
merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    __version__ as breezy_version,
34
34
    errors as brz_errors,
35
35
    trace,
 
36
    urlutils,
36
37
    version_info,
37
38
    )
38
39
 
112
113
                external_url.startswith("https:")):
113
114
            # Already handled by RemoteGitProber
114
115
            raise brz_errors.NotBranchError(path=transport.base)
115
 
        from .. import urlutils
116
116
        if urlutils.split(transport.base)[1] == ".git":
117
117
            raise brz_errors.NotBranchError(path=transport.base)
118
118
        if not transport.has_any(['objects', '.git/objects', '.git']):
142
142
    return "git/Breezy/%s" % breezy_version
143
143
 
144
144
 
 
145
def is_github_url(url):
 
146
    (scheme, user, password, host, port,
 
147
     path) = urlutils.parse_url(url)
 
148
    return host == "github.com"
 
149
 
 
150
 
145
151
class RemoteGitProber(Prober):
146
152
 
147
153
    def probe_http_transport(self, transport):
149
155
        # breezy.git, since it's called for every repository that's
150
156
        # accessed over HTTP, whether it's Git, Bzr or something else.
151
157
        # Importing Dulwich and the other support code adds unnecessray slowdowns.
152
 
        from .. import urlutils
153
158
        base_url, _ = urlutils.split_segment_parameters(
154
159
            transport.external_url())
155
160
        url = urlutils.URL.from_string(base_url)
156
161
        url.user = url.quoted_user = None
157
162
        url.password = url.quoted_password = None
 
163
        host = url.host
158
164
        url = urlutils.join(str(url), "info/refs") + "?service=git-upload-pack"
159
165
        headers = {"Content-Type": "application/x-git-upload-pack-request",
160
166
                   "Accept": "application/x-git-upload-pack-result",
161
167
                   }
162
 
        (scheme, user, password, host, port,
163
 
         path) = urlutils.parse_url(url)
164
 
        if host == "github.com":
 
168
        if is_github_url(url):
165
169
            # GitHub requires we lie.
166
170
            # https://github.com/dulwich/dulwich/issues/562
167
171
            headers["User-Agent"] = user_agent_for_github()