From 59f6c2e5ac93f09bcd6720d59fb8864f81f119d7 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Mon, 4 Nov 2019 11:15:27 -0500 Subject: [PATCH] reviewers: make --project and --stable mutually exclusive When using the reviewers command to get stats on stable branch reviews, I always think I can specify --stable and --project nova to get nova stable reviews, but that's not how the command works and the --project option is ignored resulting in a report which I don't expect, i.e. there are non-nova reviewers in the report. This makes --project and --stable mutually exclusive to avoid that confusion. Change-Id: Ie9938f5e68f27b9a5a58635be2185365f041136f --- reviewstats/cmd/reviewers.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/reviewstats/cmd/reviewers.py b/reviewstats/cmd/reviewers.py index e232b8a..7bc0409 100755 --- a/reviewstats/cmd/reviewers.py +++ b/reviewstats/cmd/reviewers.py @@ -239,17 +239,26 @@ def main(argv=None): argv = sys.argv optparser = argparse.ArgumentParser() - optparser.add_argument( + # --stable and --project are mutually exclusive right now, so if + # --project is specified it's likely an attempt to only show stable + # reviews for a given project which isn't how --stable works right now + # unfortunately, so error out to let the user know they are trying to + # do something unsupported if both are specified. + # It would be a nice feature addition to allow specifying --project with + # --stable and filter the stable.json subprojects by the given project. + project_group = optparser.add_mutually_exclusive_group(required=False) + project_group.add_argument( '-p', '--project', default='projects/nova.json', - help='JSON file describing the project to generate stats for') + help='JSON file describing the project to generate stats for. ' + 'Mutually exclusive with --stable.') optparser.add_argument( - '-a', '--all', action='store_true', default=False, + '-a', '--all', action='store_true', help='Generate stats across all known projects (*.json)') - optparser.add_argument( + project_group.add_argument( '-s', '--stable', default='', metavar='BRANCH', help='Generate stats for the specified stable BRANCH ("havana") ' 'across all integrated projects. Specify "all" for all ' - 'open stable branches.') + 'open stable branches. Mutually exclusive with --project.') optparser.add_argument( '-o', '--output', default='-', help='Where to write output. If - stdout is used and only one output '