From 4bb58b50f51421ee9c731985af11a0f074c76ad7 Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Fri, 14 Feb 2014 15:48:54 +0100 Subject: [PATCH] Support reviewers stats for stable branches Adds a "-s" option that lets you specify the name of a stable branch (for example "-s havana") instead of specifying a project (-p) or all projects (-a). reviewers.py will then use a specific stable.json file that defines the set of projects stable-maint-core has authority on, as well as the contents of that core team. Note: -s disables result caching since the search is made on specific branches, which would pollute the general purpose cache. Change-Id: Idd03f51c98e006972bc93e3ce11e052cd1cc26aa --- projects/stable.json | 42 ++++++++++++++++++++++++++++++++++++ reviewstats/cmd/reviewers.py | 12 +++++++++-- reviewstats/utils.py | 10 ++++++--- 3 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 projects/stable.json diff --git a/projects/stable.json b/projects/stable.json new file mode 100644 index 0000000..eac6d71 --- /dev/null +++ b/projects/stable.json @@ -0,0 +1,42 @@ +{ + "name": "stable", + "unofficial": true, + "subprojects": [ + "openstack/nova", + "openstack/swift", + "openstack/glance", + "openstack/heat", + "openstack/ceilometer", + "openstack/keystone", + "openstack/cinder", + "openstack/neutron", + "openstack/horizon" + ], + "core-team": [ + "arosen", + "gandelman-a", + "apevec", + "zulcss", + "danms", + "davewalker", + "david-lyle", + "dolph", + "doug-hellmann", + "eglynn", + "flaper87", + "gabriel-hurley", + "john-griffith", + "jdanjou", + "markmc", + "markwash", + "treinish", + "mrunge", + "russellb", + "stevebaker", + "shardy", + "vishvananda", + "garyk", + "markmcclain", + "p-draigbrady" + ] +} diff --git a/reviewstats/cmd/reviewers.py b/reviewstats/cmd/reviewers.py index a445ede..9c50884 100755 --- a/reviewstats/cmd/reviewers.py +++ b/reviewstats/cmd/reviewers.py @@ -229,6 +229,10 @@ def main(argv=None): optparser.add_option( '-a', '--all', action='store_true', help='Generate stats across all known projects (*.json)') + optparser.add_option( + '-s', '--stable', default='', metavar='BRANCH', + help='Generate stats for the specified stable BRANCH ("havana") ' + 'across all integrated projects') optparser.add_option( '-o', '--output', default='-', help='Where to write output. If - stdout is used and only one output' @@ -250,7 +254,10 @@ def main(argv=None): options, args = optparser.parse_args() - projects = utils.get_projects_info(options.project, options.all) + if options.stable: + projects = utils.get_projects_info('projects/stable.json', False) + else: + projects = utils.get_projects_info(options.project, options.all) if not projects: print "Please specify a project." @@ -273,7 +280,8 @@ def main(argv=None): } for project in projects: - changes = utils.get_changes([project], options.user, options.key) + changes = utils.get_changes([project], options.user, options.key, + stable=options.stable) for change in changes: patch_for_change = False first_patchset = True diff --git a/reviewstats/utils.py b/reviewstats/utils.py index 334b62b..0824d35 100644 --- a/reviewstats/utils.py +++ b/reviewstats/utils.py @@ -57,7 +57,7 @@ def projects_q(project): ')') -def get_changes(projects, ssh_user, ssh_key, only_open=False, +def get_changes(projects, ssh_user, ssh_key, only_open=False, stable='', server='review.openstack.org'): all_changes = [] @@ -69,10 +69,12 @@ def get_changes(projects, ssh_user, ssh_key, only_open=False, changes = [] logging.debug('Getting changes for project %s' % project['name']) - if not only_open: + if not only_open and not stable: # Only use the cache for *all* changes (the entire history). # Requesting only the open changes isn't nearly as big of a deal, # so just get the current data. + # Also do not use cache for stable stats as they cover different + # results. pickle_fn = '.%s-changes.pickle' % project['name'] if os.path.isfile(pickle_fn): @@ -89,6 +91,8 @@ def get_changes(projects, ssh_user, ssh_key, only_open=False, '--format JSON' % projects_q(project)) if only_open: cmd += ' status:open' + if stable: + cmd += ' branch:stable/%s' % stable if changes: cmd += ' resume_sortkey:%s' % changes[-2]['sortKey'] stdin, stdout, stderr = client.exec_command(cmd) @@ -97,7 +101,7 @@ def get_changes(projects, ssh_user, ssh_key, only_open=False, if changes[-1]['rowCount'] == 0: break - if not only_open: + if not only_open and not stable: with open(pickle_fn, 'w') as f: pickle.dump(changes, f)