Mercurial > hg > hg-git
changeset 922:5f93caf337a9
git_handler: test for a raw git ssh uri
By testing the uri early, we can reuse logic later in the method to parse the
git uri. We rely on the isgitsshuri heuristic to return True or False, and if
True, prepend 'git+ssh://' to the uri.
Arguably, this is fragile, and am open to better ideas, but can't think of
anything else currently.
author | Sean Farley <sean@farley.io> |
---|---|
date | Fri, 26 Jun 2015 16:32:20 -0700 |
parents | 0e975d03f8ca |
children | ee9017a3c269 |
files | hggit/git_handler.py |
diffstat | 1 files changed, 24 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -1540,10 +1540,34 @@ return string.decode('ascii', 'replace').encode('utf-8') def get_transport_and_path(self, uri): + """Method that sets up the transport (either ssh or http(s)) + + Tests: + + >>> from dulwich.client import HttpGitClient, SSHGitClient + >>> from mercurial.ui import ui + >>> g = GitHandler('', ui()) + >>> client, url = g.get_transport_and_path('http://fqdn.com/test.git') + >>> print isinstance(client, HttpGitClient) + True + >>> print url + http://fqdn.com/test.git + >>> client, url = g.get_transport_and_path('git@fqdn.com:user/repo.git') + >>> print isinstance(client, SSHGitClient) + True + >>> print url + user/repo.git + >>> print client.host + git@fqdn.com + """ # pass hg's ui.ssh config to dulwich if not issubclass(client.get_ssh_vendor, _ssh.SSHVendor): client.get_ssh_vendor = _ssh.generate_ssh_vendor(self.ui) + # test for raw git ssh uri here so that we can reuse the logic below + if util.isgitsshuri(uri): + uri = "git+ssh://" + uri + git_match = RE_GIT_URI.match(uri) if git_match: res = git_match.groupdict()