@@ -22,14 +22,17 @@ const LINT_RESULTS = {
22
22
} ;
23
23
24
24
class 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, oneCommitMax
28
+ } = { } ) {
27
29
super ( cli , dir , prid ) ;
28
30
this . req = req ;
29
31
this . backport = backport ;
30
32
this . lint = lint ;
31
33
this . autorebase = autorebase ;
32
34
this . fixupAll = fixupAll ;
35
+ this . oneCommitMax = oneCommitMax ;
33
36
this . expectedCommitShas = [ ] ;
34
37
this . checkCI = ! ! checkCI ;
35
38
}
@@ -40,6 +43,7 @@ class LandingSession extends Session {
40
43
args . lint = this . lint ;
41
44
args . autorebase = this . autorebase ;
42
45
args . fixupAll = this . fixupAll ;
46
+ args . oneCommitMax = this . oneCommitMax ;
43
47
return args ;
44
48
}
45
49
@@ -349,7 +353,9 @@ class LandingSession extends Session {
349
353
}
350
354
351
355
async final ( ) {
352
- const { cli, owner, repo, upstream, branch, prid } = this ;
356
+ const {
357
+ cli, owner, repo, upstream, branch, prid, oneCommitMax
358
+ } = this ;
353
359
354
360
// Check that git rebase/am has been completed.
355
361
if ( ! this . readyToFinal ( ) ) {
@@ -360,6 +366,20 @@ class LandingSession extends Session {
360
366
} ;
361
367
362
368
const stray = this . getStrayCommits ( ) ;
369
+ if ( stray . length > 1 ) {
370
+ const forceLand = await cli . prompt (
371
+ 'There is more than one commit in the PR. ' +
372
+ 'Do you still want to land it?' ,
373
+ { defaultAnswer : ! oneCommitMax } ) ;
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
+ }
363
383
const strayVerbose = this . getStrayCommits ( true ) ;
364
384
const validateCommand = path . join (
365
385
__dirname ,
0 commit comments