Skip to content

Commit 11d0a04

Browse files
authored
fix(v8): handle error in git apply (#851)
Capture stdout so it can be used in the catch block when there is a conflict. Fixes: #850
1 parent c401a77 commit 11d0a04

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

lib/update-v8/minorUpdate.js

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { spawn } from 'node:child_process';
21
import path from 'node:path';
32
import { promises as fs } from 'node:fs';
43

@@ -61,30 +60,22 @@ function doMinorUpdate() {
6160
}
6261

6362
async function applyPatch(ctx, latestStr) {
64-
const diff = spawn(
63+
const diff = await forceRunAsync(
6564
'git',
6665
['format-patch', '--stdout', `${ctx.currentVersion}...${latestStr}`],
67-
{ cwd: ctx.v8Dir, stdio: ['ignore', 'pipe', 'ignore'] }
66+
{ captureStdout: true, ignoreFailure: false, spawnArgs: { cwd: ctx.v8Dir } }
6867
);
6968
try {
7069
await forceRunAsync('git', ['apply', '--directory', 'deps/v8'], {
70+
input: diff,
7171
ignoreFailure: false,
72-
spawnArgs: {
73-
cwd: ctx.nodeDir,
74-
stdio: [diff.stdout, 'ignore', 'ignore']
75-
}
72+
spawnArgs: { cwd: ctx.nodeDir }
7673
});
7774
} catch (e) {
7875
const file = path.join(ctx.nodeDir, `${latestStr}.diff`);
7976
await fs.writeFile(file, diff);
8077
throw new Error(`Could not apply patch.\n${e}\nDiff was stored in ${file}`);
8178
}
82-
if (diff.exitCode !== 0) {
83-
const err = new Error(`git format-patch failed: ${diff.exitCode}`);
84-
err.code = diff.exitCode;
85-
err.messageOnly = true;
86-
throw err;
87-
}
8879
}
8980

9081
function filterAndSortTags(tags) {

0 commit comments

Comments
 (0)