Commit 8b0553c1 authored by thestig@chromium.org's avatar thestig@chromium.org

Cleanup: Merge a bunch of redundent env['GIT_PAGER'] = 'cat' statements.

Additionally:
- replace some RunCommand(['git', ...]) calls with RunGit().
- replace Settings._GetConfig('rietveld.foo') _GetRietveldConfig('foo').
- merge and cache calls to git rev-parse --show-cdup.
- merge some calls to git merge-base.

Review URL: https://codereview.chromium.org/157913005

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@250248 0039d316-1c4b-4281-b951-d872f2087c98
parent 2504f2ed
This diff is collapsed.
...@@ -204,7 +204,6 @@ class TestGitCl(TestCase): ...@@ -204,7 +204,6 @@ class TestGitCl(TestCase):
((['git', ((['git',
'config', '--local', '--get-regexp', '^svn-remote\\.'],), 'config', '--local', '--get-regexp', '^svn-remote\\.'],),
(('', None), 0)), (('', None), 0)),
((['git', 'rev-parse', '--show-cdup'],), ''),
((['git', 'svn', 'info'],), ''), ((['git', 'svn', 'info'],), ''),
((['git', ((['git',
'config', 'branch.master.rietveldissue', '1'],), ''), 'config', 'branch.master.rietveldissue', '1'],), ''),
...@@ -319,8 +318,8 @@ class TestGitCl(TestCase): ...@@ -319,8 +318,8 @@ class TestGitCl(TestCase):
] ]
@classmethod @classmethod
def _dcommit_calls_3(cls): def _dcommit_calls_3(cls, is_first_call):
return [ calls = [
((['git', ((['git',
'diff', '--no-ext-diff', '--stat', '--find-copies-harder', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder',
'-l100000', '-C50', 'fake_ancestor_sha', '-l100000', '-C50', 'fake_ancestor_sha',
...@@ -334,7 +333,12 @@ class TestGitCl(TestCase): ...@@ -334,7 +333,12 @@ class TestGitCl(TestCase):
((['git', 'branch', '-D', 'git-cl-commit'],), ''), ((['git', 'branch', '-D', 'git-cl-commit'],), ''),
((['git', 'show-ref', '--quiet', '--verify', ((['git', 'show-ref', '--quiet', '--verify',
'refs/heads/git-cl-cherry-pick'],), ''), 'refs/heads/git-cl-cherry-pick'],), ''),
((['git', 'rev-parse', '--show-cdup'],), '\n'), ]
if is_first_call:
calls += [
((['git', 'rev-parse', '--show-cdup'],), '\n'),
]
calls += [
((['git', 'checkout', '-q', '-b', 'git-cl-commit'],), ''), ((['git', 'checkout', '-q', '-b', 'git-cl-commit'],), ''),
((['git', 'reset', '--soft', 'fake_ancestor_sha'],), ''), ((['git', 'reset', '--soft', 'fake_ancestor_sha'],), ''),
((['git', 'commit', '-m', ((['git', 'commit', '-m',
...@@ -346,7 +350,8 @@ class TestGitCl(TestCase): ...@@ -346,7 +350,8 @@ class TestGitCl(TestCase):
(('', None), 0)), (('', None), 0)),
((['git', 'checkout', '-q', 'working'],), ''), ((['git', 'checkout', '-q', 'working'],), ''),
((['git', 'branch', '-D', 'git-cl-commit'],), ''), ((['git', 'branch', '-D', 'git-cl-commit'],), ''),
] ]
return calls
@staticmethod @staticmethod
def _cmd_line(description, args, similarity, find_copies, private): def _cmd_line(description, args, similarity, find_copies, private):
...@@ -509,14 +514,14 @@ class TestGitCl(TestCase): ...@@ -509,14 +514,14 @@ class TestGitCl(TestCase):
self._dcommit_calls_1() + self._dcommit_calls_1() +
self._git_sanity_checks('fake_ancestor_sha', 'working') + self._git_sanity_checks('fake_ancestor_sha', 'working') +
self._dcommit_calls_normal() + self._dcommit_calls_normal() +
self._dcommit_calls_3()) self._dcommit_calls_3(False))
git_cl.main(['dcommit']) git_cl.main(['dcommit'])
def test_dcommit_bypass_hooks(self): def test_dcommit_bypass_hooks(self):
self.calls = ( self.calls = (
self._dcommit_calls_1() + self._dcommit_calls_1() +
self._dcommit_calls_bypassed() + self._dcommit_calls_bypassed() +
self._dcommit_calls_3()) self._dcommit_calls_3(True))
git_cl.main(['dcommit', '--bypass-hooks']) git_cl.main(['dcommit', '--bypass-hooks'])
......
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