summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-08-04 15:17:24 +0000
committerGerrit Code Review <review@openstack.org>2013-08-04 15:17:24 +0000
commit344187c8a72125a2abcec02f5e17846d8357ec99 (patch)
treebeb13c905d0feb51a24d2c7d480ccaed1e13bb1d
parent9004973d42867a215043b0b8654983efc02d0d17 (diff)
parent44ba87493d2c3ccf9e1af541284365ea44f911ac (diff)
downloadpbr-344187c8a72125a2abcec02f5e17846d8357ec99.tar.gz
Merge "Improve AUTHORS file generation"
-rw-r--r--pbr/packaging.py37
-rw-r--r--pbr/tests/test_packaging.py2
2 files changed, 24 insertions, 15 deletions
diff --git a/pbr/packaging.py b/pbr/packaging.py
index 366f21e..763ba45 100644
--- a/pbr/packaging.py
+++ b/pbr/packaging.py
@@ -273,27 +273,36 @@ def generate_authors(git_dir=None, dest_dir='.', option_dict=dict()):
if git_dir is None:
git_dir = _get_git_directory()
if git_dir:
+ authors = []
+
# don't include jenkins email address in AUTHORS file
git_log_cmd = ("git --git-dir=" + git_dir +
- " log --format='%aN <%aE>' | sort -u | "
- "egrep -v '" + ignore_emails + "'")
- changelog = _run_shell_command(git_log_cmd)
- signed_cmd = ("git log --git-dir=" + git_dir +
- " | grep -i Co-authored-by: | sort -u")
- signed_entries = _run_shell_command(signed_cmd)
- if signed_entries:
- new_entries = "\n".join(
- [signed.split(":", 1)[1].strip()
- for signed in signed_entries.split("\n") if signed])
- changelog = "\n".join((changelog, new_entries))
+ " log --format='%aN <%aE>'"
+ " | egrep -v '" + ignore_emails + "'")
+ authors += _run_shell_command(git_log_cmd).split('\n')
+
+ # get all co-authors from commit messages
+ co_authors_cmd = ("git log --git-dir=" + git_dir +
+ " | grep -i Co-authored-by:")
+ co_authors = _run_shell_command(co_authors_cmd)
+
+ co_authors = [signed.split(":", 1)[1].strip()
+ for signed in co_authors.split('\n') if signed]
+
+ authors += co_authors
+
+ # canonicalize emails, remove duplicates and sort
+ mailmap = read_git_mailmap(git_dir)
+ authors = canonicalize_emails('\n'.join(authors), mailmap)
+ authors = authors.split('\n')
+ authors = sorted(set(authors))
- mailmap = read_git_mailmap()
with open(new_authors, 'wb') as new_authors_fh:
if os.path.exists(old_authors):
with open(old_authors, "rb") as old_authors_fh:
new_authors_fh.write(old_authors_fh.read())
- new_authors_fh.write(canonicalize_emails(
- changelog, mailmap).encode('utf-8'))
+ new_authors_fh.write(('\n'.join(authors) + '\n')
+ .encode('utf-8'))
_rst_template = """%(heading)s
diff --git a/pbr/tests/test_packaging.py b/pbr/tests/test_packaging.py
index 7461c0f..562b10e 100644
--- a/pbr/tests/test_packaging.py
+++ b/pbr/tests/test_packaging.py
@@ -79,7 +79,7 @@ class TestPackagingInGitRepoWithoutCommit(tests.BaseTestCase):
# No commits, no authors in list
with open(os.path.join(self.package_dir, 'AUTHORS'), 'r') as f:
body = f.read()
- self.assertEqual(body, '')
+ self.assertEqual(body, '\n')
def test_changelog(self):
# No commits, nothing should be in the ChangeLog list