Skip to content

Commit 3c7350b

Browse files
committed
Auto generate AUTHORS for python-openstackclient.
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. * tests/test_authors.py Remove this test case. * .gitignore Add AUTHORS file. * openstackclient/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. Generate AUTHORS file before creating the package. Change-Id: Ia5488a43f88e13a0fb1f7a5d8d10a576b9034dc8
1 parent 67ea436 commit 3c7350b

5 files changed

Lines changed: 15 additions & 73 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*~
55
.openstackclient-venv
66
.venv
7+
AUTHORS
78
build
89
dist
910
python_openstackclient.egg-info

AUTHORS

Lines changed: 0 additions & 3 deletions
This file was deleted.

openstackclient/openstack/common/setup.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def parse_mailmap(mailmap='.mailmap'):
3737

3838

3939
def canonicalize_emails(changelog, mapping):
40-
""" Takes in a string and an email alias mapping and replaces all
41-
instances of the aliases in the string with their real email
40+
"""Takes in a string and an email alias mapping and replaces all
41+
instances of the aliases in the string with their real email.
4242
"""
4343
for alias, email in mapping.iteritems():
4444
changelog = changelog.replace(alias, email)
@@ -97,7 +97,7 @@ def _run_shell_command(cmd):
9797

9898

9999
def write_vcsversion(location):
100-
""" Produce a vcsversion dict that mimics the old one produced by bzr
100+
"""Produce a vcsversion dict that mimics the old one produced by bzr.
101101
"""
102102
if os.path.isdir('.git'):
103103
branch_nick_cmd = 'git branch | grep -Ei "\* (.*)" | cut -f2 -d" "'
@@ -118,7 +118,7 @@ def write_vcsversion(location):
118118

119119

120120
def write_git_changelog():
121-
"""Write a changelog based on the git changelog"""
121+
"""Write a changelog based on the git changelog."""
122122
if os.path.isdir('.git'):
123123
git_log_cmd = 'git log --stat'
124124
changelog = _run_shell_command(git_log_cmd)
@@ -128,13 +128,18 @@ def write_git_changelog():
128128

129129

130130
def generate_authors():
131-
"""Create AUTHORS file using git commits"""
131+
"""Create AUTHORS file using git commits."""
132132
jenkins_email = 'jenkins@review.openstack.org'
133+
old_authors = 'AUTHORS.in'
134+
new_authors = 'AUTHORS'
133135
if os.path.isdir('.git'):
134136
# don't include jenkins email address in AUTHORS file
135137
git_log_cmd = "git log --format='%aN <%aE>' | sort -u | " \
136138
"grep -v " + jenkins_email
137139
changelog = _run_shell_command(git_log_cmd)
138140
mailmap = parse_mailmap()
139-
with open("AUTHORS", "w") as authors_file:
140-
authors_file.write(canonicalize_emails(changelog, mailmap))
141+
with open(new_authors, 'w') as new_authors_fh:
142+
new_authors_fh.write(canonicalize_emails(changelog, mailmap))
143+
if os.path.exists(old_authors):
144+
with open(old_authors, "r") as old_authors_fh:
145+
new_authors_fh.write('\n' + old_authors_fh.read())

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import setuptools
44

5+
from openstackclient.openstack.common.setup import generate_authors
56
from openstackclient.openstack.common.setup import parse_requirements
67
from openstackclient.openstack.common.setup import parse_dependency_links
78
from openstackclient.openstack.common.setup import write_git_changelog
@@ -10,6 +11,7 @@
1011
requires = parse_requirements()
1112
dependency_links = parse_dependency_links()
1213
write_git_changelog()
14+
generate_authors()
1315

1416

1517
def read(fname):

tests/test_authors.py

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)