Commit fda50ca0 authored by Ravi Mistry's avatar Ravi Mistry Committed by Commit Bot

Skip checking local vs remote patchset for Gerrit

BUG=chromium:664520

Change-Id: Idd5855e14f6237577b351ff51582335996522417
Reviewed-on: https://chromium-review.googlesource.com/399118
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
parent 9b654aa0
......@@ -1595,7 +1595,9 @@ class Changelist(object):
if not options.reviewers and hook_results.reviewers:
options.reviewers = hook_results.reviewers.split(',')
if self.GetIssue():
# TODO(tandrii): Checking local patchset against remote patchset is only
# supported for Rietveld. Extend it to Gerrit or remove it completely.
if self.GetIssue() and not self.IsGerrit():
latest_patchset = self.GetMostRecentPatchset()
local_patchset = self.GetPatchset()
if (latest_patchset and local_patchset and
......@@ -4883,7 +4885,9 @@ def CMDtry(parser, args):
return 1
patchset = cl.GetMostRecentPatchset()
if patchset != cl.GetPatchset():
# TODO(tandrii): Checking local patchset against remote patchset is only
# supported for Rietveld. Extend it to Gerrit or remove it completely.
if not cl.IsGerrit() and patchset != cl.GetPatchset():
print('Warning: Codereview server has newer patchsets (%s) than most '
'recent upload from local checkout (%s). Did a previous upload '
'fail?\n'
......@@ -4935,7 +4939,9 @@ def CMDtry_results(parser, args):
'Either upload first, or pass --patchset explicitely' %
cl.GetIssue())
if patchset != cl.GetPatchset():
# TODO(tandrii): Checking local patchset against remote patchset is only
# supported for Rietveld. Extend it to Gerrit or remove it completely.
if not cl.IsGerrit() and patchset != cl.GetPatchset():
print('Warning: Codereview server has newer patchsets (%s) than most '
'recent upload from local checkout (%s). Did a previous upload '
'fail?\n'
......
......@@ -2037,7 +2037,6 @@ class TestGitCl(TestCase):
((['git', 'config', 'branch.feature.gerritserver'],),
'https://chromium-review.googlesource.com'),
((['_GetChangeDetail', []],), {'status': 'OPEN'}),
((['git', 'config', 'branch.feature.gerritpatchset'],), '7'),
((['_GetChangeDetail', ['DETAILED_ACCOUNTS']],),
{'owner': {'email': 'owner@e.mail'}}),
((['_GetChangeDetail', ['ALL_REVISIONS']],), {
......@@ -2368,8 +2367,10 @@ class TestGitCl(TestCase):
((['git', 'symbolic-ref', 'HEAD'],), 'feature'),
((['git', 'config', 'branch.feature.rietveldissue'],), CERR1),
((['git', 'config', 'branch.feature.gerritissue'],), '1'),
# TODO(tandrii): Uncomment the below if we decide to support checking
# patchsets for Gerrit.
# Simulate that Gerrit has more patchsets than local.
((['git', 'config', 'branch.feature.gerritpatchset'],), '12'),
# ((['git', 'config', 'branch.feature.gerritpatchset'],), '12'),
((['git', 'config', 'branch.feature.gerritserver'],),
'https://x-review.googlesource.com'),
((['get_authenticator_for_host', 'x-review.googlesource.com'],),
......@@ -2379,18 +2380,21 @@ class TestGitCl(TestCase):
def test_fetch_try_jobs_none_gerrit(self):
self._setup_fetch_try_jobs_gerrit({})
self.assertEqual(0, git_cl.main(['try-results']))
self.assertRegexpMatches(
sys.stdout.getvalue(),
r'Warning: Codereview server has newer patchsets \(13\)')
# TODO(tandrii): Uncomment the below if we decide to support checking
# patchsets for Gerrit.
# self.assertRegexpMatches(
# sys.stdout.getvalue(),
# r'Warning: Codereview server has newer patchsets \(13\)')
self.assertRegexpMatches(sys.stdout.getvalue(), 'No try jobs')
def test_fetch_try_jobs_some_gerrit(self):
self._setup_fetch_try_jobs_gerrit({
'builds': self.BUILDBUCKET_BUILDS_MAP.values(),
})
# Explicit --patchset means actual local patchset doesn't matter.
self.calls.remove(
((['git', 'config', 'branch.feature.gerritpatchset'],), '12'))
# TODO(tandrii): Uncomment the below if we decide to support checking
# patchsets for Gerrit.
# self.calls.remove(
# ((['git', 'config', 'branch.feature.gerritpatchset'],), '12'))
self.assertEqual(0, git_cl.main(['try-results', '--patchset', '5']))
# ... and doesn't result in warning.
......
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