@@ -9,6 +9,7 @@ import { ListrEnquirerPromptAdapter } from '@listr2/prompt-adapter-enquirer';
9
9
import { shortSha } from '../utils.js' ;
10
10
11
11
import { getCurrentV8Version } from './common.js' ;
12
+ import { forceRunAsync } from '../run.js' ;
12
13
13
14
export async function checkOptions ( options ) {
14
15
if ( options . sha . length > 1 && options . squash ) {
@@ -78,9 +79,9 @@ function commitSquashedBackport() {
78
79
} ;
79
80
} ;
80
81
81
- const commitTask = ( patch , ... extraArgs ) => async ( ctx ) => {
82
+ const commitTask = ( patch , extraArgs , trailers ) => async ( ctx ) => {
82
83
const messageTitle = formatMessageTitle ( [ patch ] ) ;
83
- const messageBody = formatMessageBody ( patch , false ) ;
84
+ const messageBody = formatMessageBody ( patch , false , trailers ) ;
84
85
await ctx . execGitNode ( 'add' , [ 'deps/v8' ] ) ;
85
86
await ctx . execGitNode ( 'commit' , [
86
87
...ctx . gpgSign , ...extraArgs ,
@@ -92,10 +93,22 @@ function amendHEAD(patch) {
92
93
return {
93
94
title : 'Amend/commit' ,
94
95
task : async ( ctx ) => {
96
+ let coAuthor ;
95
97
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
+ } ;
96
106
await ctx . execGitNode ( 'am' , [ ...ctx . gpgSign , '--continue' ] ) ;
107
+ coAuthor = `\nCo-authored-by: ${
108
+ await getGitConfigEntry ( 'user.name' ) } <${
109
+ await getGitConfigEntry ( 'user.email' ) } >`;
97
110
}
98
- await commitTask ( patch , '--amend' ) ( ctx ) ;
111
+ await commitTask ( patch , [ '--amend' ] , coAuthor ) ( ctx ) ;
99
112
}
100
113
} ;
101
114
}
@@ -125,12 +138,12 @@ function formatMessageTitle(patches) {
125
138
}
126
139
}
127
140
128
- function formatMessageBody ( patch , prefixTitle ) {
141
+ function formatMessageBody ( patch , prefixTitle , trailers = '' ) {
129
142
const indentedMessage = patch . message . replace ( / \n / g, '\n ' ) ;
130
143
const body =
131
144
'Original commit message:\n\n' +
132
145
` ${ indentedMessage } \n\n` +
133
- `Refs: https://github.com/v8/v8/commit/${ patch . sha } ` ;
146
+ `Refs: https://github.com/v8/v8/commit/${ patch . sha } ${ trailers } ` ;
134
147
135
148
if ( prefixTitle ) {
136
149
const action = patch . hadConflicts ? 'Backport' : 'Cherry-pick' ;
0 commit comments