Auto generate AUTHORS file for glanceclient 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.

* glanceclient/openstack/common/setup.py
  Sync changes from openstack-common.

* setup.py
  Generate AUTHORS file before creating the package.

* glanceclient/shell.py
  Pep8 fix.

* tests/test_authors.py
  Remove this test case.

Change-Id: I9e9d4da5ca3b147b483250dcf25a3b2a840123c2
This commit is contained in:
Bhuvan Arumugam 2012-06-01 23:38:12 -07:00
parent b9b8972528
commit a1f8ea1c7f
6 changed files with 18 additions and 75 deletions

1
.gitignore vendored
View File

@ -6,6 +6,7 @@ cover
.idea
*.swp
*~
AUTHORS
build
dist
python_glanceclient.egg-info

View File

@ -1,9 +0,0 @@
Brian Waldon <bcwaldon@gmail.com>
Jay Pipes <jaypipes@gmail.com>
Monty Taylor <mordred@inaugust.com>
Dean Troyer <dtroyer@gmail.com>
Gabriel Hurley <gabriel@strikeawe.com>
James E. Blair <jeblair@hp.com>
Chuck Short <chuck.short@canonical.com>
Michael Basnight <mbasnight@gmail.com>
Thierry Carrez <thierry@openstack.org>

View File

@ -61,14 +61,21 @@ def parse_requirements(requirements_files=['requirements.txt',
'tools/pip-requires']):
requirements = []
for line in get_reqs_from_files(requirements_files):
# For the requirements list, we need to inject only the portion
# after egg= so that distutils knows the package it's looking for
# such as:
# -e git://github.com/openstack/nova/master#egg=nova
if re.match(r'\s*-e\s+', line):
requirements.append(re.sub(r'\s*-e\s+.*#egg=(.*)$', r'\1',
line))
elif re.match(r'\s*-f\s+', line):
pass
# such as:
# http://github.com/openstack/nova/zipball/master#egg=nova
elif re.match(r'\s*https?:', line):
requirements.append(re.sub(r'\s*https?:.*#egg=(.*)$', r'\1',
line))
# -f lines are for index locations, and don't get used here
elif re.match(r'\s*-f\s+', line):
pass
else:
requirements.append(line)
@ -78,11 +85,16 @@ def parse_requirements(requirements_files=['requirements.txt',
def parse_dependency_links(requirements_files=['requirements.txt',
'tools/pip-requires']):
dependency_links = []
# dependency_links inject alternate locations to find packages listed
# in requirements
for line in get_reqs_from_files(requirements_files):
# skip comments and blank lines
if re.match(r'(\s*#)|(\s*$)', line):
continue
# lines with -e or -f need the whole line, minus the flag
if re.match(r'\s*-[ef]\s+', line):
dependency_links.append(re.sub(r'\s*-[ef]\s+', '', line))
# lines that are only urls can go in unmolested
elif re.match(r'\s*https?:', line):
dependency_links.append(line)
return dependency_links

View File

@ -36,7 +36,7 @@ class OpenStackImagesShell(object):
parser = argparse.ArgumentParser(
prog='glance',
description=__doc__.strip(),
epilog='See "glance help COMMAND" '\
epilog='See "glance help COMMAND" '
'for help on a specific command.',
add_help=False,
formatter_class=HelpFormatter,

View File

@ -3,6 +3,7 @@ import sys
import setuptools
from glanceclient.openstack.common.setup import generate_authors
from glanceclient.openstack.common.setup import parse_requirements
from glanceclient.openstack.common.setup import parse_dependency_links
from glanceclient.openstack.common.setup import write_git_changelog
@ -12,6 +13,7 @@ requires = parse_requirements()
dependency_links = parse_dependency_links()
tests_require = parse_requirements(['tools/test-requires'])
write_git_changelog()
generate_authors()
if sys.version_info < (2, 6):
requires.append('simplejson')

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)