Skip to content

Commit 02a162b

Browse files
authored
fix(release): distinguish CSS colors from issue references (#132075)
Use one token-aware scanner for release history, contribution labels, and editorial checks. Keep legitimate issue references after CSS custom-property colors instead of discarding the rest of their line.
1 parent 7d354ce commit 02a162b

2 files changed

Lines changed: 116 additions & 32 deletions

File tree

‎.agents/skills/openclaw-changelog-update/scripts/verify-release-notes.mjs‎

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -479,28 +479,28 @@ function sectionFor(changelog, version) {
479479
}
480480

481481
function referencesIn(text) {
482-
const references = [];
483-
for (const match of text.matchAll(
484-
/(?<![A-Za-z0-9_.&-])(?:(?<owner>[A-Za-z0-9_.-]+)\/(?<name>[A-Za-z0-9_.-]+))?#(?<number>\d+)/g,
485-
)) {
486-
const qualifiedRepository = match.groups?.owner
487-
? `${match.groups.owner}/${match.groups.name}`.toLowerCase()
488-
: undefined;
489-
if (!qualifiedRepository || qualifiedRepository === repo) {
490-
references.push(Number(match.groups?.number));
491-
}
492-
}
493-
return references;
482+
return referenceLabelsIn(text)
483+
.filter((reference) => reference.startsWith("#"))
484+
.map((reference) => Number(reference.slice(1)));
494485
}
495486

496487
function referenceLabelsIn(text) {
488+
const hexColor = String.raw`#(?:[A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{4}|[A-Fa-f0-9]{3})(?![A-Za-z0-9_])`;
489+
// Mask only custom-property color values/transitions, never the rest of a line:
490+
// a following issue ref must still participate in release attribution.
491+
const source = text.replace(
492+
new RegExp(
493+
String.raw`--[\w-]+(?:[ \t]*:[ \t]*|[ \t]+)${hexColor}(?:[ \t]*(?:->|→)[ \t]*${hexColor})*`,
494+
"g",
495+
),
496+
" ",
497+
);
497498
const labels = [];
498-
for (const match of text.matchAll(
499-
/(?<![A-Za-z0-9_.&-])(?:(?<owner>[A-Za-z0-9_.-]+)\/(?<name>[A-Za-z0-9_.-]+))?#(?<number>\d+)/g,
499+
// Issue ids are complete positive decimal tokens, not hex prefixes or zero-padded colors.
500+
for (const match of source.matchAll(
501+
/(?<![A-Za-z0-9_.&-])(?<repository>[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)?#(?<number>[1-9]\d*)(?![A-Za-z0-9_])/g,
500502
)) {
501-
const qualifiedRepository = match.groups?.owner
502-
? `${match.groups.owner}/${match.groups.name}`
503-
: undefined;
503+
const qualifiedRepository = match.groups?.repository;
504504
labels.push(
505505
!qualifiedRepository || qualifiedRepository.toLowerCase() === repo
506506
? `#${match.groups?.number}`
@@ -2280,23 +2280,22 @@ export function ledgerChecks(section, pullRequests, nodes, directCommits, shippe
22802280
}
22812281
}
22822282
const editorialProse = section.source.slice(0, ledgerStart);
2283+
const editorialReferences = new Set(referencesIn(editorialProse));
22832284
for (const entry of pullRequests) {
2284-
if (
2285-
!entry.editorialEligible &&
2286-
new RegExp(`(?<![A-Za-z0-9_./-])#${entry.number}\\b`).test(editorialProse)
2287-
) {
2285+
if (!entry.editorialEligible && editorialReferences.has(entry.number)) {
22882286
errors.push(
22892287
`editorial release prose references non-editorial ${entry.type} PR #${entry.number} (${entry.type})`,
22902288
);
22912289
}
22922290
}
22932291
const editorialLines = editorialProse.split("\n");
2294-
for (const entry of pullRequests) {
2295-
for (const line of editorialLines) {
2296-
if (
2297-
!new RegExp(`(?<![A-Za-z0-9_./-])#${entry.number}\\b`).test(line) ||
2298-
!line.startsWith("- ")
2299-
) {
2292+
for (const line of editorialLines) {
2293+
if (!line.startsWith("- ")) {
2294+
continue;
2295+
}
2296+
const lineReferences = new Set(referencesIn(line));
2297+
for (const entry of pullRequests) {
2298+
if (!lineReferences.has(entry.number)) {
23002299
continue;
23012300
}
23022301
for (const handle of entry.thanks) {
@@ -2305,11 +2304,6 @@ export function ledgerChecks(section, pullRequests, nodes, directCommits, shippe
23052304
}
23062305
}
23072306
}
2308-
}
2309-
for (const line of editorialLines) {
2310-
if (!line.startsWith("- ")) {
2311-
continue;
2312-
}
23132307
for (const handle of directCommitCreditsForLine(line, directCommits)) {
23142308
if (!line.toLowerCase().includes(`@${handle.toLowerCase()}`)) {
23152309
errors.push(`missing editorial Thanks @${handle} for directly landed work`);

‎test/scripts/verify-release-notes.test.ts‎

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
githubApiWithSnapshot,
1717
highlightCountError,
1818
isEligibleHandle,
19+
ledgerChecks,
1920
parseArgs,
2021
persistGithubSnapshot,
2122
pullRequestTitleFromCommitSubject,
@@ -868,6 +869,95 @@ describe("release-note verification", () => {
868869
expect(releaseNoteReferences(section, baselines)).toEqual([1, 3]);
869870
});
870871

872+
it.each([
873+
{
874+
name: "CSS palette comparisons in a commit message",
875+
source: [
876+
"fix(control-ui): darken the Absolutely surface ramp (#130239)",
877+
"",
878+
"--bg #262624 sat above Dash #1a1210, Claw #0e1015, and Knot #080808.",
879+
"Steps the ramp down (--bg #262624 -> #1c1c1a).",
880+
].join("\n"),
881+
expected: [130239],
882+
},
883+
{
884+
name: "issue refs after CSS colors on the same line",
885+
source: "--bg #262624 (fixes #123), refs #1234, #123456, and #12345678.",
886+
expected: [123, 1234, 123456, 12345678],
887+
},
888+
{
889+
name: "short and alpha CSS values and numeric color transitions",
890+
source:
891+
"--fg: #123; --border:#1234; --bg #123456 -> #654321; --alpha: #12345678 → #87654321. (#456)",
892+
expected: [456],
893+
},
894+
{
895+
name: "qualified references beside CSS values",
896+
source: "OpenClaw/OpenClaw#123 --bg #262624; openclaw/openclaw#456 and Other/Repo#123456.",
897+
expected: [123, 456],
898+
},
899+
{
900+
name: "ordinary Markdown and code references",
901+
source:
902+
"**PR #123**; `#456`; [#789](https://github.com/openclaw/openclaw/issues/789)\n```text\n#123456\n```\n`--bg: #262624` (#1234)",
903+
expected: [123, 456, 789, 123456, 1234],
904+
},
905+
{
906+
name: "complete numeric reference tokens",
907+
source:
908+
"#1a1210 #0e1015 #080808 #fff #123abc #456_def &#123; file#456; #123 #1234 #123456 #12345678",
909+
expected: [123, 1234, 123456, 12345678],
910+
},
911+
{
912+
name: "non-color custom-property prose and cross-line references",
913+
source: "--bg fixes #123; --border relates to #456.\n--bg\n#789",
914+
expected: [123, 456, 789],
915+
},
916+
])("extracts release references from $name", ({ source, expected }) => {
917+
expect(releaseNoteReferences(source, [])).toEqual(expected);
918+
});
919+
920+
it.each([
921+
{ reference: "", expected: [] },
922+
{
923+
reference: " (fixes #262624)",
924+
expected: [
925+
"editorial release prose references non-editorial chore PR #262624 (chore)",
926+
"missing editorial Thanks @alice for PR #262624",
927+
],
928+
},
929+
])("validates editorial credit after a CSS color: '$reference'", ({ reference, expected }) => {
930+
const source = [
931+
"## 2026.8.1",
932+
"### Highlights",
933+
"- One.",
934+
"- Two.",
935+
"- Three.",
936+
"- Four.",
937+
"- Five.",
938+
"### Changes",
939+
"### Fixes",
940+
`- Set --bg #262624${reference}.`,
941+
"### Complete contribution record",
942+
`This audited record covers the complete base..${"a".repeat(40)} history: 1 merged PR.`,
943+
"#### Pull requests",
944+
"- **PR #262624** Thanks @alice.",
945+
].join("\n");
946+
const entry = {
947+
number: 262624,
948+
title: "chore: unrelated tooling",
949+
type: "chore",
950+
editorialEligible: false,
951+
externalReferences: [],
952+
linkedIssues: [],
953+
thanks: ["alice"],
954+
};
955+
956+
expect(
957+
ledgerChecks({ source }, [entry], new Map([[262624, { __typename: "PullRequest" }]]), []),
958+
).toEqual(expected);
959+
});
960+
871961
it("records a canonical target SHA when --target is symbolic", () => {
872962
const cwd = mkdtempSync(join(tmpdir(), "openclaw-release-notes-"));
873963
try {

0 commit comments

Comments
 (0)