Skip to content

Commit

Permalink
Merge "Auto generate AUTHORS file for keystone component."
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed May 1, 2012
2 parents ac3d314 + 6c3d9c4 commit d62a913
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 180 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -17,6 +17,7 @@ doc/source/modules.rst
doc/source/keystone.*
ChangeLog
requirements.txt
AUTHORS
build/
dist/
etc/keystone.conf
113 changes: 0 additions & 113 deletions AUTHORS

This file was deleted.

28 changes: 24 additions & 4 deletions keystone/openstack/common/setup.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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" "'
Expand All @@ -118,10 +118,30 @@ def write_vcsversion(location):


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()
2 changes: 2 additions & 0 deletions setup.py
Expand Up @@ -19,6 +19,7 @@
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
Expand All @@ -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}

Expand Down
63 changes: 0 additions & 63 deletions tests/test_authors.py

This file was deleted.

0 comments on commit d62a913

Please sign in to comment.