comparison hggit/git_handler.py @ 261:29e5072ddaab

Handle normal relative SSH paths (i.e for heroku and gitosis) as well as github style paths.
author Lincoln Stoll <lstoll@lstoll.net>
date Mon, 19 Oct 2009 17:48:07 +0200
parents 6977263c4d80
children 5347d8c94021 c2d6b1093e7e
comparison
equal deleted inserted replaced
260:6977263c4d80 261:29e5072ddaab
837 837
838 def get_transport_and_path(self, uri): 838 def get_transport_and_path(self, uri):
839 from dulwich.client import TCPGitClient, SSHGitClient, SubprocessGitClient 839 from dulwich.client import TCPGitClient, SSHGitClient, SubprocessGitClient
840 for handler, transport in (("git://", TCPGitClient), ("git@", SSHGitClient), ("git+ssh://", SSHGitClient)): 840 for handler, transport in (("git://", TCPGitClient), ("git@", SSHGitClient), ("git+ssh://", SSHGitClient)):
841 if uri.startswith(handler): 841 if uri.startswith(handler):
842 host, path = uri[len(handler):].split("/", 1) 842 # We need to split around : or /, whatever comes first
843 return transport(host, thin_packs=False), '/' + path 843 hostpath = uri[len(handler):]
844 if (hostpath.find(':') > 0 and hostpath.find('/') > 0):
845 # we have both, whatever is first wins.
846 if hostpath.find(':') < hostpath.find('/'):
847 hostpath_seper = ':'
848 else:
849 hostpath_seper = '/'
850 elif hostpath.find(':') > 0:
851 hostpath_seper = ':'
852 else:
853 hostpath_seper = '/'
854
855 host, path = hostpath.split(hostpath_seper, 1)
856 if hostpath_seper == '/':
857 transportpath = '/' + path
858 else:
859 transportpath = path
860 return transport(host, thin_packs=False), transportpath
844 # if its not git or git+ssh, try a local url.. 861 # if its not git or git+ssh, try a local url..
845 return SubprocessGitClient(thin_packs=False), uri 862 return SubprocessGitClient(thin_packs=False), uri