| 269 | } |
| 270 | |
| 271 | function getGitDiff(changedFiles, repoRoot) { |
| 272 | const parts = []; |
| 273 | for (const f of changedFiles) { |
| 274 | const before = parts.length; |
| 275 | try { |
| 276 | const result = execSync( |
| 277 | 'git diff HEAD -- "' + f + '"', |
| 278 | { cwd: repoRoot, timeout: 10000, encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'], maxBuffer: MAX_EXEC_BUFFER } |
| 279 | ); |
| 280 | if (result && result.trim()) parts.push(result.trim()); |
| 281 | } catch (_) {} |
| 282 | if (parts.length === before) { |
| 283 | try { |
| 284 | const result = execSync( |
| 285 | 'git diff -- "' + f + '"', |
| 286 | { cwd: repoRoot, timeout: 10000, encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'], maxBuffer: MAX_EXEC_BUFFER } |
| 287 | ); |
| 288 | if (result && result.trim()) parts.push(result.trim()); |
| 289 | } catch (_) {} |
| 290 | } |
| 291 | } |
| 292 | return parts.join('\n'); |
| 293 | } |
| 294 | |
| 295 | async function maybeCreatePR({ capsule, event, mutation, gene, blastRadius }) { |
| 296 | if (String(process.env.EVOLVER_SELF_PR || '').toLowerCase() !== 'true') return null; |