This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { spawnSync } from 'node:child_process';
|
||||
|
||||
import { deriveHistoryBoundary } from './gate-history.mjs';
|
||||
|
||||
const candidateKind = process.argv[2];
|
||||
const root = process.cwd();
|
||||
const boundary = deriveHistoryBoundary(root);
|
||||
|
||||
function revParse(revision) {
|
||||
const result = spawnSync('git', ['rev-parse', revision], {
|
||||
cwd: root,
|
||||
encoding: 'utf8',
|
||||
});
|
||||
if (result.status !== 0) {
|
||||
process.stderr.write(`history boundary control could not resolve ${revision}\n`);
|
||||
process.exit(2);
|
||||
}
|
||||
return result.stdout.trim();
|
||||
}
|
||||
|
||||
const candidates = {
|
||||
head: revParse('HEAD'),
|
||||
parent: revParse('HEAD^'),
|
||||
introduction: boundary.introductionCommit,
|
||||
};
|
||||
if (!Object.hasOwn(candidates, candidateKind)) {
|
||||
process.stderr.write(`unknown history boundary candidate ${String(candidateKind)}\n`);
|
||||
process.exit(2);
|
||||
}
|
||||
const candidate = candidates[candidateKind];
|
||||
if (candidate === boundary.activationCommit) {
|
||||
process.stdout.write(`history boundary candidate ${candidateKind} matched derived activation\n`);
|
||||
process.exit(0);
|
||||
}
|
||||
process.stderr.write(
|
||||
`history boundary candidate ${candidateKind} rejected: derived activation is parent of registry introduction\n`,
|
||||
);
|
||||
process.exit(1);
|
||||
Reference in New Issue
Block a user