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
This commit is contained in:
Thierry Carrez 2014-02-14 15:48:54 +01:00
parent 2f5fb00f58
commit 4bb58b50f5
3 changed files with 59 additions and 5 deletions

42
projects/stable.json Normal file
View File

@ -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"
]
}

View File

@ -229,6 +229,10 @@ def main(argv=None):
optparser.add_option( optparser.add_option(
'-a', '--all', action='store_true', '-a', '--all', action='store_true',
help='Generate stats across all known projects (*.json)') 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( optparser.add_option(
'-o', '--output', default='-', '-o', '--output', default='-',
help='Where to write output. If - stdout is used and only one output' help='Where to write output. If - stdout is used and only one output'
@ -250,6 +254,9 @@ def main(argv=None):
options, args = optparser.parse_args() options, args = optparser.parse_args()
if options.stable:
projects = utils.get_projects_info('projects/stable.json', False)
else:
projects = utils.get_projects_info(options.project, options.all) projects = utils.get_projects_info(options.project, options.all)
if not projects: if not projects:
@ -273,7 +280,8 @@ def main(argv=None):
} }
for project in projects: 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: for change in changes:
patch_for_change = False patch_for_change = False
first_patchset = True first_patchset = True

View File

@ -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'): server='review.openstack.org'):
all_changes = [] all_changes = []
@ -69,10 +69,12 @@ def get_changes(projects, ssh_user, ssh_key, only_open=False,
changes = [] changes = []
logging.debug('Getting changes for project %s' % project['name']) 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). # Only use the cache for *all* changes (the entire history).
# Requesting only the open changes isn't nearly as big of a deal, # Requesting only the open changes isn't nearly as big of a deal,
# so just get the current data. # 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'] pickle_fn = '.%s-changes.pickle' % project['name']
if os.path.isfile(pickle_fn): 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)) '--format JSON' % projects_q(project))
if only_open: if only_open:
cmd += ' status:open' cmd += ' status:open'
if stable:
cmd += ' branch:stable/%s' % stable
if changes: if changes:
cmd += ' resume_sortkey:%s' % changes[-2]['sortKey'] cmd += ' resume_sortkey:%s' % changes[-2]['sortKey']
stdin, stdout, stderr = client.exec_command(cmd) 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: if changes[-1]['rowCount'] == 0:
break break
if not only_open: if not only_open and not stable:
with open(pickle_fn, 'w') as f: with open(pickle_fn, 'w') as f:
pickle.dump(changes, f) pickle.dump(changes, f)