Skip to content

Commit

Permalink
[ci][chore] Refine release notes script (#2041)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCatLady authored Apr 25, 2024
1 parent c769c8b commit 451386e
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions tools/release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@ def parse_commit(row: list[str]) -> Commit:
brackets = re.findall("\\[([^]]+)]", msg)
if len(brackets) == 2:
component, group = brackets
if rewrite_group.get(component, component) in group_names:
if rewrite_group.get(group, group) not in group_names and rewrite_group.get(component, component) in group_names:
group, component = brackets
elif len(brackets) == 1:
component, group = brackets[0], "feat"
if rewrite_group.get(brackets[0], brackets[0]) in group_names:
component, group = "", brackets[0]
else:
component, group = brackets[0], "feat"
else:
component, group = "fix", "feat"
component, group = "", "fix"

msg_pr = re.fullmatch("(?:\\[[^]]+]\\s*){0,2}(.*)(\\(#(\\d+)\\))?", msg)
if len(msg_pr.groups()) == 2:
Expand All @@ -68,8 +71,8 @@ def parse_commit(row: list[str]) -> Commit:
return Commit(
commit_hash,
author,
rewrite_component.get(component, component),
rewrite_group.get(group, group),
re.sub("^(?:fix)?(?:inventory)?", "", rewrite_component.get(component, component)),
rewrite_group.get(group, group) if 'readme' not in message.lower() else 'docs',
message,
pr,
time,
Expand All @@ -93,9 +96,10 @@ def show_log(from_tag: str, to_tag: str):
print(f"\n### {group_names.get(group, group)}\n")
for commit in commits:
print(
f"- [`{commit.commit_hash}`](https://github.com/someengineering/fix/commit/{commit.commit_hash}) "
f'<span class="badge badge--secondary">{commit.component}</span> {commit.message}'
f"{f' ([#{commit.pr}](https://github.com/someengineering/fix/pull/{commit.pr}))' if commit.pr else ''}"
f"- [`{commit.commit_hash}`](https://github.com/someengineering/fixinventory/commit/{commit.commit_hash}) "
f"{f'<span class={chr(34)}badge badge--secondary{chr(34)}>{commit.component}</span> ' if commit.component else ''}"
f'{commit.message}'
f"{f' ([#{commit.pr}](https://github.com/someengineering/fixinventory/pull/{commit.pr}))' if commit.pr else ''}"
)

print("\n{/* truncate */}")
Expand Down

0 comments on commit 451386e

Please sign in to comment.