diff --git a/git_cl.py b/git_cl.py index 3f26f217f..73ce7b186 100755 --- a/git_cl.py +++ b/git_cl.py @@ -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' diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index dcd530865..82d830a57 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -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.