diff --git a/tools_webrtc/autoroller/roll_deps.py b/tools_webrtc/autoroller/roll_deps.py index d7d197be1d..24ca18beb3 100755 --- a/tools_webrtc/autoroller/roll_deps.py +++ b/tools_webrtc/autoroller/roll_deps.py @@ -403,7 +403,7 @@ def _LocalCommit(commit_msg, dry_run): _RunCommand(['git', 'commit', '-m', commit_msg]) -def ShouldUseCQ(skip_cq, cq_over, current_commit_pos, new_commit_pos): +def ChooseCQMode(skip_cq, cq_over, current_commit_pos, new_commit_pos): if skip_cq: return 0 if (new_commit_pos - current_commit_pos) < cq_over: @@ -411,24 +411,22 @@ def ShouldUseCQ(skip_cq, cq_over, current_commit_pos, new_commit_pos): return 2 -def _UploadCL(dry_run, commit_queue=2): +def _UploadCL(commit_queue_mode): """Upload the committed changes as a changelist to Gerrit. - commit_queue: + commit_queue_mode: - 2: Submit to commit queue. - - 1: Commit queue dry run. + - 1: Run trybots but do not submit to CQ. - 0: Skip CQ, upload only. """ - logging.info('Uploading CL...') - if not dry_run: - cmd = ['git', 'cl', 'upload', '-f', '--gerrit'] - if commit_queue >= 2: - logging.info('Sending the CL to the CQ...') - cmd.extend(['--use-commit-queue', '--send-mail']) - elif commit_queue >= 1: - logging.info('Starting CQ dry run...') - cmd.extend(['--cq-dry-run']) - _RunCommand(cmd, extra_env={'EDITOR': 'true', 'SKIP_GCE_AUTH_FOR_GIT': '1'}) + cmd = ['git', 'cl', 'upload', '-f', '--gerrit'] + if commit_queue_mode >= 2: + logging.info('Sending the CL to the CQ...') + cmd.extend(['--use-commit-queue', '--send-mail']) + elif commit_queue_mode >= 1: + logging.info('Starting CQ dry run...') + cmd.extend(['--cq-dry-run']) + _RunCommand(cmd, extra_env={'EDITOR': 'true', 'SKIP_GCE_AUTH_FOR_GIT': '1'}) def main(): @@ -503,9 +501,11 @@ def main(): logging.info("No DEPS changes detected, skipping CL creation.") else: _LocalCommit(commit_msg, opts.dry_run) - commit_queue = ShouldUseCQ(opts.skip_cq, opts.cq_over, - current_commit_pos, new_commit_pos) - _UploadCL(opts.dry_run, commit_queue) + commit_queue_mode = ChooseCQMode(opts.skip_cq, opts.cq_over, + current_commit_pos, new_commit_pos) + logging.info('Uploading CL...') + if not opts.dry_run: + _UploadCL(commit_queue_mode) return 0 diff --git a/tools_webrtc/autoroller/unittests/roll_deps_test.py b/tools_webrtc/autoroller/unittests/roll_deps_test.py index 369feea7db..db7ab022e7 100755 --- a/tools_webrtc/autoroller/unittests/roll_deps_test.py +++ b/tools_webrtc/autoroller/unittests/roll_deps_test.py @@ -19,8 +19,8 @@ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) PARENT_DIR = os.path.join(SCRIPT_DIR, os.pardir) sys.path.append(PARENT_DIR) import roll_deps -from roll_deps import CalculateChangedDeps, GetMatchingDepsEntries, \ - ParseDepsDict, ParseLocalDepsFile, UpdateDepsFile, ShouldUseCQ +from roll_deps import CalculateChangedDeps, ChooseCQMode, \ + GetMatchingDepsEntries, ParseDepsDict, ParseLocalDepsFile, UpdateDepsFile TEST_DATA_VARS = { @@ -140,15 +140,15 @@ class TestRollChromiumRevision(unittest.TestCase): self.assertEquals(changed_deps[1].new_rev, BUILDTOOLS_NEW_REV) -class TestShouldUseCQ(unittest.TestCase): +class TestChooseCQMode(unittest.TestCase): def testSkip(self): - self.assertEquals(ShouldUseCQ(True, 99, 500000, 500100), 0) + self.assertEquals(ChooseCQMode(True, 99, 500000, 500100), 0) def testDryRun(self): - self.assertEquals(ShouldUseCQ(False, 101, 500000, 500100), 1) + self.assertEquals(ChooseCQMode(False, 101, 500000, 500100), 1) def testSubmit(self): - self.assertEquals(ShouldUseCQ(False, 100, 500000, 500100), 2) + self.assertEquals(ChooseCQMode(False, 100, 500000, 500100), 2) def _SetupGitLsRemoteCall(cmd_fake, url, revision):