From d48b6a145b05ef7d192c9940e8777427352791ff Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.dos.anjos@gmail.com> Date: Fri, 17 Dec 2021 14:21:13 +0100 Subject: [PATCH] [scripts] Be more flexible with group discovery --- bob/devtools/scripts/runners.py | 16 +++++++++++----- bob/devtools/scripts/settings.py | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bob/devtools/scripts/runners.py b/bob/devtools/scripts/runners.py index b8a208e9..f39e9509 100644 --- a/bob/devtools/scripts/runners.py +++ b/bob/devtools/scripts/runners.py @@ -120,6 +120,12 @@ Examples: ) @click.argument("name") @click.argument("targets", nargs=-1, required=True) +@click.option( + "-g", + "--group/--no-group", + default=False, + help="If set, consider the the provided name as a group name", +) @click.option( "-d", "--dry-run/--no-dry-run", @@ -130,7 +136,7 @@ Examples: ) @verbosity_option() @bdt.raise_on_error -def enable(name, targets, dry_run): +def enable(name, targets, group, dry_run): """Enables runners on whole gitlab groups or single projects. You may provide project names (like "group/project"), whole groups, and @@ -145,12 +151,12 @@ def enable(name, targets, dry_run): packages = [] for target in targets: - if "/" in target: # it is a specific project - packages.append(_get_project(gl, target)) - - elif os.path.exists(target): # it is a file with project names + if os.path.exists(target): # it is a file with project names packages += _get_projects_from_file(gl, target) + elif not group: # it is a specific project + packages.append(_get_project(gl, target)) + else: # it is a group - get all projects packages += _get_projects_from_group(gl, target) diff --git a/bob/devtools/scripts/settings.py b/bob/devtools/scripts/settings.py index feeb4113..e8517451 100644 --- a/bob/devtools/scripts/settings.py +++ b/bob/devtools/scripts/settings.py @@ -114,7 +114,7 @@ def settings(projects, avatar, description, group, archive, dry_run): if os.path.exists(target): # it is a file with project names gl_projects += _get_projects_from_file(gl, target) - if not group: # it is a specific project + elif not group: # it is a specific project gl_projects.append(_get_project(gl, target)) else: # it is a group - get all projects -- GitLab