diff --git a/.github/scripts/release_notes_by_component.py b/.github/scripts/release_notes_by_component.py index 378688d837..b7e6a0af88 100644 --- a/.github/scripts/release_notes_by_component.py +++ b/.github/scripts/release_notes_by_component.py @@ -125,7 +125,7 @@ PATH_RULES = { ".github/": "Tests and CI", } -PR_LINE = re.compile(r"^\* (?P.+?) by @\S+ in https://github\.com/\S+/pull/(?P<num>\d+)\s*$") +PR_LINE = re.compile(r"^\* (?P<title>.+?) by @(?P<author>\S+) in https://github\.com/\S+/pull/(?P<num>\d+)\s*$") # Lines regroup() writes between the PRs, so a second run accepts them. SCAFFOLD = re.compile(r"^$|^### |^<details>|^</details>$") # "fix(s3tables,s3vectors): ...", "s3 lifecycle: ...", "[Volume] ...", "Fix/admin ..." @@ -228,9 +228,8 @@ def regroup(body, pr_files): groups = {s: [] for s in SECTIONS} for line in prs: m = PR_LINE.match(line) - author = re.search(r" by @(\S+) in ", line).group(1) num = int(m.group("num")) - groups[classify(m.group("title"), author, lambda: pr_files(num))].append(line) + groups[classify(m.group("title"), m.group("author"), lambda: pr_files(num))].append(line) out = [before, ""] if before else [] out.append("## What's Changed") diff --git a/.github/scripts/test_release_notes_by_component.py b/.github/scripts/test_release_notes_by_component.py index 119b5c3e40..cb64d63273 100644 --- a/.github/scripts/test_release_notes_by_component.py +++ b/.github/scripts/test_release_notes_by_component.py @@ -161,6 +161,10 @@ class RegroupTest(unittest.TestCase): with self.assertRaises(ValueError): rn.regroup(body, self.files) + def test_author_from_the_by_clause(self): + body = "## What's Changed\n* Bump a by @dependabot[bot] in docs by @alice in https://github.com/seaweedfs/seaweedfs/pull/7\n" + self.assertIn("### Documentation", rn.regroup(body, lambda n: ["README.md"])) + def test_notes_without_prs_unchanged(self): body = "Hand-written notes\n\n**Full Changelog**: x" self.assertEqual(rn.regroup(body, no_files), body)