@@ -22,14 +22,17 @@ const LINT_RESULTS = {
2222} ;
2323
2424class LandingSession extends Session {
25- constructor ( cli , req , dir ,
26- { prid, backport, lint, autorebase, fixupAll, checkCI } = { } ) {
25+ constructor ( cli , req , dir , {
26+ prid, backport, lint, autorebase, fixupAll,
27+ checkCI, allowMultipleCommits
28+ } = { } ) {
2729 super ( cli , dir , prid ) ;
2830 this . req = req ;
2931 this . backport = backport ;
3032 this . lint = lint ;
3133 this . autorebase = autorebase ;
3234 this . fixupAll = fixupAll ;
35+ this . allowMultipleCommits = allowMultipleCommits ;
3336 this . expectedCommitShas = [ ] ;
3437 this . checkCI = ! ! checkCI ;
3538 }
@@ -40,6 +43,7 @@ class LandingSession extends Session {
4043 args . lint = this . lint ;
4144 args . autorebase = this . autorebase ;
4245 args . fixupAll = this . fixupAll ;
46+ args . allowMultipleCommits = this . allowMultipleCommits ;
4347 return args ;
4448 }
4549
@@ -349,7 +353,9 @@ class LandingSession extends Session {
349353 }
350354
351355 async final ( ) {
352- const { cli, owner, repo, upstream, branch, prid } = this ;
356+ const {
357+ cli, owner, repo, upstream, branch, prid, allowMultipleCommits
358+ } = this ;
353359
354360 // Check that git rebase/am has been completed.
355361 if ( ! this . readyToFinal ( ) ) {
@@ -360,6 +366,20 @@ class LandingSession extends Session {
360366 } ;
361367
362368 const stray = this . getStrayCommits ( ) ;
369+ if ( stray . length > 1 ) {
370+ const forceLand = await cli . prompt (
371+ 'There are more than one commit in the PR. ' +
372+ 'Do you still want to land it?' ,
373+ { defaultAnswer : allowMultipleCommits } ) ;
374+
375+ if ( ! forceLand ) {
376+ cli . info (
377+ 'Use --fixupAll option, squash the PR manually or land the PR from ' +
378+ 'the command line.'
379+ ) ;
380+ process . exit ( 1 ) ;
381+ }
382+ }
363383 const strayVerbose = this . getStrayCommits ( true ) ;
364384 const validateCommand = path . join (
365385 __dirname ,
0 commit comments