diff --git a/.github/scripts/release_notes_by_component.py b/.github/scripts/release_notes_by_component.py
index af993a2e09..378688d837 100644
--- a/.github/scripts/release_notes_by_component.py
+++ b/.github/scripts/release_notes_by_component.py
@@ -126,6 +126,8 @@ PATH_RULES = {
}
PR_LINE = re.compile(r"^\* (?P
.+?) by @\S+ in https://github\.com/\S+/pull/(?P\d+)\s*$")
+# Lines regroup() writes between the PRs, so a second run accepts them.
+SCAFFOLD = re.compile(r"^$|^### |^|^ $")
# "fix(s3tables,s3vectors): ...", "s3 lifecycle: ...", "[Volume] ...", "Fix/admin ..."
CONVENTIONAL = re.compile(r"^(?P[a-z]+)\((?P[^)]*)\)!?$")
TYPE_ONLY = {"fix", "feat", "feature", "perf", "refactor", "chore", "style", "revert", "improvement"}
@@ -206,7 +208,14 @@ def split_notes(body):
return [], body, ""
end = next((i for i in range(start + 1, len(lines))
if lines[i].startswith(("## ", "**Full Changelog**"))), len(lines))
- prs = [l for l in lines[start + 1:end] if PR_LINE.match(l)]
+ prs, stray = [], []
+ for line in lines[start + 1:end]:
+ if PR_LINE.match(line):
+ prs.append(line)
+ elif not SCAFFOLD.match(line.strip()):
+ stray.append(line)
+ if prs and stray:
+ raise ValueError("What's Changed has lines that are not PRs: %r" % stray[:3])
before = "\n".join(lines[:start]).rstrip()
after = "\n".join(lines[end:]).strip()
return prs, before, after
@@ -268,7 +277,10 @@ def main():
return []
return out.split()
- notes = regroup(body, pr_files)
+ try:
+ notes = regroup(body, pr_files)
+ except ValueError as e:
+ sys.exit("release %s: %s" % (args.tag, e))
if notes.strip() == body.replace("\r\n", "\n").strip():
print("release %s: notes already grouped, nothing to change" % args.tag, file=sys.stderr)
sys.stdout.write(notes)
diff --git a/.github/scripts/test_release_notes_by_component.py b/.github/scripts/test_release_notes_by_component.py
index a433dc01b5..119b5c3e40 100644
--- a/.github/scripts/test_release_notes_by_component.py
+++ b/.github/scripts/test_release_notes_by_component.py
@@ -156,6 +156,11 @@ class RegroupTest(unittest.TestCase):
self.assertTrue(out.endswith("\n\n**Full Changelog**: https://github.com/seaweedfs/seaweedfs/compare/4.53...4.54\n"), out)
self.assertEqual(rn.regroup(out, self.files), out)
+ def test_unknown_line_refused(self):
+ body = NOTES.replace("## New Contributors", "* a hand-written note\n\n## New Contributors")
+ with self.assertRaises(ValueError):
+ rn.regroup(body, self.files)
+
def test_notes_without_prs_unchanged(self):
body = "Hand-written notes\n\n**Full Changelog**: x"
self.assertEqual(rn.regroup(body, no_files), body)