Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix: release:unstamp --continue no longer refuses the fragment it wrote
garrytaneafbff9ca5a8
diff --git a/scripts/release-restamp.ts b/scripts/release-restamp.tsindex 8df91f6277..6752dd0496 100644--- a/scripts/release-restamp.ts+++ b/scripts/release-restamp.ts@@ -460,10 +460,10 @@ function unstampFiles(ctx: Ctx, state: State, masterVersion: string): void {fail(`this branch has no CHANGELOG entry above ${state.masterRef}'s`, 'release:unstamp moves the branch\'s own entry into its changelog fragment.',`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`);stampOnly(ctx.root, masterVersion, [state.branchVersion]);ctx.write('CHANGELOG.md', ctx.git('show', `${state.masterRef}:CHANGELOG.md`));- const frag = `${CHANGELOG_FRAGMENT_DIR}/${fragmentSlug(ctx.git('rev-parse', '--abbrev-ref', 'HEAD').trim())}.md`;- if (existsSync(join(ctx.root, 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`);const rows = state.rows ?? [];const body = state.entry.text.split('\n').slice(1).join('\n').trim();mkdirSync(join(ctx.root, CHANGELOG_FRAGMENT_DIR), { recursive: true });diff --git a/test/scripts/release-restamp.test.ts b/test/scripts/release-restamp.test.tsindex 67efaebdb9..57ee73c2de 100644--- a/test/scripts/release-restamp.test.ts+++ b/test/scripts/release-restamp.test.ts@@ -656,6 +656,18 @@ describe('release:unstamp and merge: direct', () => {}}, 120_000);+ test('refuses a changelog fragment the branch already had, before touching a stamp', () => {+ const fx = noticeFixture();+ branchWork(fx, '0.1.1.0', { 'changelog.d/feature.md': 'Already written.\n' });+ landOnMaster(fx, '0.1.1.0', null);+ landOnMaster(fx, '0.1.2.0', null, POLICY_DIRECT);+ 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, 'VERSION')).toBe('0.1.1.0\n');+ expect(read(fx.work, 'changelog.d/feature.md')).toBe('Already written.\n');+ }, 120_000);+test('plain restamp is refused when origin/master says merge: direct', () => {const fx = noticeFixture();branchWork(fx, '0.1.1.0', {});