From 3b695e11da34247123ea919e71096e53393f227b Mon Sep 17 00:00:00 2001 From: Soren Hansen Date: Thu, 11 Nov 2010 19:52:36 -0600 Subject: Added a .mailmap that maps addresses in bzr to people's real, preferred e-mail addresses. (I made a few guesses along the way, feel free to adjust according to what is actually the preferred e-mail) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added a couple of methods to nova.utils to parse said .mailmap and do the appropriate (though highly naïve) replacement. Apply mailmap replacement in changelog generation in setup.py. Add a unit test that checks everyone is properly listed in Authors. Add sleepsonthefloor to Authors. If anyone knows the real name, please add it. --- .mailmap | 24 +++++++++++++++++++++++ Authors | 1 + nova/tests/misc_unittest.py | 48 +++++++++++++++++++++++++++++++++++++++++++++ nova/utils.py | 16 +++++++++++++++ run_tests.py | 5 +++-- setup.py | 10 ++++++---- 6 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 .mailmap create mode 100644 nova/tests/misc_unittest.py diff --git a/.mailmap b/.mailmap new file mode 100644 index 000000000..cf79dc95c --- /dev/null +++ b/.mailmap @@ -0,0 +1,24 @@ +# Format is: +# + + + + + + + + + + + + + + + + + + + + + + diff --git a/Authors b/Authors index ec3a1cbd8..87ebb55d7 100644 --- a/Authors +++ b/Authors @@ -19,3 +19,4 @@ Rick Clark Soren Hansen Todd Willey Vishvananda Ishaya +¿¿¿??? diff --git a/nova/tests/misc_unittest.py b/nova/tests/misc_unittest.py new file mode 100644 index 000000000..856060afa --- /dev/null +++ b/nova/tests/misc_unittest.py @@ -0,0 +1,48 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 OpenStack LLC +# +# 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 os +import subprocess + +from nova import test +from nova.utils import parse_mailmap, str_dict_replace + + +class ProjectTestCase(test.TrialTestCase): + def test_authors_up_to_date(self): + if os.path.exists('../.bzr'): + log_cmd = subprocess.Popen(["bzr", "log", "-n0"], + stdout=subprocess.PIPE) + changelog = log_cmd.communicate()[0] + mailmap = parse_mailmap('../.mailmap') + + contributors = set() + for l in changelog.split('\n'): + l = l.strip() + if (l.startswith('author:') or l.startswith('committer:') + and not l == 'committer: Tarmac'): + email = l.split(' ')[-1] + contributors.add(str_dict_replace(email, mailmap)) + + authors_file = open('../Authors', 'r').read() + + missing = set() + for contributor in contributors: + if not contributor in authors_file: + missing.add(contributor) + + self.assertTrue(len(missing) == 0, + '%r not listed in Authors' % missing) diff --git a/nova/utils.py b/nova/utils.py index e7892a212..b63237c10 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -173,6 +173,22 @@ def isotime(at=None): def parse_isotime(timestr): return datetime.datetime.strptime(timestr, TIME_FORMAT) +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 LazyPluggable(object): """A pluggable backend loaded lazily based on some value.""" diff --git a/run_tests.py b/run_tests.py index 9a2f40dc9..3d427d8af 100644 --- a/run_tests.py +++ b/run_tests.py @@ -49,11 +49,12 @@ from nova import flags from nova import twistd from nova.tests.access_unittest import * -from nova.tests.auth_unittest import * from nova.tests.api_unittest import * +from nova.tests.auth_unittest import * from nova.tests.cloud_unittest import * from nova.tests.compute_unittest import * from nova.tests.flags_unittest import * +from nova.tests.misc_unittest import * from nova.tests.network_unittest import * from nova.tests.objectstore_unittest import * from nova.tests.process_unittest import * @@ -64,8 +65,8 @@ from nova.tests.service_unittest import * from nova.tests.twistd_unittest import * from nova.tests.validator_unittest import * from nova.tests.virt_unittest import * -from nova.tests.volume_unittest import * from nova.tests.virt_unittest import * +from nova.tests.volume_unittest import * FLAGS = flags.FLAGS diff --git a/setup.py b/setup.py index a333fbf64..da1e5f8c9 100644 --- a/setup.py +++ b/setup.py @@ -16,12 +16,13 @@ # License for the specific language governing permissions and limitations # under the License. -from setuptools import setup, find_packages -from setuptools.command.sdist import sdist - import os import subprocess +from setuptools import setup, find_packages +from setuptools.command.sdist import sdist + +from nova.util import parse_mailmap, str_dict_replace class local_sdist(sdist): """Customized sdist hook - builds the ChangeLog file from VC first""" @@ -34,8 +35,9 @@ class local_sdist(sdist): log_cmd = subprocess.Popen(["bzr", "log", "--novalog"], stdout=subprocess.PIPE, env=env) changelog = log_cmd.communicate()[0] + mailmap = parse_mailmap() with open("ChangeLog", "w") as changelog_file: - changelog_file.write(changelog) + changelog_file.write(str_dict_replace(changelog, mailmap)) sdist.run(self) setup(name='nova', -- cgit