Commit 4e07567f authored by igorgatis@gmail.com's avatar igorgatis@gmail.com

Introduced git+http(s) fake URL schema to support git urls which don't have...

Introduced git+http(s) fake URL schema to support git urls which don't have "filename.git" portion (http://foo/bar vs http://foo/bar/filename.git).

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@110937 0039d316-1c4b-4281-b951-d872f2087c98
parent 4942e4a5
...@@ -67,6 +67,7 @@ def GetScmName(url): ...@@ -67,6 +67,7 @@ def GetScmName(url):
if url: if url:
url, _ = gclient_utils.SplitUrlRevision(url) url, _ = gclient_utils.SplitUrlRevision(url)
if (url.startswith('git://') or url.startswith('ssh://') or if (url.startswith('git://') or url.startswith('ssh://') or
url.startswith('git+http://') or url.startswith('git+https://') or
url.endswith('.git')): url.endswith('.git')):
return 'git' return 'git'
elif (url.startswith('http://') or url.startswith('https://') or elif (url.startswith('http://') or url.startswith('https://') or
...@@ -126,6 +127,12 @@ class SCMWrapper(object): ...@@ -126,6 +127,12 @@ class SCMWrapper(object):
class GitWrapper(SCMWrapper): class GitWrapper(SCMWrapper):
"""Wrapper for Git""" """Wrapper for Git"""
def __init__(self, url=None, root_dir=None, relpath=None):
"""Removes 'git+' fake prefix from git URL."""
if url.startswith('git+http://') or url.startswith('git+https://'):
url = url[4:]
SCMWrapper.__init__(self, url, root_dir, relpath)
def GetRevisionDate(self, revision): def GetRevisionDate(self, revision):
"""Returns the given revision's date in ISO-8601 format (which contains the """Returns the given revision's date in ISO-8601 format (which contains the
time zone).""" time zone)."""
......
...@@ -120,6 +120,22 @@ class SVNWrapperTestCase(BaseTestCase): ...@@ -120,6 +120,22 @@ class SVNWrapperTestCase(BaseTestCase):
relpath=self.relpath) relpath=self.relpath)
self.assertEqual(scm.FullUrlForRelativeUrl('/crap'), 'git://a/b/c/crap') self.assertEqual(scm.FullUrlForRelativeUrl('/crap'), 'git://a/b/c/crap')
def testGITFakeHttpUrl(self):
self.url = 'git+http://foo'
self.mox.ReplayAll()
scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
relpath=self.relpath)
self.assertEqual(scm.url, 'http://foo')
def testGITFakeHttpsUrl(self):
self.url = 'git+https://foo'
self.mox.ReplayAll()
scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
relpath=self.relpath)
self.assertEqual(scm.url, 'https://foo')
def testRunCommandException(self): def testRunCommandException(self):
options = self.Options(verbose=False) options = self.Options(verbose=False)
gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
......
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