fix(review): the verdict gate refuses, with --repo, a review of another commit than the one being merged
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a9f5f6251a
commit
6c0718c8d8
6 changed files with 570 additions and 25 deletions
|
|
@ -40,6 +40,7 @@ import { spawnSync } from 'node:child_process';
|
|||
import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { decideVerdict } from '../lib/review/verdict-gate.mjs';
|
||||
import { reviewedSha } from '../lib/review/reviewed-commit.mjs';
|
||||
import { commandEnv } from '../lib/util/command-env.mjs';
|
||||
import { DEFAULT_TIMEOUT_MS, stoppedBy } from '../lib/verification/criteria-runner.mjs';
|
||||
import { isMain } from '../lib/util/is-main.mjs';
|
||||
|
|
@ -213,18 +214,10 @@ function checkReview(reviewPath) {
|
|||
return { check: { id: 'review', status: 'pass', detail: `review verdict ${v.verdict}` }, text };
|
||||
}
|
||||
|
||||
/**
|
||||
* The review's `scope_sha_end` as written. Read from the frontmatter text, not
|
||||
* through the YAML reader, which turns an all-digit value into a number and
|
||||
* drops a leading zero (`0123456` → 123456; release review of 6.3.0, round 3).
|
||||
*/
|
||||
export function reviewedSha(reviewText) {
|
||||
const fm = /^---\r?\n([\s\S]*?)\r?\n---\r?\n/.exec(String(reviewText ?? ''));
|
||||
const m = fm && /^scope_sha_end:[ \t]*(["']?)([^"'\s#]*)\1[ \t]*(?:#.*)?$/m.exec(fm[1]);
|
||||
// A commit sha only: a ref name (HEAD, main, a tag) resolves to whatever it
|
||||
// points at now, and coverage would pass whatever was reviewed (round 4).
|
||||
return m && /^[0-9a-f]{7,40}$/i.test(m[2]) ? m[2] : '';
|
||||
}
|
||||
// `reviewedSha` lives in lib/review/reviewed-commit.mjs (the verdict gate's
|
||||
// --repo check reads it too; lib/ never imports from scripts/). Re-exported
|
||||
// here under the same name for the callers of this module.
|
||||
export { reviewedSha };
|
||||
|
||||
function checkCoverage(repo, reviewText) {
|
||||
if (reviewText === null) return { id: 'coverage', status: 'skip', detail: 'not checked: no readable review' };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue