From 7159d5e885535b7cbbcc86077ed238af842d2494 Mon Sep 17 00:00:00 2001 From: Robert Adam Date: Sat, 20 Mar 2021 19:14:39 +0100 Subject: MAINT: Make changelog script more robust The assumptions about the format of the merge commit message were rather strict and thus slight deviations would cause the script to fail. Therefore the script got overhauled and is now using a (hopefully) more versatile RegEx to do the job. --- scripts/generateChangelog.py | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/scripts/generateChangelog.py b/scripts/generateChangelog.py index f6cf1c03c..af2576c33 100755 --- a/scripts/generateChangelog.py +++ b/scripts/generateChangelog.py @@ -8,6 +8,7 @@ import argparse import platform import subprocess +import re from commitMessage.CommitMessage import CommitMessage, CommitFormatError @@ -19,19 +20,6 @@ def cmd(args): raise Exception('cmd(): {0} failed with status {1}: {2}'.format(args, p.returncode, stderr)) return stdout.decode('utf-8') -def isRelevantCommit(commitLine): - if commitLine.strip() == "": - return False - - components = commitLine.split() - - if len(components) < 2: - return False - - # First component is commit hash - # We only consider merge commits to be relevant - return components[1].lower() == "merge" - def formatChangeLine(line, prNumber, target): if target == "github": return "- {} (#{})".format(line, prNumber) @@ -49,8 +37,9 @@ def main(): default="other") args = parser.parse_args() + mergeCommitPattern = re.compile("^([0-9a-f]+)\s*[Mm]erge\s.+?#(\d+):?\s*(.+)$", re.MULTILINE) + commits = cmd(["git", "log" ,"--format=oneline", "--date=short", "{}..{}".format(args.FROM_TAG, args.TO_TAG)]).split("\n") - commits = list(filter(isRelevantCommit, commits)) serverChanges = [] clientChanges = [] @@ -60,21 +49,15 @@ def main(): skipTypes = set(["FORMAT", "DOCS", "TEST", "MAINT", "CI", "REFAC", "BUILD", "TRANSLATION"]) for commitLine in commits: - parts = commitLine.split(maxsplit=1) - commitHash = parts[0] - commitTitle = parts[1] - - assert ":" in commitTitle - assert "#" in commitTitle + match = re.match(mergeCommitPattern, commitLine) - prTagStart = commitTitle.find("#") - prTagEnd = commitTitle.find(":") - assert prTagStart + 1 < prTagEnd + if not match: + # Commit doesn't match the expected pattern and is thus ignored + continue - # Extract PR number - prNumber = commitTitle[prTagStart + 1 : prTagEnd] - # Cut out PR information from commit title - commitTitle = commitTitle[prTagEnd + 1 : ].strip() + commitHash = match.group(1) + prNumber = match.group(2) + commitTitle = match.group(3) try: commit = CommitMessage(commitTitle) -- cgit v1.2.3 From 8a9a915c1be0d02b54b994e2875a3b08f9443fc2 Mon Sep 17 00:00:00 2001 From: Robert Adam Date: Sat, 20 Mar 2021 19:29:52 +0100 Subject: MAINT: Extend grouping in changelog script This commit adds a few more grouping rules to the generateChangelog.py script which should further reduce the manual labor needed to create changelogs. --- scripts/generateChangelog.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/scripts/generateChangelog.py b/scripts/generateChangelog.py index af2576c33..f5f584d35 100755 --- a/scripts/generateChangelog.py +++ b/scripts/generateChangelog.py @@ -41,10 +41,11 @@ def main(): commits = cmd(["git", "log" ,"--format=oneline", "--date=short", "{}..{}".format(args.FROM_TAG, args.TO_TAG)]).split("\n") - serverChanges = [] - clientChanges = [] - sharedChanges = [] - miscChanges = [] + serverChanges = [] + clientChanges = [] + sharedChanges = [] + positionalAudioChanges = [] + miscChanges = [] skipTypes = set(["FORMAT", "DOCS", "TEST", "MAINT", "CI", "REFAC", "BUILD", "TRANSLATION"]) @@ -73,6 +74,16 @@ def main(): targetGroups.append(serverChanges) if "shared" in commit.m_scopes: targetGroups.append(sharedChanges) + if "positional-audio" in commit.m_scopes: + targetGroups.append(positionalAudioChanges) + if "ice" in commit.m_scopes and not "server" in commit.m_scopes: + targetGroups.append(serverChanges) + commit.m_summary = "Ice: " + commit.m_summary + if "grpc" in commit.m_scopes and not "server" in commit.m_scopes: + targetGroups.append(serverChanges) + commit.m_summary = "gRPC: " + commit.m_summary + if "audio" in commit.m_scopes and not "client" in commit.m_scopes: + targetGroups.append(clientChanges) if len(targetGroups) == 0: targetGroups.append(miscChanges) @@ -112,6 +123,13 @@ def main(): print() print() + if len(positionalAudioChanges) > 0: + print("### Positional audio plugins") + print() + print("\n".join(sorted(positionalAudioChanges))) + print() + print() + if len(miscChanges): print("### Miscellaneous") print() -- cgit v1.2.3