Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[notes] Add support for multiple authors #50

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions release_tools/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,20 @@ def compose(self, project, entries):

authors = self._extract_authors(project)

def _check_author_exists_already(author):
if author not in authors:
authors.append(author)

for _, entry_list in sorted(entries.items()):
for entry in ReleaseNotesComposer._sort_entries_by_id(entry_list):
if not entry.author:
continue
if entry.author not in authors:
authors.append(entry.author)

if type(entry.author) is list:
for author in entry.author:
_check_author_exists_already(author)
else:
_check_author_exists_already(entry.author)

content = ""

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Notes command supports multiple authors in changelog entries
category: added
author:
issue: 49
notes: >
The notes command supports exporting of multiple authors
from the changelog entries. You can add more than one
author to the changelog entry by defining them as
```
author:
- John Smith <jsmith@example.com>
- John Doe <jdoe@example.com>
```
6 changes: 3 additions & 3 deletions tests/test_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

AUTHORS_FILE_ORIGINAL_CONTENT = """jdoe\n\n"""
AUTHORS_FILE_ORIGINAL_CONTENT_NO_NEW_LINE = """jdoe"""
AUTHORS_FILE_CONTENT = """jdoe\njsmith\n\n"""
AUTHORS_FILE_CONTENT = """jdoe\njsmith\njwick\n\n"""
RELEASE_NOTES_FILE_ALREADY_EXISTS_ERROR = (
"Error: Release notes for version 0.8.10 already exist. Use '--overwrite' to replace it."
)
Expand Down Expand Up @@ -121,7 +121,7 @@ def setup_unreleased_entries(dirpath):
CategoryChange.ADDED,
CategoryChange.FIXED,
]
authors = ['jsmith', 'jdoe', 'jsmith', 'jdoe', 'jsmith']
authors = ['jsmith', 'jdoe', '\n- jsmith\n- jdoe\n- jwick', 'jdoe', 'jsmith']
issues = [1, 2, 3, 'null', 'null']
notes = [True, False, False, False, True]
notes_txt = (
Expand Down Expand Up @@ -389,7 +389,7 @@ def test_authors_empty_file(self, mock_project):
with open(authors_file, 'r') as fd:
text = fd.read()

expected = """jsmith\njdoe\n\n"""
expected = """jsmith\njdoe\njwick\n\n"""
self.assertEqual(text, expected)

@unittest.mock.patch('release_tools.notes.ReleaseNotesComposer._datetime_utcnow_str')
Expand Down