tools/cl upload: Add a few convenience flags

--try: set CQ+1
--autosubmit: Set Auto-Submit and CQ+1
--submit: set CQ+2
--reviewer: Set a username as reviewer

BUG=None
TEST=This CL was uploaded with:
tools/cl upload --autosubmit -r dverkamp

Change-Id: I1ec9834d2f5d365eaa500e8e5915c77a4f066c6b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3997873
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Dennis Kempin 2022-11-01 22:34:33 +00:00 committed by crosvm LUCI
parent be900c3aae
commit a7b5a94480
2 changed files with 23 additions and 3 deletions

View file

@ -3,11 +3,14 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import argparse
import functools
import re
import sys
from argh import arg # type: ignore
from os import chdir
from pathlib import Path
from typing import List, Optional, Tuple
from impl.common import CROSVM_ROOT, GerritChange, cmd, confirm, run_commands
@ -213,7 +216,13 @@ def rebase():
git(f"cherry-pick {branch_name}@{{u}}..{branch_name}").fg()
def upload(dry_run: bool = False):
def upload(
dry_run: bool = False,
reviewer: Optional[str] = None,
auto_submit: bool = False,
submit: bool = False,
try_: bool = False,
):
"""
Uploads changes to the crosvm main branch.
"""
@ -240,7 +249,18 @@ def upload(dry_run: bool = False):
return
print()
git("push origin HEAD:refs/for/main").fg(dry_run=dry_run)
extra_args: List[str] = []
if auto_submit:
extra_args.append("l=Auto-Submit+1")
try_ = True
if try_:
extra_args.append("l=Commit-Queue+1")
if submit:
extra_args.append(f"l=Commit-Queue+2")
if reviewer:
extra_args.append(f"r={reviewer}")
git(f"push origin HEAD:refs/for/main%{','.join(extra_args)}").fg(dry_run=dry_run)
if __name__ == "__main__":

View file

@ -58,7 +58,7 @@ class ClTests(unittest.TestCase):
Uploading to origin/main:
{sha} Test Commit
Not running: git push origin HEAD:refs/for/main"""
Not running: git push origin HEAD:refs/for/main%"""
self.assertEqual(cl("upload --dry-run").stdout(), expected)