diff --git a/README.rst b/README.rst index 0e34477..d337ded 100644 --- a/README.rst +++ b/README.rst @@ -34,3 +34,14 @@ object containing the following keys: * core-team: A list of Gerrit usernames to consider as core reviewers across subprojects. * lp_projects: A list of Launchpad project ids to include. + +Examples +-------- + +#. Get reviewer stats for the last 14 days (default) in the stable/pike branch: + + ``$ reviewers --stable pike --output ~/reviewers-stable-pike-14`` + +#. Get reviewer stats for the last 90 days across all stable branches: + + ``$ reviewers --stable all --days 90 --output ~/reviewers-stable-all-90`` diff --git a/reviewstats/cmd/reviewers.py b/reviewstats/cmd/reviewers.py index 3db21f1..35e7c81 100755 --- a/reviewstats/cmd/reviewers.py +++ b/reviewstats/cmd/reviewers.py @@ -136,7 +136,11 @@ def write_pretty(reviewer_data, file_obj, options, reviewers, projects, else: project_name = projects[0]['name'] if options.stable: - project_name = "stable/%s" % (options.stable) + # Handle the wildcare case. + if options.stable.strip() == 'all': + project_name = 'all open stable branches' + else: + project_name = "stable/%s" % (options.stable) file_obj.write( 'Reviews for the last %d days in %s\n' % (options.days, project_name)) @@ -244,7 +248,8 @@ def main(argv=None): optparser.add_option( '-s', '--stable', default='', metavar='BRANCH', help='Generate stats for the specified stable BRANCH ("havana") ' - 'across all integrated projects') + 'across all integrated projects. Specify "all" for all ' + 'open stable branches.') optparser.add_option( '-o', '--output', default='-', help='Where to write output. If - stdout is used and only one output ' diff --git a/reviewstats/utils.py b/reviewstats/utils.py index d0ce068..81d591b 100644 --- a/reviewstats/utils.py +++ b/reviewstats/utils.py @@ -111,7 +111,8 @@ def get_changes(projects, ssh_user, ssh_key, only_open=False, stable='', :param bool only_open: If True, get only the not closed reviews. :param str stable: Name of the stable branch. If empty string, the changesets are not - filtered by any branch. + filtered by any branch. The special value "all" is handled to get + changes for all open stable branches. :return: List of de-serialized JSON changeset data as returned by gerrit. :rtype: list @@ -189,7 +190,11 @@ def get_changes(projects, ssh_user, ssh_key, only_open=False, stable='', if only_open: cmd += ' status:open' if stable: - cmd += ' branch:stable/%s' % stable + # Check for "all" to query all stable branches. + if stable.strip() == 'all': + cmd += ' branch:^stable/.*' + else: + cmd += ' branch:stable/%s' % stable if new_count: cmd += ' --start %d' % new_count else: