Skip to content

Commit b317b28

Browse files
committed
add user as co-author in case of conflict
1 parent 888bfbb commit b317b28

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

lib/update-v8/backport.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { ListrEnquirerPromptAdapter } from '@listr2/prompt-adapter-enquirer';
99
import { shortSha } from '../utils.js';
1010

1111
import { getCurrentV8Version } from './common.js';
12+
import { forceRunAsync } from '../run.js';
1213

1314
export async function checkOptions(options) {
1415
if (options.sha.length > 1 && options.squash) {
@@ -78,9 +79,9 @@ function commitSquashedBackport() {
7879
};
7980
};
8081

81-
const commitTask = (patch, ...extraArgs) => async(ctx) => {
82+
const commitTask = (patch, extraArgs, trailers) => async(ctx) => {
8283
const messageTitle = formatMessageTitle([patch]);
83-
const messageBody = formatMessageBody(patch, false);
84+
const messageBody = formatMessageBody(patch, false, trailers);
8485
await ctx.execGitNode('add', ['deps/v8']);
8586
await ctx.execGitNode('commit', [
8687
...ctx.gpgSign, ...extraArgs,
@@ -92,10 +93,22 @@ function amendHEAD(patch) {
9293
return {
9394
title: 'Amend/commit',
9495
task: async(ctx) => {
96+
let coAuthor;
9597
if (patch.hadConflicts) {
98+
const getGitConfigEntry = async(configKey) => {
99+
const output = await forceRunAsync('git', ['config', configKey], {
100+
ignoreFailure: false,
101+
captureStdout: true,
102+
spawnArgs: { cwd: ctx.nodeDir }
103+
});
104+
return output.trim();
105+
};
96106
await ctx.execGitNode('am', [...ctx.gpgSign, '--continue']);
107+
coAuthor = `\nCo-authored-by: ${
108+
await getGitConfigEntry('user.name')} <${
109+
await getGitConfigEntry('user.email')}>`;
97110
}
98-
await commitTask(patch, '--amend')(ctx);
111+
await commitTask(patch, ['--amend'], coAuthor)(ctx);
99112
}
100113
};
101114
}
@@ -125,12 +138,12 @@ function formatMessageTitle(patches) {
125138
}
126139
}
127140

128-
function formatMessageBody(patch, prefixTitle) {
141+
function formatMessageBody(patch, prefixTitle, trailers = '') {
129142
const indentedMessage = patch.message.replace(/\n/g, '\n ');
130143
const body =
131144
'Original commit message:\n\n' +
132145
` ${indentedMessage}\n\n` +
133-
`Refs: https://github.com/v8/v8/commit/${patch.sha}`;
146+
`Refs: https://github.com/v8/v8/commit/${patch.sha}${trailers}`;
134147

135148
if (prefixTitle) {
136149
const action = patch.hadConflicts ? 'Backport' : 'Cherry-pick';

0 commit comments

Comments
 (0)