Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Strip trailing slash for heroku-style URLs. Fixes #31. Includes a reg…

…ression test for the fix.
  • Loading branch information...
commit ed4cbf893ca9287ce6a82b970dbea08565f3dbc9 1 parent fcb147c
@jaraco jaraco authored
View
4 hggit/git_handler.py
@@ -1110,6 +1110,10 @@ def get_transport_and_path(self, uri):
host, port, sepr, path = res['host'], res['port'], res['sepr'], res['path']
if sepr == '/':
path = '/' + path
+ # strip trailing slash for heroku-style URLs
+ # ssh+git://git@heroku.com:project.git/
+ if sepr == ':' and path.endswith('.git/'):
+ path = path.rstrip('/')
if port:
client.port = port
View
22 tests/test-url-parsing.py
@@ -40,6 +40,26 @@ def test_ssh_heroku_style(self):
client, path = self.handler.get_transport_and_path(url)
self.assertEquals(path, 'webjam.git')
self.assertEquals(client.host, 'git@heroku.com')
+ # also test that it works even if heroku isn't in the name
+ url = "git+ssh://git@compatible.com:webjam.git"
+ client, path = self.handler.get_transport_and_path(url)
+ self.assertEquals(path, 'webjam.git')
+ self.assertEquals(client.host, 'git@compatible.com')
+
+ def test_ssh_heroku_style_with_trailing_slash(self):
+ # some versions of mercurial add a trailing slash even if
+ # the user didn't supply one.
+ url = "git+ssh://git@heroku.com:webjam.git/"
+ client, path = self.handler.get_transport_and_path(url)
+ self.assertEquals(path, 'webjam.git')
+ self.assertEquals(client.host, 'git@heroku.com')
+
+ def test_heroku_style_with_port(self):
+ url = "git+ssh://git@heroku.com:999:webjam.git"
+ client, path = self.handler.get_transport_and_path(url)
+ self.assertEquals(path, 'webjam.git')
+ self.assertEquals(client.host, 'git@heroku.com')
+ self.assertEquals(client.port, '999')
def test_gitdaemon_style(self):
url = "git://github.com/webjam/webjam.git"
@@ -72,6 +92,8 @@ def test_gitdaemon_style_with_port(self):
for test in ['test_ssh_github_style_slash',
'test_ssh_github_style_colon',
'test_ssh_heroku_style',
+ 'test_ssh_heroku_style_with_trailing_slash',
+ 'test_heroku_style_with_port',
'test_gitdaemon_style',
'test_ssh_github_style_slash_with_port',
'test_gitdaemon_style_with_port']:
View
14 tests/test-url-parsing.py.out
@@ -10,6 +10,20 @@ git@github.com
webjam.git
% expect 'git@heroku.com'
git@heroku.com
+% expect 'webjam.git'
+webjam.git
+% expect 'git@compatible.com'
+git@compatible.com
+% expect 'webjam.git'
+webjam.git
+% expect 'git@heroku.com'
+git@heroku.com
+% expect 'webjam.git'
+webjam.git
+% expect 'git@heroku.com'
+git@heroku.com
+% expect '999'
+999
% expect '/webjam/webjam.git'
/webjam/webjam.git
% expect 'github.com'
Please sign in to comment.
Something went wrong with that request. Please try again.