Commit 21a51b39 authored by John Budorick's avatar John Budorick Committed by Commit Bot

gclient: set the push url to the actual repository instead of the mirror.

Bug: 884434
Change-Id: Id156709e14d1c3506a1236bc1e59f8468381a402
Reviewed-on: https://chromium-review.googlesource.com/1232257
Commit-Queue: John Budorick <jbudorick@chromium.org>
Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
parent 647e1e79
......@@ -550,14 +550,21 @@ class GitWrapper(SCMWrapper):
self._Clone(revision, url, options)
if file_list is not None:
files = self._Capture(
['-c', 'core.quotePath=false', 'ls-files']).splitlines()
['-c', 'core.quotePath=false', 'ls-files']).splitlines()
file_list.extend([os.path.join(self.checkout_path, f) for f in files])
if mirror:
self._Capture(
['remote', 'set-url', '--push', 'origin', mirror.url])
if not verbose:
# Make the output a little prettier. It's nice to have some whitespace
# between projects when cloning.
self.Print('')
return self._Capture(['rev-parse', '--verify', 'HEAD'])
if mirror:
self._Capture(
['remote', 'set-url', '--push', 'origin', mirror.url])
if not managed:
self._SetFetchConfig(options)
self.Print('________ unmanaged solution; skipping %s' % self.relpath)
......
......@@ -570,6 +570,41 @@ class ManagedGitWrapperTestCase(BaseGitWrapperTestCase):
rev_info = scm.revinfo(options, (), None)
self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458')
def testMirrorPushUrl(self):
if not self.enabled:
return
fakes = fake_repos.FakeRepos()
fakes.set_up_git()
self.url = fakes.git_base + 'repo_1'
self.root_dir = fakes.root_dir
self.addCleanup(fake_repos.FakeRepos.tear_down_git, fakes)
mirror = tempfile.mkdtemp()
self.addCleanup(rmtree, mirror)
# This should never happen, but if it does, it'd render the other assertions
# in this test meaningless.
self.assertFalse(self.url.startswith(mirror))
git_cache.Mirror.SetCachePath(mirror)
self.addCleanup(git_cache.Mirror.SetCachePath, None)
options = self.Options()
scm = gclient_scm.GitWrapper(self.url, self.root_dir, self.relpath)
self.assertIsNotNone(scm._GetMirror(self.url, options))
scm.update(options, (), [])
fetch_url = scm._Capture(['remote', 'get-url', 'origin'])
self.assertTrue(
fetch_url.startswith(mirror),
msg='\n'.join([
'Repository fetch url should be in the git cache mirror directory.',
' fetch_url: %s' % fetch_url,
' mirror: %s' % mirror]))
push_url = scm._Capture(['remote', 'get-url', '--push', 'origin'])
self.assertEquals(push_url, self.url)
sys.stdout.close()
class ManagedGitWrapperTestCaseMox(BaseTestCase):
class OptionsObject(object):
......
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