@@ -23,14 +23,17 @@ const LINT_RESULTS = {
2323export default class LandingSession extends Session {
2424 constructor ( cli , req , dir , {
2525 prid, backport, lint, autorebase, fixupAll,
26- checkCI, oneCommitMax
26+ checkCI, oneCommitMax, ... argv
2727 } = { } ) {
2828 super ( cli , dir , prid ) ;
2929 this . req = req ;
3030 this . backport = backport ;
3131 this . lint = lint ;
3232 this . autorebase = autorebase ;
3333 this . fixupAll = fixupAll ;
34+ this . gpgSign = argv ?. [ 'gpg-sign' ]
35+ ? ( argv [ 'gpg-sign' ] === true ? [ '-S' ] : [ '-S' , argv [ 'gpg-sign' ] ] )
36+ : [ ] ;
3437 this . oneCommitMax = oneCommitMax ;
3538 this . expectedCommitShas = [ ] ;
3639 this . checkCI = ! ! checkCI ;
@@ -119,9 +122,8 @@ export default class LandingSession extends Session {
119122 const allowEmptyCommits = this . fixupAll ? [ '--allow-empty' ] : [ ] ;
120123 try {
121124 await forceRunAsync ( 'git' ,
122- [ 'cherry-pick' , ...allowEmptyCommits , `${ base } ..${ head } ` ] ,
123- { ignoreFailure : false }
124- ) ;
125+ [ 'cherry-pick' , ...allowEmptyCommits , ...this . gpgSign , `${ base } ..${ head } ` ] ,
126+ { ignoreFailure : false } ) ;
125127 } catch ( ex ) {
126128 cli . error ( 'Failed to apply patches' ) ;
127129 process . exit ( 1 ) ;
@@ -137,7 +139,7 @@ export default class LandingSession extends Session {
137139 // Update items then stage files and amend the last commit.
138140 await updateDeprecations ( unmarkedDeprecations ) ;
139141 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 ] ) ;
141143
142144 cli
143145 . stopSpinner ( `Updated ${ unmarkedDepCount } DEPOXXX items in codebase` ) ;
@@ -160,6 +162,10 @@ export default class LandingSession extends Session {
160162 command += ' --autosquash' ;
161163 }
162164
165+ if ( this . gpgSign ) {
166+ command += ' ' + this . gpgSign . join ( ' ' ) ;
167+ }
168+
163169 return command ;
164170 }
165171
@@ -215,7 +221,7 @@ export default class LandingSession extends Session {
215221 cli . log ( `There are ${ subjects . length } commits in the PR. ` +
216222 'Attempting to fixup everything into first commit.' ) ;
217223 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 ] ) ;
219225 return await this . amend ( ) && this . final ( ) ;
220226 } else if ( this . autorebase && this . canAutomaticallyRebase ( subjects ) ) {
221227 // Run git rebase in interactive mode with autosquash but without editor
@@ -227,7 +233,7 @@ export default class LandingSession extends Session {
227233 const msgAmend = `-x "git node land --amend ${ assumeYes } "` ;
228234 try {
229235 await forceRunAsync ( 'git' ,
230- [ 'rebase' , `${ upstream } /${ branch } ` , '-i' , '--autosquash' , msgAmend ] ,
236+ [ 'rebase' , ... this . gpgSign , `${ upstream } /${ branch } ` , '-i' , '--autosquash' , msgAmend ] ,
231237 {
232238 ignoreFailure : false ,
233239 spawnArgs : {
@@ -278,7 +284,7 @@ export default class LandingSession extends Session {
278284 await runAsync ( 'git' , [ 'add' , '.' ] ) ;
279285
280286 // 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 ] ) ;
282288 } else {
283289 cli . info ( 'Please fix lint errors and then run ' +
284290 '`git node land --amend` followed by ' +
@@ -359,7 +365,7 @@ export default class LandingSession extends Session {
359365 cli . log ( message . trim ( ) ) ;
360366 const takeMessage = await cli . prompt ( 'Use this message?' ) ;
361367 if ( takeMessage ) {
362- await runAsync ( 'git' , [ 'commit' , '--amend' , '-F' , messageFile ] ) ;
368+ await runAsync ( 'git' , [ 'commit' , '--amend' , '-F' , messageFile , ... this . gpgSign ] ) ;
363369 return true ;
364370 }
365371
@@ -371,7 +377,7 @@ export default class LandingSession extends Session {
371377 [ `"${ messageFile } "` ] ,
372378 { ignoreFailure : false , spawnArgs : { shell : true } }
373379 ) ;
374- await runAsync ( 'git' , [ 'commit' , '--amend' , '-F' , messageFile ] ) ;
380+ await runAsync ( 'git' , [ 'commit' , '--amend' , '-F' , messageFile , ... this . gpgSign ] ) ;
375381 return true ;
376382 } catch {
377383 cli . error ( 'Failed to edit the message using the configured editor' ) ;
0 commit comments