Merge "Add the ability to get reviewer stats across all stable branches"

This commit is contained in:
Zuul 2019-03-16 02:29:34 +00:00 committed by Gerrit Code Review
commit fe43551dfb
3 changed files with 25 additions and 4 deletions

View File

@ -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``

View File

@ -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 '

View File

@ -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: