From 6c3d9c42cc9f04ba99d89de7830675f6b59e2d25 Mon Sep 17 00:00:00 2001 From: Bhuvan Arumugam Date: Sat, 21 Apr 2012 02:13:45 -0700 Subject: 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 --- keystone/openstack/common/setup.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'keystone/openstack') diff --git a/keystone/openstack/common/setup.py b/keystone/openstack/common/setup.py index 9eabfcca..231b3384 100644 --- a/keystone/openstack/common/setup.py +++ b/keystone/openstack/common/setup.py @@ -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() -- cgit