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

This commit is contained in:
CRTkafa 2026-10-15 01:46:02 +08:00
parent cd1e13c1e2
commit ef81dd1b3e
2 changed files with 8 additions and 3 deletions

View file

@ -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);

View file

@ -271,7 +271,12 @@ async function main(): Promise<void> {
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']);