From 8366d77e4c6bb97525670060c147d85ec5458f5b Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Tue, 29 Aug 2023 18:15:47 +0100 Subject: [PATCH] bin/ci_run_n_monitor: error out if both --project and --pipeline-url are passed Signed-off-by: Eric Engestrom Part-of: --- bin/ci/ci_run_n_monitor.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/ci/ci_run_n_monitor.py b/bin/ci/ci_run_n_monitor.py index 7445273..4dc4e78 100755 --- a/bin/ci/ci_run_n_monitor.py +++ b/bin/ci/ci_run_n_monitor.py @@ -259,7 +259,16 @@ def parse_args() -> None: help="URL of the pipeline to use, instead of auto-detecting it.", ) - return parser.parse_args() + args = parser.parse_args() + + # argparse doesn't support groups inside add_mutually_exclusive_group(), + # which means we can't just put `--project` and `--rev` in a group together, + # we have to do this by heand instead. + if args.pipeline_url and args.project != parser.get_default("project"): + # weird phrasing but it's the error add_mutually_exclusive_group() gives + parser.error("argument --project: not allowed with argument --pipeline-url") + + return args def find_dependencies(target_job: str, project_path: str, sha: str) -> set[str]: -- 2.7.4