Commits

Junichi OKADOME  committed edaadbd

to be recognized port number in path to repository

  • Participants
  • Parent commits 6867b01

Comments (0)

Files changed (2)

File hggit/git_handler.py

                 else:
                     hostpath_seper = '/'
 
+                port = None
                 host, path = hostpath.split(hostpath_seper, 1)
                 if hostpath_seper == '/':
                     transportpath = '/' + path
                 else:
-                    transportpath = path
-                return transport(host, thin_packs=False), transportpath
+                    # port number should be recognized
+                    m = re.match('^(?P<port>\d+)?(?P<path>.*)$', path)
+                    if m.group('port'):
+                        client.port = m.group('port')
+                        port = client.port
+                        transportpath = m.group('path')
+                    else:
+                        transportpath = path
+
+                return transport(host, thin_packs=False, port=port), transportpath
         # if its not git or git+ssh, try a local url..
         return client.SubprocessGitClient(thin_packs=False), uri

File tests/test-url-parsing.py

         except AttributeError:
             self.assertEquals(client.host, 'github.com')
 
+    def test_ssh_github_style_slash_with_port(self):
+        url = "git+ssh://git@github.com:10022/webjam/webjam.git"
+        client, path = self.handler.get_transport_and_path(url)
+        self.assertEquals(path, '/webjam/webjam.git')
+        self.assertEquals(client.host, 'git@github.com')
+        self.assertEquals(client.port, '10022')
+
+    def test_gitdaemon_style_with_port(self):
+        url = "git://github.com:19418/webjam/webjam.git"
+        client, path = self.handler.get_transport_and_path(url)
+        self.assertEquals(path, '/webjam/webjam.git')
+        try:
+            self.assertEquals(client._host, 'github.com')
+        except AttributeError:
+            self.assertEquals(client.host, 'github.com')
+        self.assertEquals(client._port, '19418')
 
 if __name__ == '__main__':
     tc = TestUrlParsing()
     for test in ['test_ssh_github_style_slash',
                  'test_ssh_github_style_colon',
                  'test_ssh_heroku_style',
-                 'test_gitdaemon_style']:
+                 'test_gitdaemon_style',
+                 'test_ssh_github_style_slash_with_port',
+                 'test_gitdaemon_style_with_port']:
         tc.setUp()
         getattr(tc, test)()
         tc.tearDown()