Commit a4d60f9b authored by msb@chromium.org's avatar msb@chromium.org

Fix parsing bug in SplitUrlRevision.

ssh://example.com/git/test.git was not parsed correctly.

Review URL: http://codereview.chromium.org/401022

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@32377 0039d316-1c4b-4281-b951-d872f2087c98
parent dffe4942
...@@ -29,7 +29,7 @@ def SplitUrlRevision(url): ...@@ -29,7 +29,7 @@ def SplitUrlRevision(url):
"""Splits url and returns a two-tuple: url, rev""" """Splits url and returns a two-tuple: url, rev"""
if url.startswith('ssh:'): if url.startswith('ssh:'):
# Make sure ssh://test@example.com/test.git@stable works # Make sure ssh://test@example.com/test.git@stable works
regex = r"(ssh://(?:[\w]+@)?[-\w:\.]+/[-\w\.]+)(?:@([\w/]+))?" regex = r"(ssh://(?:[\w]+@)?[-\w:\.]+/[-\w\./]+)(?:@([\w/]+))?"
components = re.search(regex, url).groups() components = re.search(regex, url).groups()
else: else:
components = url.split("@") components = url.split("@")
......
...@@ -63,6 +63,13 @@ class SplitUrlRevisionTestCase(SuperMoxTestBase): ...@@ -63,6 +63,13 @@ class SplitUrlRevisionTestCase(SuperMoxTestBase):
out_url, out_rev = gclient_utils.SplitUrlRevision("%s@%s" % (url, rev)) out_url, out_rev = gclient_utils.SplitUrlRevision("%s@%s" % (url, rev))
self.assertEquals(out_rev, rev) self.assertEquals(out_rev, rev)
self.assertEquals(out_url, url) self.assertEquals(out_url, url)
url = "ssh://example.com/git/test.git"
out_url, out_rev = gclient_utils.SplitUrlRevision(url)
self.assertEquals(out_rev, None)
self.assertEquals(out_url, url)
out_url, out_rev = gclient_utils.SplitUrlRevision("%s@%s" % (url, rev))
self.assertEquals(out_rev, rev)
self.assertEquals(out_url, url)
def testSVNUrl(self): def testSVNUrl(self):
url = "svn://example.com/test" url = "svn://example.com/test"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment