Pārlūkot izejas kodu

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: Andrii Shyshkalov <tandrii@chromium.org>
Ravi Mistry 8 gadi atpakaļ
vecāks
revīzija
fda50ca02d
2 mainītis faili ar 21 papildinājumiem un 11 dzēšanām
  1. 9 3
      git_cl.py
  2. 12 8
      tests/git_cl_test.py

+ 9 - 3
git_cl.py

@@ -1595,7 +1595,9 @@ class Changelist(object):
       if not options.reviewers and hook_results.reviewers:
       if not options.reviewers and hook_results.reviewers:
         options.reviewers = hook_results.reviewers.split(',')
         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()
       latest_patchset = self.GetMostRecentPatchset()
       local_patchset = self.GetPatchset()
       local_patchset = self.GetPatchset()
       if (latest_patchset and local_patchset and
       if (latest_patchset and local_patchset and
@@ -4883,7 +4885,9 @@ def CMDtry(parser, args):
       return 1
       return 1
 
 
   patchset = cl.GetMostRecentPatchset()
   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 '
     print('Warning: Codereview server has newer patchsets (%s) than most '
           'recent upload from local checkout (%s). Did a previous upload '
           'recent upload from local checkout (%s). Did a previous upload '
           'fail?\n'
           'fail?\n'
@@ -4935,7 +4939,9 @@ def CMDtry_results(parser, args):
                    'Either upload first, or pass --patchset explicitely' %
                    'Either upload first, or pass --patchset explicitely' %
                    cl.GetIssue())
                    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 '
       print('Warning: Codereview server has newer patchsets (%s) than most '
             'recent upload from local checkout (%s). Did a previous upload '
             'recent upload from local checkout (%s). Did a previous upload '
             'fail?\n'
             'fail?\n'

+ 12 - 8
tests/git_cl_test.py

@@ -2037,7 +2037,6 @@ class TestGitCl(TestCase):
         ((['git', 'config', 'branch.feature.gerritserver'],),
         ((['git', 'config', 'branch.feature.gerritserver'],),
          'https://chromium-review.googlesource.com'),
          'https://chromium-review.googlesource.com'),
         ((['_GetChangeDetail', []],), {'status': 'OPEN'}),
         ((['_GetChangeDetail', []],), {'status': 'OPEN'}),
-        ((['git', 'config', 'branch.feature.gerritpatchset'],), '7'),
         ((['_GetChangeDetail', ['DETAILED_ACCOUNTS']],),
         ((['_GetChangeDetail', ['DETAILED_ACCOUNTS']],),
          {'owner': {'email': 'owner@e.mail'}}),
          {'owner': {'email': 'owner@e.mail'}}),
         ((['_GetChangeDetail', ['ALL_REVISIONS']],), {
         ((['_GetChangeDetail', ['ALL_REVISIONS']],), {
@@ -2368,8 +2367,10 @@ class TestGitCl(TestCase):
       ((['git', 'symbolic-ref', 'HEAD'],), 'feature'),
       ((['git', 'symbolic-ref', 'HEAD'],), 'feature'),
       ((['git', 'config', 'branch.feature.rietveldissue'],), CERR1),
       ((['git', 'config', 'branch.feature.rietveldissue'],), CERR1),
       ((['git', 'config', 'branch.feature.gerritissue'],), '1'),
       ((['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.
       # 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'],),
       ((['git', 'config', 'branch.feature.gerritserver'],),
        'https://x-review.googlesource.com'),
        'https://x-review.googlesource.com'),
       ((['get_authenticator_for_host', '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):
   def test_fetch_try_jobs_none_gerrit(self):
     self._setup_fetch_try_jobs_gerrit({})
     self._setup_fetch_try_jobs_gerrit({})
     self.assertEqual(0, git_cl.main(['try-results']))
     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')
     self.assertRegexpMatches(sys.stdout.getvalue(), 'No try jobs')
 
 
   def test_fetch_try_jobs_some_gerrit(self):
   def test_fetch_try_jobs_some_gerrit(self):
     self._setup_fetch_try_jobs_gerrit({
     self._setup_fetch_try_jobs_gerrit({
       'builds': self.BUILDBUCKET_BUILDS_MAP.values(),
       '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']))
     self.assertEqual(0, git_cl.main(['try-results', '--patchset', '5']))
 
 
     # ... and doesn't result in warning.
     # ... and doesn't result in warning.