Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
release:unstamp reads a notice row's id in either quote style
garrytan085145754ec4
diff --git a/scripts/release-restamp.ts b/scripts/release-restamp.tsindex a46a095374..cad945964b 100644--- a/scripts/release-restamp.ts+++ b/scripts/release-restamp.ts@@ -297,12 +297,13 @@ function branchNoticeRows(ctx: Ctx, masterRef: string, mergeBase: string): Arrayconst close = head.findIndex((l, i) => i >= open && l === '];') + 1;const outside = added.filter((l) => l.line <= open || l.line >= close);if (removed !== '0' || outside.length > 0) fail(`this branch changes ${BEHAVIOR_NOTICE_FILE} beyond appending BEHAVIOR_CHANGES rows${outside.length ? ` (line ${outside.slice(0, 5).map((l) => l.line).join(', ')})` : ''}`, why, how);- const noId = added.filter((l) => /\{ since:/.test(l.text) && !/\bid: '/.test(l.text));+ const quotedId = /\bid:\s*(['"`])([^'"`]+)\1/g;+ const noId = added.filter((l) => /\{ since:|\bid\s*:/.test(l.text) && !l.text.match(quotedId));if (noId.length > 0) fail(`${noId.length} BEHAVIOR_CHANGES row(s) this branch added have no id (line ${noId.map((l) => l.line).join(', ')})`, 'a moved row is named behavior-changes.d/<id>.md and dated by its id.', 'give each row an id (lowercase letters, digits and _), commit, then rerun: bun run release:unstamp');const r = ctx.run(['bun', '-e', ROW_DUMP]);const rows = (() => { try { return JSON.parse(r.out.trim().split('\n').at(-1) ?? '') as Array<{ id: string | null; text: string | null }>; } catch { return null; } })();if (r.code !== 0 || !rows) fail(`could not read the BEHAVIOR_CHANGES table at HEAD (exit ${r.code}): ${r.out.trim().split('\n').slice(-3).join(' ')}`, 'release:unstamp reads each appended row\'s text from the evaluated table.', 'fix the table so bun can import it, then rerun: bun run release:unstamp');- const ids = (text: string) => new Set([...text.matchAll(/\bid: '([^']+)'/g)].map((m) => m[1]!));+ const ids = (text: string) => new Set([...text.matchAll(quotedId)].map((m) => m[2]!));const appended = ids(added.map((l) => l.text).join('\n'));const mine = rows.filter((row): row is { id: string; text: string | null } => !!row.id && appended.has(row.id));const fn = mine.filter((row) => row.text === null).map((row) => row.id);diff --git a/scripts/structural-suites.tsv b/scripts/structural-suites.tsvindex 4a72c55433..cc57488ebb 100644--- a/scripts/structural-suites.tsv+++ b/scripts/structural-suites.tsv@@ -356,8 +356,8 @@ test/scripts/pregate-remote-gate.test.ts ship_lanes_from (/ship lanes carried frtest/scripts/promote-stable.test.ts promote-stable.yml 2 readFileSynctest/scripts/regen-all.test.ts regen:all 5 readFileSynctest/scripts/release-restamp.test.ts release-restamp --stamp-only 2 readFileSync-test/scripts/release-restamp.test.ts release:restamp end to end 15 readFileSync-test/scripts/release-restamp.test.ts release:unstamp and merge: direct 8 readFileSync+test/scripts/release-restamp.test.ts release:restamp end to end 16 readFileSync+test/scripts/release-restamp.test.ts release:unstamp and merge: direct 9 readFileSynctest/scripts/require-executed-tests.test.ts require-executed-tests 9 readFileSynctest/scripts/run-verify-parallel.test.ts guard registration ⇒ execution coverage 1 readFileSynctest/scripts/run-verify-parallel.test.ts run-verify-parallel.sh — no-timeout-binary fallback rc capture (regression) 7 readFileSyncdiff --git a/test/scripts/release-restamp.test.ts b/test/scripts/release-restamp.test.tsindex 18d583d308..60aee5fe89 100644--- a/test/scripts/release-restamp.test.ts+++ b/test/scripts/release-restamp.test.ts@@ -340,6 +340,20 @@ describe('release:restamp end to end', () => {expect(splitChangelog(read(fx.work, 'CHANGELOG.md')).sections.map((s) => s.header)[0]).toBe('## [0.1.2.0] - 2026-10-05');}, 120_000);+ test('--continue refuses a hand resolution that puts a master-edited published migration back to the branch text', () => {+ const fx = fixture();+ const seed = migrationFile(208, 'seed_two');+ branchWork(fx, '0.1.1.0', { 'src/shared.ts': 'export const GREETING = "hi from the branch";\n' });+ landOnMaster(fx, '0.1.1.0', null, { 'src/shared.ts': 'export const GREETING = "hi from master";\n', [seed]: migration(208, 'seed_two', 'CREATE TABLE IF NOT EXISTS seed_two (id BIGINT);') });+ expect(restamp(fx.work).code).toBe(1);+ put(fx.work, { 'src/shared.ts': 'export const GREETING = "hi from both";\n' });+ git(fx.work, 'checkout', 'HEAD', '--', seed);+ git(fx.work, 'add', 'src/shared.ts', seed);+ const r = restamp(fx.work, ['--continue']);+ expect(r.code).toBe(1);+ expect(r.out).toContain(`${seed} is published on origin/master but this branch changes its payload`);+ }, 120_000);+test('--abort returns to the pre-run commit', () => {const fx = fixture();branchWork(fx, '0.1.1.0', { 'src/shared.ts': 'export const GREETING = "hi from the branch";\n' });@@ -713,6 +727,16 @@ describe('release:unstamp and merge: direct', () => {expect(read(fx.work, 'behavior-changes.d/released_row_abc.md')).toBe('Released.\n');}, 120_000);+ test('a row whose id is double-quoted moves to its fragment instead of vanishing with the table', () => {+ const fx = noticeFixture();+ branchWork(fx, '0.1.1.0', { [NOTICE]: noticeFile(BRANCH_ROW, " { id: \"quoted_row_abc\", since: '0.1.1.0', text: 'Quoted id.' },") });+ landOnMaster(fx, '0.1.1.0', null, POLICY_DIRECT);+ const r = restamp(fx.work, ['--unstamp'], QUIET);+ expect(r.code).toBe(0);+ expect(read(fx.work, 'behavior-changes.d/quoted_row_abc.md')).toContain('Quoted id.');+ expect(read(fx.work, 'behavior-changes.d/faster_sync_abc.md')).toContain('Sync is faster now.');+ }, 120_000);+test('plain restamp is refused when origin/master says merge: direct', () => {const fx = noticeFixture();branchWork(fx, '0.1.1.0', {});