Skip to content

Commit

Permalink
fix(v8): fix git node v8 backport (#728)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Sep 15, 2023
1 parent a3b2662 commit ba4e0c0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
8 changes: 4 additions & 4 deletions components/git/v8.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import path from 'node:path';
import { Readable } from 'node:stream';

import logSymbols from 'log-symbols';

import { minor, major, backport } from '../../lib/update-v8/index.js';
import { defaultBaseDir } from '../../lib/update-v8/constants.js';
import { checkCwd } from '../../lib/update-v8/common.js';
import { forceRunAsync, runAsync } from '../../lib/run.js';
import { forceRunAsync } from '../../lib/run.js';

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

options.execGitNode = function execGitNode(cmd, args, input) {
args.unshift(cmd);
return runAsync('git', args, {
return forceRunAsync('git', args, {
input,
spawnArgs: {
cwd: options.nodeDir,
stdio: input ? [Readable.from(input), 'ignore', 'ignore'] : 'ignore'
stdio: input ? ['pipe', 'ignore', 'ignore'] : 'ignore'
}
});
};
Expand Down
8 changes: 7 additions & 1 deletion lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@ export const IGNORE = '__ignore__';
function runAsyncBase(cmd, args, {
ignoreFailure = true,
spawnArgs,
input,
captureStdout = false
} = {}) {
if (cmd instanceof URL) {
cmd = fileURLToPath(cmd);
}
let stdio = 'inherit';
if (captureStdout || input != null) {
stdio = [input == null ? 'inherit' : 'pipe', captureStdout ? 'pipe' : 'inherit', 'inherit'];
}
return new Promise((resolve, reject) => {
const opt = Object.assign({
cwd: process.cwd(),
stdio: captureStdout ? ['inherit', 'pipe', 'inherit'] : 'inherit'
stdio
}, spawnArgs);
if (isDebugVerbosity()) {
debuglog('[Spawn]', `${cmd} ${(args || []).join(' ')}`, opt);
Expand Down Expand Up @@ -47,6 +52,7 @@ function runAsyncBase(cmd, args, {
}
return resolve(stdout);
});
if (input != null) child.stdin.end(input);
});
}

Expand Down
38 changes: 17 additions & 21 deletions lib/update-v8/backport.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,27 +132,23 @@ function generatePatches() {
title: 'Generate patches',
task: async(ctx) => {
const shas = ctx.sha;
try {
const fullShas = await Promise.all(
shas.map(async(sha) => {
const stdout = await ctx.execGitV8('rev-parse', sha);
return stdout;
})
);
ctx.patches = await Promise.all(fullShas.map(async(sha) => {
const [patch, message] = await Promise.all([
ctx.execGitV8('format-patch', '--stdout', `${sha}^..${sha}`),
ctx.execGitV8('log', '--format=%B', '-n', '1', sha)
]);
return {
sha,
data: patch,
message
};
}));
} catch (e) {
throw new Error(e.stderr);
}
const fullShas = await Promise.all(
shas.map(async(sha) => {
const stdout = await ctx.execGitV8('rev-parse', sha);
return stdout.trim();
})
);
ctx.patches = await Promise.all(fullShas.map(async(sha) => {
const [patch, message] = await Promise.all([
ctx.execGitV8('format-patch', '--stdout', `${sha}^..${sha}`),
ctx.execGitV8('log', '--format=%B', '-n', '1', sha)
]);
return {
sha,
data: patch,
message
};
}));
}
};
}
Expand Down

0 comments on commit ba4e0c0

Please sign in to comment.