@@ -41,6 +41,8 @@ export function doBackport(options) {
41
41
}
42
42
}
43
43
todo . push ( commitSquashedBackport ( ) ) ;
44
+ } else if ( options . preserveOriginalAuthor ) {
45
+ todo . push ( cherryPickV8Commits ( options ) ) ;
44
46
} else {
45
47
todo . push ( applyAndCommitPatches ( ) ) ;
46
48
}
@@ -76,18 +78,35 @@ function commitSquashedBackport() {
76
78
} ;
77
79
} ;
78
80
79
- function commitPatch ( patch ) {
81
+ const commitTask = ( patch , ...extraArgs ) => async ( ctx ) => {
82
+ const messageTitle = formatMessageTitle ( [ patch ] ) ;
83
+ const messageBody = formatMessageBody ( patch , false ) ;
84
+ await ctx . execGitNode ( 'add' , [ 'deps/v8' ] ) ;
85
+ await ctx . execGitNode ( 'commit' , [
86
+ ...ctx . gpgSign , ...extraArgs ,
87
+ '-m' , messageTitle , '-m' , messageBody
88
+ ] ) ;
89
+ } ;
90
+
91
+ function amendHEAD ( patch ) {
80
92
return {
81
- title : 'Commit patch ' ,
93
+ title : 'Amend/commit ' ,
82
94
task : async ( ctx ) => {
83
- const messageTitle = formatMessageTitle ( [ patch ] ) ;
84
- const messageBody = formatMessageBody ( patch , false ) ;
85
- await ctx . execGitNode ( 'add' , [ 'deps/v8' ] ) ;
86
- await ctx . execGitNode ( 'commit' , [ '-m' , messageTitle , '-m' , messageBody ] ) ;
95
+ if ( patch . hadConflicts ) {
96
+ await ctx . execGitNode ( 'am' , [ ... ctx . gpgSign , '--continue' ] ) ;
97
+ }
98
+ await commitTask ( patch , '--amend' ) ( ctx ) ;
87
99
}
88
100
} ;
89
101
}
90
102
103
+ function commitPatch ( patch ) {
104
+ return {
105
+ title : 'Commit patch' ,
106
+ task : commitTask ( patch )
107
+ } ;
108
+ }
109
+
91
110
function formatMessageTitle ( patches ) {
92
111
const action =
93
112
patches . some ( patch => patch . hadConflicts ) ? 'backport' : 'cherry-pick' ;
@@ -167,6 +186,15 @@ function applyAndCommitPatches() {
167
186
} ;
168
187
}
169
188
189
+ function cherryPickV8Commits ( ) {
190
+ return {
191
+ title : 'Cherry-pick commit from V8 clone to deps/v8' ,
192
+ task : ( ctx , task ) => {
193
+ return task . newListr ( ctx . patches . map ( cherryPickV8CommitTask ) ) ;
194
+ }
195
+ } ;
196
+ }
197
+
170
198
function applyPatchTask ( patch ) {
171
199
return {
172
200
title : `Commit ${ shortSha ( patch . sha ) } ` ,
@@ -190,10 +218,33 @@ function applyPatchTask(patch) {
190
218
} ;
191
219
}
192
220
193
- async function applyPatch ( ctx , task , patch ) {
221
+ function cherryPickV8CommitTask ( patch ) {
222
+ return {
223
+ title : `Commit ${ shortSha ( patch . sha ) } ` ,
224
+ task : ( ctx , task ) => {
225
+ const todo = [
226
+ {
227
+ title : 'Cherry-pick' ,
228
+ task : ( ctx , task ) => applyPatch ( ctx , task , patch , 'am' )
229
+ }
230
+ ] ;
231
+ if ( ctx . bump !== false ) {
232
+ if ( ctx . nodeMajorVersion < 9 ) {
233
+ todo . push ( incrementV8Version ( ) ) ;
234
+ } else {
235
+ todo . push ( incrementEmbedderVersion ( ) ) ;
236
+ }
237
+ }
238
+ todo . push ( amendHEAD ( patch ) ) ;
239
+ return task . newListr ( todo ) ;
240
+ }
241
+ } ;
242
+ }
243
+
244
+ async function applyPatch ( ctx , task , patch , method = 'apply' ) {
194
245
try {
195
246
await ctx . execGitNode (
196
- 'apply' ,
247
+ method ,
197
248
[ '-p1' , '--3way' , '--directory=deps/v8' ] ,
198
249
patch . data /* input */
199
250
) ;
0 commit comments