Merge "Improve AUTHORS file generation"
This commit is contained in:
commit
344187c8a7
@ -273,27 +273,36 @@ def generate_authors(git_dir=None, dest_dir='.', option_dict=dict()):
|
|||||||
if git_dir is None:
|
if git_dir is None:
|
||||||
git_dir = _get_git_directory()
|
git_dir = _get_git_directory()
|
||||||
if git_dir:
|
if git_dir:
|
||||||
|
authors = []
|
||||||
|
|
||||||
# don't include jenkins email address in AUTHORS file
|
# don't include jenkins email address in AUTHORS file
|
||||||
git_log_cmd = ("git --git-dir=" + git_dir +
|
git_log_cmd = ("git --git-dir=" + git_dir +
|
||||||
" log --format='%aN <%aE>' | sort -u | "
|
" log --format='%aN <%aE>'"
|
||||||
"egrep -v '" + ignore_emails + "'")
|
" | egrep -v '" + ignore_emails + "'")
|
||||||
changelog = _run_shell_command(git_log_cmd)
|
authors += _run_shell_command(git_log_cmd).split('\n')
|
||||||
signed_cmd = ("git log --git-dir=" + git_dir +
|
|
||||||
" | grep -i Co-authored-by: | sort -u")
|
# get all co-authors from commit messages
|
||||||
signed_entries = _run_shell_command(signed_cmd)
|
co_authors_cmd = ("git log --git-dir=" + git_dir +
|
||||||
if signed_entries:
|
" | grep -i Co-authored-by:")
|
||||||
new_entries = "\n".join(
|
co_authors = _run_shell_command(co_authors_cmd)
|
||||||
[signed.split(":", 1)[1].strip()
|
|
||||||
for signed in signed_entries.split("\n") if signed])
|
co_authors = [signed.split(":", 1)[1].strip()
|
||||||
changelog = "\n".join((changelog, new_entries))
|
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:
|
with open(new_authors, 'wb') as new_authors_fh:
|
||||||
if os.path.exists(old_authors):
|
if os.path.exists(old_authors):
|
||||||
with open(old_authors, "rb") as old_authors_fh:
|
with open(old_authors, "rb") as old_authors_fh:
|
||||||
new_authors_fh.write(old_authors_fh.read())
|
new_authors_fh.write(old_authors_fh.read())
|
||||||
new_authors_fh.write(canonicalize_emails(
|
new_authors_fh.write(('\n'.join(authors) + '\n')
|
||||||
changelog, mailmap).encode('utf-8'))
|
.encode('utf-8'))
|
||||||
|
|
||||||
|
|
||||||
_rst_template = """%(heading)s
|
_rst_template = """%(heading)s
|
||||||
|
@ -79,7 +79,7 @@ class TestPackagingInGitRepoWithoutCommit(tests.BaseTestCase):
|
|||||||
# No commits, no authors in list
|
# No commits, no authors in list
|
||||||
with open(os.path.join(self.package_dir, 'AUTHORS'), 'r') as f:
|
with open(os.path.join(self.package_dir, 'AUTHORS'), 'r') as f:
|
||||||
body = f.read()
|
body = f.read()
|
||||||
self.assertEqual(body, '')
|
self.assertEqual(body, '\n')
|
||||||
|
|
||||||
def test_changelog(self):
|
def test_changelog(self):
|
||||||
# No commits, nothing should be in the ChangeLog list
|
# No commits, nothing should be in the ChangeLog list
|
||||||
|
Loading…
Reference in New Issue
Block a user