fix(release): exclude legacy main history from commit checks
All checks were successful
Build and Release FEDEO / verify (push) Successful in 25s
Build and Release FEDEO / build-and-release (push) Successful in 6m4s

This commit is contained in:
2026-09-20 18:44:53 +02:00
parent bb94e73229
commit f6996c1d7b
5 changed files with 75 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { execFileSync } from 'node:child_process';
import { mkdtempSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';
@@ -17,9 +18,9 @@ function fixture(t) {
run(['commit', '--allow-empty', '-m', 'historic baseline']);
const config = { bootstrapCommit: run(['rev-parse', 'HEAD']), initialVersion: '1.0.0', repositoryUrl: 'https://git.example.test/owner/fedeo' };
let count = 0;
const commit = message => {
writeFileSync(join(cwd, 'file'), `${++count}\n`);
run(['add', 'file']);
const commit = (message, file = 'file') => {
writeFileSync(join(cwd, file), `${++count}\n`);
run(['add', file]);
run(['commit', '-m', message]);
return run(['rev-parse', 'HEAD']);
};
@@ -52,6 +53,51 @@ test('first release uses explicit baseline and excludes legacy history', async t
assert.doesNotMatch(plan.notes, /historic baseline|compare\/\.\.\./);
});
function divergentHistory(t) {
const f = fixture(t);
f.run(['branch', 'legacy-main']);
f.config.bootstrapCommit = f.commit('chore: versioning baseline');
f.commit('feat: current export');
f.run(['checkout', 'legacy-main']);
f.commit('.gitea/ISSUE_TEMPLATE/bug_report.md aktualisiert', 'legacy-template');
const legacyHead = f.commit('feat: historic main feature', 'legacy-feature');
f.config.legacyHistoryHeads = [legacyHead];
return f;
}
test('the first main merge excludes pinned legacy branch history from validation and notes', async t => {
const f = divergentHistory(t);
f.run(['checkout', 'main']);
f.run(['merge', '--no-ff', 'legacy-main', '-m', 'Merge historic main']);
const plan = await f.plan();
assert.equal(plan.version, '1.0.0');
assert.match(plan.notes, /current export/);
assert.doesNotMatch(plan.notes, /historic main feature|ISSUE_TEMPLATE/);
writeFileSync(join(f.cwd, 'release.config.json'), JSON.stringify(f.config));
const output = execFileSync(process.execPath, [resolve('scripts/release/cli.mjs'), 'check'], { cwd: f.cwd, encoding: 'utf8' });
assert.match(output, /1 Commit-Nachrichten geprüft/);
});
test('new commits on a legacy branch still affect versions and must use Conventional Commits', async t => {
const f = divergentHistory(t);
f.run(['checkout', 'main']);
f.run(['tag', 'v1.0.0']);
f.run(['checkout', 'legacy-main']);
f.commit('feat(api)!: replace exported API', 'new-api');
f.run(['checkout', 'main']);
f.run(['merge', '--no-ff', 'legacy-main', '-m', 'Merge new API']);
const plan = await f.plan();
assert.equal(plan.version, '2.0.0');
assert.match(plan.notes, /replace exported API/);
assert.doesNotMatch(plan.notes, /historic main feature/);
f.run(['checkout', 'legacy-main']);
f.commit('Unclassified new change', 'another-change');
f.run(['checkout', 'main']);
f.run(['merge', '--no-ff', 'legacy-main', '-m', 'Merge another change']);
await assert.rejects(f.plan(), /Conventional Commits fehlen:[\s\S]*Unclassified new change/);
});
test('patch/minor/major releases, multi-digit tags and unrelated component tags', async t => {
const f = fixture(t);
f.run(['tag', 'v1.9.0']);
@@ -104,6 +150,14 @@ test('an unknown baseline fails instead of releasing unrelated history', async t
await assert.rejects(f.plan(), /Ausgangscommit/);
});
test('missing or mutable legacy history heads fail instead of silently skipping validation', async t => {
const f = fixture(t);
f.config.legacyHistoryHeads = ['f'.repeat(40)];
await assert.rejects(f.plan(), /alte Release-Historie .* fehlt/);
f.config.legacyHistoryHeads = ['main'];
await assert.rejects(f.plan(), /feste vollständige Commit-IDs/);
});
test('Git lease lock excludes concurrent runners and cannot remove another owner', async t => {
const f = fixture(t);
const remote = join(f.cwd, 'remote.git');