Skip to content

Commit

Permalink
[Automation] Print release notes even if some commits failed parsing (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Tankilevitch committed Dec 2, 2021
1 parent e3675f5 commit 00ad602
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions automation/release_notes/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def __init__(
"guy1992l": "guy1992l",
"Nick Brown": "ihs-nick",
"Oded Messer": "omesser",
"Tom Tankilevitch": "tankilevitch",
}

def run(self):
Expand Down Expand Up @@ -105,12 +106,14 @@ def run(self):
def _generate_release_notes_from_commits(
self, commits_for_highlights, commits_for_pull_requests
):
highlight_notes = self._generate_highlight_notes_from_commits(
commits_for_highlights
)
(
highlight_notes,
failed_parsing_commits,
) = self._generate_highlight_notes_from_commits(commits_for_highlights)
# currently we just put everything under features / enhancements
# TODO: enforce a commit message convention which will allow to parse whether it's a feature/enhancement or
# bug fix
failed_commits = "\n".join(failed_parsing_commits)
print(
f"""
### Features / Enhancements
Expand All @@ -123,14 +126,24 @@ def _generate_release_notes_from_commits(
#### Pull requests:
{commits_for_pull_requests}
#### Failed parsing:
{failed_commits}
"""
)

raise ValueError(
"Failed parsing some of the commits, added them at the end of the release notes"
)

def _generate_highlight_notes_from_commits(self, commits):
highlighted_notes = ""
failed_parsing_commits = []
for commit in commits.split("\n"):
match = re.fullmatch(self.commit_regex, commit)
assert match is not None, f"Commit did not matched regex. {commit}"
if match is None:
failed_parsing_commits.append(commit)
break
scope = match.groupdict()["scope"] or "Unknown"
message = match.groupdict()["commitMessage"]
pull_request_number = match.groupdict()["pullRequestNumber"]
Expand All @@ -141,7 +154,7 @@ def _generate_highlight_notes_from_commits(self, commits):
f"* **{scope}**: {message}, {pull_request_number}, @{github_username}\n"
)

return highlighted_notes
return highlighted_notes, failed_parsing_commits

def _resolve_github_username(self, commit_id, username):
"""
Expand Down

0 comments on commit 00ad602

Please sign in to comment.