Skip to content

Commit

Permalink
Merge patch from Sam Vilain to pass arguments to get_transport_and_pa…
Browse files Browse the repository at this point in the history
…th on to the constructor of the transport.
  • Loading branch information
jelmer committed Mar 1, 2012
2 parents 4df8b08 + d0a0f9c commit b575ecd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
``~/.gitconfig``, to prevent test isolation issues.
(Jelmer Vernooij, #920330)

FEATURES

* Additional arguments to get_transport_and_path are now passed
on to the constructor of the transport. (Sam Vilain)

0.8.3 2012-01-21

FEATURES
Expand Down
16 changes: 10 additions & 6 deletions dulwich/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,31 +762,35 @@ def fetch_pack(self, path, determine_wants, graph_walker, pack_data,
return refs


def get_transport_and_path(uri):
def get_transport_and_path(uri, **kwargs):
"""Obtain a git client from a URI or path.
:param uri: URI or path
:param thin_packs: Whether or not thin packs should be retrieved
:param report_activity: Optional callback for reporting transport
activity.
:return: Tuple with client instance and relative path.
"""
parsed = urlparse.urlparse(uri)
if parsed.scheme == 'git':
return TCPGitClient(parsed.hostname, port=parsed.port), parsed.path
return (TCPGitClient(parsed.hostname, port=parsed.port, **kwargs),
parsed.path)
elif parsed.scheme == 'git+ssh':
return SSHGitClient(parsed.hostname, port=parsed.port,
username=parsed.username), parsed.path
username=parsed.username, **kwargs), parsed.path
elif parsed.scheme in ('http', 'https'):
return HttpGitClient(urlparse.urlunparse(parsed)), parsed.path

if parsed.scheme and not parsed.netloc:
# SSH with no user@, zero or one leading slash.
return SSHGitClient(parsed.scheme), parsed.path
return SSHGitClient(parsed.scheme, **kwargs), parsed.path
elif parsed.scheme:
raise ValueError('Unknown git protocol scheme: %s' % parsed.scheme)
elif '@' in parsed.path and ':' in parsed.path:
# SSH with user@host:foo.
user_host, path = parsed.path.split(':')
user, host = user_host.rsplit('@')
return SSHGitClient(host, username=user), path
return SSHGitClient(host, username=user, **kwargs), path

# Otherwise, assume it's a local path.
return SubprocessGitClient(), uri
return SubprocessGitClient(**kwargs), uri

0 comments on commit b575ecd

Please sign in to comment.