From a7b5a944804aa21a9185798b39682f129ca89649 Mon Sep 17 00:00:00 2001 From: Dennis Kempin Date: Tue, 1 Nov 2022 22:34:33 +0000 Subject: [PATCH] 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 Auto-Submit: Dennis Kempin Commit-Queue: Daniel Verkamp --- tools/cl | 24 ++++++++++++++++++++++-- tools/tests/cl_tests.py | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/tools/cl b/tools/cl index ef88cc910a..f75e9bbc96 100755 --- a/tools/cl +++ b/tools/cl @@ -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__": diff --git a/tools/tests/cl_tests.py b/tools/tests/cl_tests.py index b5fa1814da..7ca143e8cc 100644 --- a/tools/tests/cl_tests.py +++ b/tools/tests/cl_tests.py @@ -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)