fix: the github-range runner throws so an orphaned BEFORE_SHA can fall back to dev

resolveValidationRange already knows how to replace a force-push-orphaned
BEFORE_SHA with origin/dev, but the CLI handed it a runner that killed the
process with exit 2 on the first cat-file instead of throwing into
gitObjectExists' catch. Every push after a mandatory issue-branch rebase
therefore painted process-gate red (runs 32939996348, 32940625718,
32942113142). The regression test drives the real CLI in a throwaway repo
with a BEFORE_SHA that no longer exists.

Issue: #315
User-Visible: no
This commit is contained in:
Codex
2026-08-26 10:28:04 +03:00
parent 2364d6dd43
commit 93054823c3
2 changed files with 66 additions and 1 deletions
+8 -1
View File
@@ -575,13 +575,20 @@ function main(argv) {
let range = value('range');
if (!range && flag('github-range')) {
// gitObjectExists ловит исключение, чтобы подменить осиротевший после
// force-push BEFORE_SHA на origin/dev (#315). Раннер обязан бросать,
// а не завершать процесс, как это делает git() ниже.
range = resolveValidationRange({
eventName: process.env.EVENT_NAME,
beforeSha: process.env.BEFORE_SHA,
baseSha: process.env.BASE_SHA,
headSha: process.env.HEAD_SHA,
developmentBranch: process.env.DEVELOPMENT_BRANCH,
}, (args) => git(args, repo).trim());
}, (args) => {
const r = spawnSync('git', ['-C', repo, ...args], { encoding: 'utf8' });
if (r.status !== 0) throw new Error(`git ${args.join(' ')} → ${(r.stderr || '').trim()}`);
return r.stdout.trim();
});
}
if (!range) {
const hasDev = spawnSync('git', ['-C', repo, 'rev-parse', '--verify', 'origin/dev'],