Auto generate AUTHORS file for keystone component.

Bug: 976267

Now that git commits are gated by CLA, we shouldn't enforce
committers to add an entry in AUTHORS file. The AUTHORS file
should be generated automatically, based on git commits.

This commit fixes the problem.

* AUTHORS
  Remove this file.

* .gitignore
  Add AUTHORS file.

* keystone/openstack/common/setup.py
  generate_authors(): New method to create AUTHORS file. If
  AUTHORS.in file exists, append it's content to AUTHORS file.

* setup.py
  Import the new method.
  local_sdist.run(): Generate AUTHORS file before creating the
  package.

* tests/test_authors.py
  Remove this test case.

Change-Id: Id3ca59382e417d054d14f7735f30595bfbe2df48
This commit is contained in:
Bhuvan Arumugam 2012-04-21 02:13:45 -07:00
parent d65147bda7
commit 6c3d9c42cc
5 changed files with 27 additions and 180 deletions

1
.gitignore vendored
View File

@ -17,6 +17,7 @@ doc/source/modules.rst
doc/source/keystone.*
ChangeLog
requirements.txt
AUTHORS
build/
dist/
etc/keystone.conf

113
AUTHORS
View File

@ -1,113 +0,0 @@
Adam Gandelman <adamg@canonical.com>
Adam Young <ayoung@redhat.com>
Adipudi Praveena <padipudi@padipudi.(none)>
Akira YOSHIYAMA <akirayoshiyama@gmail.com>
Alan Pevec <apevec@redhat.com>
Alex Silva <alex.silva@M1BPAGY.(none)>
Alvaro Lopez Garcia <aloga@ifca.unican.es>
Andrew Bogott <abogott@wikimedia.org>
Andy Smith <github@anarkystic.com>
Anne Gentle <anne.gentle@rackspace.com>
annegentle <anne@openstack.org>
Anthony Young <sleepsonthefloor@gmail.com>
Brian Lamar <brian.lamar@gmail.com>
Brian Lamar <brian.lamar@rackspace.com>
Brian Waldon <bcwaldon@gmail.com>
Brian Waldon <brian.waldon@rackspace.com>
bsirish <sirish.bitra@gmail.com>
Carlos Marin <carlos.marin@rackspace.com>
Chmouel Boudjnah <chmouel@chmouel.com>
Chuck Short <chuck.short@canonical.com>
Cole Robinson <crobinso@redhat.com>
Dan Prince <dan.prince@rackspace.com>
Dan Prince <dprince@redhat.com>
Darren Birkett <darren.birkett@gmail.com>
dcramer <david.cramer@rackspace.com>
Dean Troyer <dtroyer@gmail.com>
Deepak Garg <deepakgarg.iitg@gmail.com>
Devin Carlen <devin.carlen@gmail.com>
Dolph Mathews <dolph.mathews@gmail.com>
Dolph Mathews <dolph.mathews@rackspace.com>
Ed Leafe <ed@leafe.com>
Édouard Thuleau <edouard1.thuleau@orange.com>
Eoghan Glynn <eglynn@redhat.com>
Ewan Mellor <ewan.mellor@citrix.com>
Gabriel Hurley <gabriel@strikeawe.com>
Ghe Rivero <ghe@debian.org>
gholt <gholt@brim.net>
Guang Yee <guang.yee@hp.com>
Hengqing Hu <hudayou@hotmail.com>
Ionuț Arțăriși <iartarisi@suse.cz>
jabdul <abdulkader.j@hcl.com>
James E. Blair <corvus@gnu.org>
James E. Blair <james.blair@rackspace.com>
James E. Blair <jeblair@hp.com>
Jason Cannavale <jason@cannavale.com>
Jay Pipes <jaypipes@gmail.com>
Jay Pipes <jpipes@uberbox.gateway.2wire.net>
Jesse Andrews <anotherjesse@gmail.com>
Joe Heck <heckj@mac.com>
Joe Savak <joe.savak@rackspace.com>
John Dickinson <me@not.mn>
John Eo <john.eo@rackspace.com>
John Eo <joon.eo@gmail.com>
Jorge L. Williams <jorge.williams@rackspace.com>
Joseph W. Breu <breu@breu.org>
Josh Kearney <josh@jk0.org>
Julien Danjou <julien.danjou@enovance.com>
Justin Santa Barbara <justin@fathomdb.com>
Justin Shepherd <jshepher@rackspace.com>
Kevin L. Mitchell <kevin.mitchell@rackspace.com>
Khaled Hussein <khaled.hussein@gmail.com>
Khaled Hussein <khaled.hussein@rackspace.com>
Kiall Mac Innes <kiall@managedit.ie>
KnightHacker <khaled.hussein@rackspace.com>
Liem Nguyen <liem_m_nguyen@hp.com>
Liem Nguyen <liem.m.nguyen@hp.com>
lzyeval <lzyeval@gmail.com>
Mark Gius <mgius7096@gmail.com>
Mark McLoughlin <markmc@redhat.com>
Maru Newby <mnewby@internap.com>
Michael Basnight <mbasnight@gmail.com>
Michael Still <mikal@stillhq.com>
Monty Taylor <mordred@inaugust.com>
Pádraig Brady <P@draigBrady.com>
Paul McMillan <paul.mcmillan@nebula.com>
Paul Voccio <paul@substation9.com>
Peng Yong <ppyy@pubyun.com>
Pete Zaitcev <zaitcev@kotori.zaitcev.us>
Ralf Haferkamp <rhafer@suse.de>
Ramana Juvvadi <ramana@venus.lekha.org>
Ramana Juvvadi <rjuvvadi@hcl.com>
Ramana Juvvadi <rrjuvvadi@gmail.com>
Robin Norwood <robin.norwood@gmail.com>
Ron Pedde <ron@pedde.com>
root <root@bsirish.(none)>
root <root@newapps.(none)>
Russell Bryant <rbryant@redhat.com>
saikrishna1511@gmail.com <psaikrishna@ubudesk1004.(none)>
Sai Krishna <saikrishna1511@gmail.com>
Salvatore Orlando <salvatore.orlando@eu.citrix.com>
Sandy Walsh <sandy@sandywalsh.com>
Shevek <shevek@nebula.com>
sirish bitra <sirish.bitra@gmail.com>
sirish.bitra <sirish.bitra@gmail.com>
sirishbitra <sirish.bitra@gmail.com>
Sony K. Philip <sony@hcleai.com>
termie <github@anarkystic.com>
Thierry Carrez <thierry@openstack.org>
Todd Willey <todd@rubidine.com>
Todd Willey <xtoddx@gmail.com>
Vishvananda Ishaya <vishvananda@gmail.com>
vishvananda <vishvananda@gmail.com>
Will Kelly <the.william.kelly@gmail.com>
Yaguang Tang <heut2008@gmail.com>
Yogeshwar Srikrishnan <yoga80@yahoo.com>
Yong Sheng Gong <gongysh@cn.ibm.com>
Yun Mao <yunmao@gmail.com>
Yuriy Taraday <yorik.sar@gmail.com>
Zhongyue Luo <lzyeval@gmail.com>
Ziad Sawalha <gihub@highbridgellc.com>
ziadsawalha <github@highbridgellc.com>
Ziad Sawalha <github@highbridgellc.com>
Ziad Sawalha <ziad.sawalha@rackspace.com>

