Commit c4344b59 authored by tandrii's avatar tandrii Committed by Commit bot

Fix Gerrit git cl land and add test.

R=andybons@chromium.org
BUG=641127

Review-Url: https://codereview.chromium.org/2280563003
parent 7090f652
......@@ -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')
......
......@@ -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(
......
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