git cl patch: bail out quickly if there is no branch.
This is because later calls to SetIssue() would fail.
R=michaelpg@chromium.org
BUG=611020
Review-Url: https://codereview.chromium.org/2259993002
diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py
index dc689fd..d4603ed 100755
--- a/tests/git_cl_test.py
+++ b/tests/git_cl_test.py
@@ -1237,7 +1237,8 @@
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 @@
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 @@
((['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 @@
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):