Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: refuse any bump key in fragment front matter whose value is not patch

garrytan0f3b944819ac
diff --git a/scripts/build-behavior-changes.ts b/scripts/build-behavior-changes.ts
index 84458c62aa..c162824739 100644
--- a/scripts/build-behavior-changes.ts
+++ b/scripts/build-behavior-changes.ts
@@ -75,7 +75,7 @@ export function build(root: string): Built {
? readdirSync(join(root, CHANGELOG_FRAGMENT_DIR)).filter(f => f.endsWith('.md') && f !== 'README.md').sort() : [];
for (const f of pendingFiles) {
const front = /^---\r?\n([\s\S]*?)\r?\n---\s*(\n|$)/.exec(read(root, join(CHANGELOG_FRAGMENT_DIR, f)))?.[1] ?? '';
- const bump = /^\s*bump\s*:\s*['"]?([^'"\s]*)['"]?\s*$/m.exec(front)?.[1];
+ const bump = /^\s*['"]?bump['"]?\s*:(.*)$/m.exec(front)?.[1]?.trim().replace(/^(['"])(.*)\1$/, '$2');
if (bump !== undefined && bump !== 'patch') problems.push(`${CHANGELOG_FRAGMENT_DIR}/${f} says bump: ${bump}; gbrain releases are PATCH only and the release takes the highest bump in the batch, so delete the bump: line (or write bump: patch)`);
}
const pending = [...pendingFiles.flatMap(f => markers(read(root, join(CHANGELOG_FRAGMENT_DIR, f)))), ...releases.filter(r => !r.version).flatMap(r => r.ids)];
diff --git a/test/scripts/build-behavior-changes.test.ts b/test/scripts/build-behavior-changes.test.ts
index f0e7a6a0c4..5945887337 100644
--- a/test/scripts/build-behavior-changes.test.ts
+++ b/test/scripts/build-behavior-changes.test.ts
@@ -199,6 +199,9 @@ describe('build()', () => {
const { problems } = build(tree({ ...base, 'changelog.d/feature-x.md': `---\nbump: ${bump}\nimportant: security\n---\n**Faster sync.**\n` }));
expect(problems).toEqual([`changelog.d/feature-x.md says bump: ${bump.replace(/'/g, '')}; gbrain releases are PATCH only and the release takes the highest bump in the batch, so delete the bump: line (or write bump: patch)`]);
}
+ for (const line of ['bump: minor # feature', '"bump": major']) {
+ expect(build(tree({ ...base, 'changelog.d/feature-x.md': `---\n${line}\n---\n**Faster sync.**\n` })).problems.join('\n')).toContain('changelog.d/feature-x.md says bump: ');
+ }
expect(build(tree({ ...base, 'changelog.d/feature-x.md': '---\nbump: patch\n---\n**Faster sync.**\n' })).problems).toEqual([]);
expect(build(tree({ ...base, 'changelog.d/feature-x.md': '**Faster sync.**\n\nbump: minor appears in prose here.\n' })).problems).toEqual([]);
});