Skip to content

Commit

Permalink
Merge branch 'support-multiple-authors' of 'https://github.com/vchrom…
Browse files Browse the repository at this point in the history
…bie/release-tools'

Merges #50
Closes #50
Fixes #49
  • Loading branch information
sduenas committed Jul 4, 2022
2 parents e1dd4db + 5decf0d commit 419e2ca
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
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

0 comments on commit 419e2ca

Please sign in to comment.