Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(503)

Unified Diff: tests/git_cl_test.py

Issue 2259993002: git cl patch: bail out quickly if there is no branch. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@fix-611020
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« git_cl.py ('K') | « git_cl.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/git_cl_test.py
diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py
index dc689fdcc72ec0048a67e32e3f3b94f3828004ae..d4603ed3da7108aed8b306ed8bdff1c42e01790e 100755
--- a/tests/git_cl_test.py
+++ b/tests/git_cl_test.py
@@ -1237,7 +1237,8 @@ class TestGitCl(TestCase):
self.mock(git_common, 'is_dirty_git_tree', lambda x: True)
self.assertNotEqual(git_cl.main(['diff']), 0)
- def _patch_common(self, is_gerrit=False, force_codereview=False):
+ def _patch_common(self, is_gerrit=False, force_codereview=False,
+ new_branch=False):
self.mock(git_cl.sys, 'stdout', StringIO.StringIO())
self.mock(git_cl._RietveldChangelistImpl, 'GetMostRecentPatchset',
lambda x: '60001')
@@ -1267,7 +1268,10 @@ class TestGitCl(TestCase):
lambda *args: 'Description')
self.mock(git_cl, 'IsGitVersionAtLeast', lambda *args: True)
- self.calls = self.calls or []
+ if new_branch:
+ self.calls = [((['git', 'new-branch', 'master'],), ''),]
+ else:
+ self.calls = [((['git', 'symbolic-ref', 'HEAD'],), 'master')]
if not force_codereview:
# These calls detect codereview to use.
self.calls += [
@@ -1290,8 +1294,8 @@ class TestGitCl(TestCase):
((['sed', '-e', 's|^--- a/|--- |; s|^+++ b/|+++ |'],), ''),
]
- def _common_patch_successful(self):
- self._patch_common()
+ def _common_patch_successful(self, new_branch=False):
+ self._patch_common(new_branch=new_branch)
self.calls += [
((['git', 'apply', '--index', '-p0', '--3way'],), ''),
((['git', 'commit', '-m',
@@ -1312,8 +1316,7 @@ class TestGitCl(TestCase):
self.assertEqual(git_cl.main(['patch', '123456']), 0)
def test_patch_successful_new_branch(self):
- self.calls = [ ((['git', 'new-branch', 'master'],), ''), ]
- self._common_patch_successful()
+ self._common_patch_successful(new_branch=True)
self.assertEqual(git_cl.main(['patch', '-b', 'master', '123456']), 0)
def test_patch_conflict(self):
« git_cl.py ('K') | « git_cl.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698