feat(test-recorder): add recovery hints on push/PR creation failure

Fixes #10729
This commit is contained in:
bymyself
2026-04-10 18:08:27 -07:00
parent 64f3dfcc9b
commit adda92c6de

View File

@@ -1,5 +1,5 @@
import { execSync, spawnSync } from 'node:child_process'
import { pass, fail } from '../ui/logger'
import { pass, fail, info, blank } from '../ui/logger'
interface PrOptions {
testFilePath: string
@@ -35,6 +35,16 @@ export async function checkGhAvailable(): Promise<{
}
}
function logRecoveryHint(branchName: string) {
blank()
info([
'To clean up and retry, run:',
` git checkout -`,
` git branch -D ${branchName}`
])
blank()
}
export async function createPr(options: PrOptions): Promise<PrResult> {
const branchName = options.branchName ?? `test/${options.testName}`
const commitMsg = `test: add ${options.testName} e2e test\n\n${options.description}`
@@ -80,6 +90,7 @@ export async function createPr(options: PrOptions): Promise<PrResult> {
})
if (push.status !== 0) {
fail('Git push failed', push.stderr.trim())
logRecoveryHint(branchName)
return { success: false, error: push.stderr.trim() }
}
pass('Pushed branch', branchName)
@@ -91,6 +102,7 @@ export async function createPr(options: PrOptions): Promise<PrResult> {
)
if (pr.status !== 0) {
fail('PR creation failed', pr.stderr.trim())
logRecoveryHint(branchName)
return { success: false, error: pr.stderr.trim() }
}