Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix: release:unstamp refuses a changelog fragment master brings in for the same slug
garrytan1075c81f2fe7
diff --git a/scripts/release-restamp.ts b/scripts/release-restamp.tsindex 6752dd0496..163298a443 100644--- a/scripts/release-restamp.ts+++ b/scripts/release-restamp.ts@@ -461,7 +461,7 @@ function unstampFiles(ctx: Ctx, state: State, masterVersion: string): void {`write ${CHANGELOG_FRAGMENT_DIR}/<branch-slug>.md yourself (docs/RELEASING.md#releases-per-batch), commit, then rerun: bun run release:unstamp`);}const frag = `${CHANGELOG_FRAGMENT_DIR}/${fragmentSlug(ctx.git('rev-parse', '--abbrev-ref', 'HEAD').trim())}.md`;- if (ctx.gitOk('cat-file', '-e', `${state.preHead}:${frag}`)) fail(`${frag} already exists`, 'release:unstamp writes the branch\'s entry there and never merges two entries.', `fold your CHANGELOG entry into ${frag} by hand, put CHANGELOG.md back to ${state.masterRef}'s, commit, then rerun`);+ if (ctx.gitOk('cat-file', '-e', `HEAD:${frag}`)) fail(`${frag} already exists`, 'release:unstamp writes the branch\'s entry there and never merges two entries.', `fold your CHANGELOG entry into ${frag} by hand, put CHANGELOG.md back to ${state.masterRef}'s, commit, then rerun`);stampOnly(ctx.root, masterVersion, [state.branchVersion]);ctx.write('CHANGELOG.md', ctx.git('show', `${state.masterRef}:CHANGELOG.md`));const rows = state.rows ?? [];diff --git a/scripts/structural-suites.tsv b/scripts/structural-suites.tsvindex 79d0cbcca8..b31080ea22 100644--- a/scripts/structural-suites.tsv+++ b/scripts/structural-suites.tsv@@ -354,7 +354,7 @@ test/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 readFileSynctest/scripts/release-restamp.test.ts release:restamp end to end 15 readFileSync-test/scripts/release-restamp.test.ts release:unstamp and merge: direct 5 readFileSync+test/scripts/release-restamp.test.ts release:unstamp and merge: direct 6 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 57ee73c2de..e8ca39d5fe 100644--- a/test/scripts/release-restamp.test.ts+++ b/test/scripts/release-restamp.test.ts@@ -668,6 +668,17 @@ describe('release:unstamp and merge: direct', () => {expect(read(fx.work, 'changelog.d/feature.md')).toBe('Already written.\n');}, 120_000);+ test('refuses a changelog fragment for this slug that master brings in, and keeps master\'s text', () => {+ const fx = noticeFixture();+ branchWork(fx, '0.1.1.0', {});+ landOnMaster(fx, '0.1.1.0', null);+ landOnMaster(fx, '0.1.2.0', null, { ...POLICY_DIRECT, 'changelog.d/feature.md': 'Another PR.\n' });+ const r = restamp(fx.work, ['--unstamp'], QUIET);+ expect(r.code).toBe(1);+ expect(r.out).toContain('changelog.d/feature.md already exists');+ expect(read(fx.work, 'changelog.d/feature.md')).toBe('Another PR.\n');+ }, 120_000);+test('plain restamp is refused when origin/master says merge: direct', () => {const fx = noticeFixture();branchWork(fx, '0.1.1.0', {});