From ef81dd1b3ed0c4547f3e544d61070eb5a20e0dab Mon Sep 17 00:00:00 2001 From: CRT Date: Thu, 15 Oct 2026 01:46:02 +0800 Subject: [PATCH] a pre-release version (0.0.0-rehearsal.1) passes the one-version test; release.ts puts the checkout back when the fast gate fails before anything is committed --- tests/desktop-release.test.ts | 4 ++-- tools/release.ts | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/desktop-release.test.ts b/tests/desktop-release.test.ts index b916f0b..14e9c13 100644 --- a/tests/desktop-release.test.ts +++ b/tests/desktop-release.test.ts @@ -4,12 +4,12 @@ import { cpSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from 'nod import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { artifactName, developerIdIdentity, mergeManifest, pathFreeEnv, releaseUrl, remoteSessionReason, sliceProblems, sumsText, uploadable, archProblems, commitProblems, releaseTogetherProblems, forgejoMacFiles } from '../tools/desktop-release'; -import { COPIES, setVersion, versions } from '../tools/desktop-version'; +import { COPIES, SEMVER, setVersion, versions } from '../tools/desktop-version'; describe('desktop version authority', () => { test('the repository has one version: the CLI, the plugin manifests and the desktop app', () => { const { version, drift } = versions(); - expect(version).toMatch(/^\d+\.\d+\.\d+$/); + expect(version).toMatch(SEMVER); // x.y.z, or a pre-release such as 0.0.0-rehearsal.1 (tools/release.ts --rehearsal) expect(drift).toEqual([]); const pkg = JSON.parse(readFileSync(join(import.meta.dir, '../package.json'), 'utf8')); expect(version).toBe(pkg.version); diff --git a/tools/release.ts b/tools/release.ts index 07bad27..491d204 100644 --- a/tools/release.ts +++ b/tools/release.ts @@ -271,7 +271,12 @@ async function main(): Promise { setVersion(version); if (!rehearsal) writeFileSync(join(ROOT, 'CHANGELOG.md'), cutChangelog(readFileSync(join(ROOT, 'CHANGELOG.md'), 'utf8'), version, new Date().toISOString().slice(0, 10))); const code = await bg('ci:quick', ['bun', 'run', 'ci:quick'], join(logDir, 'ci-quick.log'), { timeoutMs: 15 * 60_000 }); - if (code !== 0) fail(`bun run ci:quick failed (${join(logDir, 'ci-quick.log').replace(HOME, '~')}); the bump is not committed (git checkout -- . to undo)`); + if (code !== 0) { + // nothing was committed or pushed: put the checkout back as it was + sh(['git', 'checkout', '-q', '--', '.']); + if (rehearsal) { sh(['git', 'checkout', '-q', startBranch === 'HEAD' ? head : startBranch]); sh(['git', 'branch', '-q', '-D', branch], { allowFail: true }); } + fail(`bun run ci:quick failed (${join(logDir, 'ci-quick.log').replace(HOME, '~')}); nothing committed, the checkout is back as it was`); + } const me = `${sh(['git', 'config', 'user.name']).trim()} <${sh(['git', 'config', 'user.email']).trim()}>`; if (me !== identity) fail(`git identity is ${me}; the commits on main are by ${identity} (git config user.name / user.email)`); sh(['git', 'add', '-A']);