Skip to content

Commit ba4e0c0

Browse files
authored
fix(v8): fix git node v8 backport (#728)
1 parent a3b2662 commit ba4e0c0

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

components/git/v8.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import path from 'node:path';
2-
import { Readable } from 'node:stream';
32

43
import logSymbols from 'log-symbols';
54

65
import { minor, major, backport } from '../../lib/update-v8/index.js';
76
import { defaultBaseDir } from '../../lib/update-v8/constants.js';
87
import { checkCwd } from '../../lib/update-v8/common.js';
9-
import { forceRunAsync, runAsync } from '../../lib/run.js';
8+
import { forceRunAsync } from '../../lib/run.js';
109

1110
export const command = 'v8 [major|minor|backport]';
1211
export const describe = 'Update or patch the V8 engine';
@@ -81,10 +80,11 @@ export function handler(argv) {
8180

8281
options.execGitNode = function execGitNode(cmd, args, input) {
8382
args.unshift(cmd);
84-
return runAsync('git', args, {
83+
return forceRunAsync('git', args, {
84+
input,
8585
spawnArgs: {
8686
cwd: options.nodeDir,
87-
stdio: input ? [Readable.from(input), 'ignore', 'ignore'] : 'ignore'
87+
stdio: input ? ['pipe', 'ignore', 'ignore'] : 'ignore'
8888
}
8989
});
9090
};

lib/run.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,20 @@ export const IGNORE = '__ignore__';
1111
function runAsyncBase(cmd, args, {
1212
ignoreFailure = true,
1313
spawnArgs,
14+
input,
1415
captureStdout = false
1516
} = {}) {
1617
if (cmd instanceof URL) {
1718
cmd = fileURLToPath(cmd);
1819
}
20+
let stdio = 'inherit';
21+
if (captureStdout || input != null) {
22+
stdio = [input == null ? 'inherit' : 'pipe', captureStdout ? 'pipe' : 'inherit', 'inherit'];
23+
}
1924
return new Promise((resolve, reject) => {
2025
const opt = Object.assign({
2126
cwd: process.cwd(),
22-
stdio: captureStdout ? ['inherit', 'pipe', 'inherit'] : 'inherit'
27+
stdio
2328
}, spawnArgs);
2429
if (isDebugVerbosity()) {
2530
debuglog('[Spawn]', `${cmd} ${(args || []).join(' ')}`, opt);
@@ -47,6 +52,7 @@ function runAsyncBase(cmd, args, {
4752
}
4853
return resolve(stdout);
4954
});
55+
if (input != null) child.stdin.end(input);
5056
});
5157
}
5258

lib/update-v8/backport.js

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -132,27 +132,23 @@ function generatePatches() {
132132
title: 'Generate patches',
133133
task: async(ctx) => {
134134
const shas = ctx.sha;
135-
try {
136-
const fullShas = await Promise.all(
137-
shas.map(async(sha) => {
138-
const stdout = await ctx.execGitV8('rev-parse', sha);
139-
return stdout;
140-
})
141-
);
142-
ctx.patches = await Promise.all(fullShas.map(async(sha) => {
143-
const [patch, message] = await Promise.all([
144-
ctx.execGitV8('format-patch', '--stdout', `${sha}^..${sha}`),
145-
ctx.execGitV8('log', '--format=%B', '-n', '1', sha)
146-
]);
147-
return {
148-
sha,
149-
data: patch,
150-
message
151-
};
152-
}));
153-
} catch (e) {
154-
throw new Error(e.stderr);
155-
}
135+
const fullShas = await Promise.all(
136+
shas.map(async(sha) => {
137+
const stdout = await ctx.execGitV8('rev-parse', sha);
138+
return stdout.trim();
139+
})
140+
);
141+
ctx.patches = await Promise.all(fullShas.map(async(sha) => {
142+
const [patch, message] = await Promise.all([
143+
ctx.execGitV8('format-patch', '--stdout', `${sha}^..${sha}`),
144+
ctx.execGitV8('log', '--format=%B', '-n', '1', sha)
145+
]);
146+
return {
147+
sha,
148+
data: patch,
149+
message
150+
};
151+
}));
156152
}
157153
};
158154
}

0 commit comments

Comments
 (0)