@@ -23,14 +23,17 @@ const LINT_RESULTS = {
23
23
export default class LandingSession extends Session {
24
24
constructor ( cli , req , dir , {
25
25
prid, backport, lint, autorebase, fixupAll,
26
- checkCI, oneCommitMax
26
+ checkCI, oneCommitMax, ... argv
27
27
} = { } ) {
28
28
super ( cli , dir , prid ) ;
29
29
this . req = req ;
30
30
this . backport = backport ;
31
31
this . lint = lint ;
32
32
this . autorebase = autorebase ;
33
33
this . fixupAll = fixupAll ;
34
+ this . gpgSign = argv ?. [ 'gpg-sign' ]
35
+ ? ( argv [ 'gpg-sign' ] === true ? [ '-S' ] : [ '-S' , argv [ 'gpg-sign' ] ] )
36
+ : [ ] ;
34
37
this . oneCommitMax = oneCommitMax ;
35
38
this . expectedCommitShas = [ ] ;
36
39
this . checkCI = ! ! checkCI ;
@@ -119,9 +122,8 @@ export default class LandingSession extends Session {
119
122
const allowEmptyCommits = this . fixupAll ? [ '--allow-empty' ] : [ ] ;
120
123
try {
121
124
await forceRunAsync ( 'git' ,
122
- [ 'cherry-pick' , ...allowEmptyCommits , `${ base } ..${ head } ` ] ,
123
- { ignoreFailure : false }
124
- ) ;
125
+ [ 'cherry-pick' , ...allowEmptyCommits , ...this . gpgSign , `${ base } ..${ head } ` ] ,
126
+ { ignoreFailure : false } ) ;
125
127
} catch ( ex ) {
126
128
cli . error ( 'Failed to apply patches' ) ;
127
129
process . exit ( 1 ) ;
@@ -137,7 +139,7 @@ export default class LandingSession extends Session {
137
139
// Update items then stage files and amend the last commit.
138
140
await updateDeprecations ( unmarkedDeprecations ) ;
139
141
await runAsync ( 'git' , [ 'add' , 'doc' , 'lib' , 'src' , 'test' ] ) ;
140
- await runAsync ( 'git' , [ 'commit' , '--amend' , '--no-edit' ] ) ;
142
+ await runAsync ( 'git' , [ 'commit' , '--amend' , '--no-edit' , ... this . gpgSign ] ) ;
141
143
142
144
cli
143
145
. stopSpinner ( `Updated ${ unmarkedDepCount } DEPOXXX items in codebase` ) ;
@@ -160,6 +162,10 @@ export default class LandingSession extends Session {
160
162
command += ' --autosquash' ;
161
163
}
162
164
165
+ if ( this . gpgSign ) {
166
+ command += ' ' + this . gpgSign . join ( ' ' ) ;
167
+ }
168
+
163
169
return command ;
164
170
}
165
171
@@ -215,7 +221,7 @@ export default class LandingSession extends Session {
215
221
cli . log ( `There are ${ subjects . length } commits in the PR. ` +
216
222
'Attempting to fixup everything into first commit.' ) ;
217
223
await runAsync ( 'git' , [ 'reset' , '--soft' , `HEAD~${ subjects . length - 1 } ` ] ) ;
218
- await runAsync ( 'git' , [ 'commit' , '--amend' , '--no-edit' ] ) ;
224
+ await runAsync ( 'git' , [ 'commit' , '--amend' , '--no-edit' , ... this . gpgSign ] ) ;
219
225
return await this . amend ( ) && this . final ( ) ;
220
226
} else if ( this . autorebase && this . canAutomaticallyRebase ( subjects ) ) {
221
227
// Run git rebase in interactive mode with autosquash but without editor
@@ -227,7 +233,7 @@ export default class LandingSession extends Session {
227
233
const msgAmend = `-x "git node land --amend ${ assumeYes } "` ;
228
234
try {
229
235
await forceRunAsync ( 'git' ,
230
- [ 'rebase' , `${ upstream } /${ branch } ` , '-i' , '--autosquash' , msgAmend ] ,
236
+ [ 'rebase' , ... this . gpgSign , `${ upstream } /${ branch } ` , '-i' , '--autosquash' , msgAmend ] ,
231
237
{
232
238
ignoreFailure : false ,
233
239
spawnArgs : {
@@ -278,7 +284,7 @@ export default class LandingSession extends Session {
278
284
await runAsync ( 'git' , [ 'add' , '.' ] ) ;
279
285
280
286
// Final message will be edited later - don't try to change it here.
281
- await runAsync ( 'git' , [ 'commit' , '--amend' , '--no-edit' ] ) ;
287
+ await runAsync ( 'git' , [ 'commit' , '--amend' , '--no-edit' , ... this . gpgSign ] ) ;
282
288
} else {
283
289
cli . info ( 'Please fix lint errors and then run ' +
284
290
'`git node land --amend` followed by ' +
@@ -359,7 +365,7 @@ export default class LandingSession extends Session {
359
365
cli . log ( message . trim ( ) ) ;
360
366
const takeMessage = await cli . prompt ( 'Use this message?' ) ;
361
367
if ( takeMessage ) {
362
- await runAsync ( 'git' , [ 'commit' , '--amend' , '-F' , messageFile ] ) ;
368
+ await runAsync ( 'git' , [ 'commit' , '--amend' , '-F' , messageFile , ... this . gpgSign ] ) ;
363
369
return true ;
364
370
}
365
371
@@ -371,7 +377,7 @@ export default class LandingSession extends Session {
371
377
[ `"${ messageFile } "` ] ,
372
378
{ ignoreFailure : false , spawnArgs : { shell : true } }
373
379
) ;
374
- await runAsync ( 'git' , [ 'commit' , '--amend' , '-F' , messageFile ] ) ;
380
+ await runAsync ( 'git' , [ 'commit' , '--amend' , '-F' , messageFile , ... this . gpgSign ] ) ;
375
381
return true ;
376
382
} catch {
377
383
cli . error ( 'Failed to edit the message using the configured editor' ) ;
0 commit comments