View File

@ -37,8 +37,8 @@ def parse_mailmap(mailmap='.mailmap'):
def canonicalize_emails(changelog, mapping):
""" Takes in a string and an email alias mapping and replaces all
instances of the aliases in the string with their real email
"""Takes in a string and an email alias mapping and replaces all
instances of the aliases in the string with their real email.
"""
for alias, email in mapping.iteritems():
changelog = changelog.replace(alias, email)
@ -97,7 +97,7 @@ def _run_shell_command(cmd):
def write_vcsversion(location):
""" Produce a vcsversion dict that mimics the old one produced by bzr
"""Produce a vcsversion dict that mimics the old one produced by bzr.
"""
if os.path.isdir('.git'):
branch_nick_cmd = 'git branch | grep -Ei "\* (.*)" | cut -f2 -d" "'
@ -118,10 +118,30 @@ version_info = {
def write_git_changelog():
""" Write a changelog based on the git changelog """
"""Write a changelog based on the git changelog."""
if os.path.isdir('.git'):
git_log_cmd = 'git log --stat'
changelog = _run_shell_command(git_log_cmd)
mailmap = parse_mailmap()
with open("ChangeLog", "w") as changelog_file:
changelog_file.write(canonicalize_emails(changelog, mailmap))
def generate_authors():
"""Create AUTHORS file using git commits."""
jenkins_email = 'jenkins@review.openstack.org'
old_authors = 'AUTHORS.in'
new_authors = 'AUTHORS'
if os.path.isdir('.git'):
# don't include jenkins email address in AUTHORS file
git_log_cmd = "git log --format='%aN <%aE>' | sort -u | " \
"grep -v " + jenkins_email
changelog = _run_shell_command(git_log_cmd)
mailmap = parse_mailmap()
new_authors_fh = open(new_authors, "w")
new_authors_fh.write(canonicalize_emails(changelog, mailmap))
if os.path.exists(old_authors):
new_authors_fh.write("\n")
with open(old_authors, "r") as old_authors_fh:
new_authors_fh.write(''.join(old_authors_fh.readlines()))
new_authors_fh.close()

View File

@ -19,6 +19,7 @@ from setuptools.command.sdist import sdist
from setuptools import setup
import subprocess
from keystone.openstack.common.setup import generate_authors
from keystone.openstack.common.setup import parse_requirements
from keystone.openstack.common.setup import parse_dependency_links
from keystone.openstack.common.setup import write_requirements
@ -29,6 +30,7 @@ class local_sdist(sdist):
"""Customized sdist hook - builds the ChangeLog file from VC first"""
def run(self):
write_git_changelog()
generate_authors()
sdist.run(self)
cmdclass = {'sdist': local_sdist}

View File

@ -1,63 +0,0 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 OpenStack LLC
# Copyright 2012 Nebula Inc
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import commands
import os
import unittest
def parse_mailmap(mailmap='.mailmap'):
mapping = {}
if os.path.exists(mailmap):
fp = open(mailmap, 'r')
for l in fp:
l = l.strip()
if not l.startswith('#') and ' ' in l:
canonical_email, alias = l.split(' ')
mapping[alias] = canonical_email
return mapping
def str_dict_replace(s, mapping):
for s1, s2 in mapping.iteritems():
s = s.replace(s1, s2)
return s
class AuthorsTestCase(unittest.TestCase):
def test_authors_up_to_date(self):
root = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
contributors = set()
missing = set()
authors_file = open(os.path.join(root, 'AUTHORS'), 'r').read()
if os.path.exists(os.path.join(root, '.git')):
mailmap = parse_mailmap(os.path.join(root, '.mailmap'))
for email in commands.getoutput('git log --format=%ae').split():
if not email:
continue
if "jenkins" in email and "openstack.org" in email:
continue
email = '<' + email + '>'
contributors.add(str_dict_replace(email, mailmap))
for contributor in contributors:
if not contributor in authors_file:
missing.add(contributor)
self.assertTrue(len(missing) == 0,
'%r not listed in AUTHORS file.' % missing)