From c4344b595829e01702a64e4380790b7daa93724c Mon Sep 17 00:00:00 2001 From: tandrii Date: Mon, 29 Aug 2016 06:04:54 -0700 Subject: [PATCH] Fix Gerrit git cl land and add test. R=andybons@chromium.org BUG=641127 Review-Url: https://codereview.chromium.org/2280563003 --- git_cl.py | 3 +-- tests/git_cl_test.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/git_cl.py b/git_cl.py index 1f62dc055..24a8c9969 100755 --- a/git_cl.py +++ b/git_cl.py @@ -2306,8 +2306,7 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase): 'Press Enter to continue, Ctrl+C to abort.') differs = True - last_upload = RunGit(['config', self._GitBranchSetting('gerritsquashhash')], - error_ok=True).strip() + last_upload = self._GitGetBranchConfigValue('gerritsquashhash') # Note: git diff outputs nothing if there is no diff. if not last_upload or RunGit(['diff', last_upload]).strip(): print('WARNING: some changes from local branch haven\'t been uploaded') diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index 47eaaf7eb..9796b2bcb 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -1894,6 +1894,23 @@ class TestGitCl(TestCase): ] cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) + def test_GerritCmdLand(self): + self.calls += [ + ((['git', 'symbolic-ref', 'HEAD'],), 'feature'), + ((['git', 'config', 'branch.feature.gerritsquashhash'],), + 'deadbeaf'), + ((['git', 'diff', 'deadbeaf'],), ''), # No diff. + ((['git', 'config', 'branch.feature.gerritserver'],), + 'chromium-review.googlesource.com'), + ] + cl = git_cl.Changelist(issue=123, codereview='gerrit') + cl._codereview_impl._GetChangeDetail = lambda _: { + 'labels': {}, + 'current_revision': 'deadbeaf', + } + cl._codereview_impl.SubmitIssue = lambda wait_for_merge: None + self.assertEqual(0, cl.CMDLand(force=True, bypass_hooks=True, verbose=True)) + if __name__ == '__main__': git_cl.logging.basicConfig(