Merge pull request 'fix: clarify stage seven push failures' (#112) from develop into master
Reviewed-on: #112
This commit is contained in:
@@ -109,8 +109,12 @@ export async function commitAndPush(workspace, repoDir, _spawnSync = spawnSync,
|
||||
|
||||
const out = run(['commit', '-m', 'chore: update ai-review findings [skip ci]'], repoDir);
|
||||
const commitHash = out.match(/\[.+ ([a-f0-9]+)\]/)?.[1] || 'unknown';
|
||||
try {
|
||||
run(['push', remoteUrl, PR_HEAD_BRANCH], repoDir, credEnv);
|
||||
console.log(` ✅ persisted findings commit=${commitHash} push=${PR_HEAD_BRANCH}`);
|
||||
} catch (pushErr) {
|
||||
console.log(` ⚠️ Step7 commit 成功但 push 失敗: commit=${commitHash} push=${PR_HEAD_BRANCH} error=${pushErr.message}`);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(` ⚠️ Runner failed: commit/push 失敗: ${e.message}`);
|
||||
|
||||
@@ -150,6 +150,32 @@ describe('commitAndPush', () => {
|
||||
const failSpawn = () => ({ status: 1, stdout: '', stderr: 'fatal: error', error: null });
|
||||
await assert.doesNotReject(() => commitAndPush(workspace, path.join(workspace, 'repo'), failSpawn, sourceRoot));
|
||||
});
|
||||
|
||||
it('logs push failures separately from commit failures', async () => {
|
||||
const repoDir = path.join(workspace, 'repo');
|
||||
fs.mkdirSync(path.join(workspace, '.gitea/ai-review'), { recursive: true });
|
||||
fs.writeFileSync(path.join(workspace, '.gitea/ai-review/findings.json'), '[]\n');
|
||||
fs.writeFileSync(path.join(workspace, '.gitea/ai-review/exclusions.json'), '[]\n');
|
||||
fs.mkdirSync(path.join(repoDir, '.gitea/ai-review'), { recursive: true });
|
||||
fs.writeFileSync(path.join(repoDir, '.gitea/ai-review/findings.json'), '[]\n');
|
||||
fs.writeFileSync(path.join(repoDir, '.gitea/ai-review/exclusions.json'), '[]\n');
|
||||
|
||||
const spawn = makeSpawn({
|
||||
push: () => ({ status: 1, stdout: '', stderr: 'remote: error: pre-receive hook declined', error: null }),
|
||||
});
|
||||
const logs = [];
|
||||
const originalLog = console.log;
|
||||
console.log = (...args) => { logs.push(args.join(' ')); };
|
||||
|
||||
try {
|
||||
await commitAndPush(workspace, repoDir, spawn, sourceRoot);
|
||||
} finally {
|
||||
console.log = originalLog;
|
||||
}
|
||||
|
||||
assert.ok(logs.some(line => line.includes('Step7 commit 成功但 push 失敗')));
|
||||
assert.ok(logs.some(line => line.includes('pre-receive hook declined')));
|
||||
});
|
||||
});
|
||||
|
||||
describe('cloneRepo', () => {
|
||||
|
||||
Reference in New Issue
Block a user