Skip to content

Commit

Permalink
fix: use git apply not system apply in v8 backport (nodejs#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere authored Jun 2, 2020
1 parent 7dc544d commit 65fb311
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
9 changes: 7 additions & 2 deletions components/git/v8.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,14 @@ function main(argv) {
options.v8Dir = path.resolve(options.v8Dir);
}

options.execGitNode = function execGitNode(...args) {
return execa('git', args, { cwd: options.nodeDir });
options.execGitNode = function execGitNode(cmd, args, input) {
args.unshift(cmd);
return execa('git', args, {
cwd: options.nodeDir,
...input && { input }
});
};

options.execGitV8 = function execGitV8(...args) {
return execa('git', args, { cwd: options.v8Dir });
};
Expand Down
22 changes: 9 additions & 13 deletions lib/update-v8/backport.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const path = require('path');

const execa = require('execa');
const fs = require('fs-extra');
const inquirer = require('inquirer');
const Listr = require('listr');
Expand Down Expand Up @@ -74,8 +73,8 @@ function commitSquashedBackport() {
messageBody += formatted + '\n\n';
}
}
await ctx.execGitNode('add', 'deps/v8');
await ctx.execGitNode('commit', '-m', messageTitle, '-m', messageBody);
await ctx.execGitNode('add', ['deps/v8']);
await ctx.execGitNode('commit', ['-m', messageTitle, '-m', messageBody]);
}
};
};
Expand All @@ -86,8 +85,8 @@ function commitPatch(patch) {
task: async(ctx) => {
const messageTitle = formatMessageTitle([patch]);
const messageBody = formatMessageBody(patch, false);
await ctx.execGitNode('add', 'deps/v8');
await ctx.execGitNode('commit', '-m', messageTitle, '-m', messageBody);
await ctx.execGitNode('add', ['deps/v8']);
await ctx.execGitNode('commit', ['-m', messageTitle, '-m', messageBody]);
}
};
}
Expand Down Expand Up @@ -200,13 +199,10 @@ function applyPatchTask(patch) {

async function applyPatch(ctx, patch) {
try {
await execa(
'patch',
['-p1', '--merge', '--no-backup-if-mismatch', '--directory=deps/v8'],
{
cwd: ctx.nodeDir,
input: patch.data
}
await ctx.execGitNode(
'apply',
['-p1', '--3way', '--directory=deps/v8'],
patch.data /* input */
);
} catch (e) {
patch.hadConflicts = true;
Expand Down Expand Up @@ -246,7 +242,7 @@ function incrementEmbedderVersion() {
commonGypiPath,
commonGypi.replace(embedderRegex, embedderString)
);
await ctx.execGitNode('add', 'common.gypi');
await ctx.execGitNode('add', ['common.gypi']);
}
};
}

0 comments on commit 65fb311

Please sign in to comment.