@@ -82,12 +82,28 @@ export default class LandingSession extends Session {
8282 }
8383
8484 async downloadAndPatch ( ) {
85- const { cli, upstream, prid, expectedCommitShas } = this ;
85+ const { cli, upstream, prid, expectedCommitShas, crossRepoPR } = this ;
86+
87+ if ( crossRepoPR ) {
88+ const { owner, repo } = this ;
89+ let response ;
90+ do {
91+ cli . warn ( `The configured remote "${ upstream } " does not point to the ` +
92+ 'Pull Request repository.' ) ;
93+ cli . warn ( 'We cannot fetch the commit(s) automatically, the user needs to fetch manually.' ) ;
94+
95+ cli . info ( 'Run the following command to fetch the commit(s):' ) ;
96+ cli . info ( `git fetch git@github.com:${ owner } /${ repo } .git refs/pull/${ prid } /merge` ) ;
97+ response = await cli . prompt ( 'Ready to continue?' , { defaultAnswer : false } ) ;
98+ } while ( ! response ) ;
99+ cli . startSpinner ( 'Parse fetched merge commit' ) ;
100+ } else {
101+ cli . startSpinner ( `Downloading patch for ${ prid } ` ) ;
102+ await runAsync ( 'git' , [
103+ 'fetch' , upstream ,
104+ `refs/pull/${ prid } /merge` ] ) ;
105+ }
86106
87- cli . startSpinner ( `Downloading patch for ${ prid } ` ) ;
88- await runAsync ( 'git' , [
89- 'fetch' , upstream ,
90- `refs/pull/${ prid } /merge` ] ) ;
91107 // We fetched the commit that would result if we used `git merge`.
92108 // ^1 and ^2 refer to the PR base and the PR head, respectively.
93109 const [ base , head ] = await runAsync ( 'git' ,
@@ -472,7 +488,7 @@ export default class LandingSession extends Session {
472488 }
473489
474490 cli . separator ( ) ;
475- cli . log ( 'The following commits are ready to be pushed to ' +
491+ cli . log ( 'The following commits are landable on ' +
476492 `${ upstream } /${ branch } ` ) ;
477493 cli . log ( `- ${ strayVerbose . join ( '\n- ' ) } ` ) ;
478494 cli . separator ( ) ;
@@ -483,8 +499,15 @@ export default class LandingSession extends Session {
483499 willBeLanded = `${ head } ...${ willBeLanded } ` ;
484500 }
485501
502+ cli . startSpinner ( 'Removing temporary files' ) ;
486503 this . cleanFiles ( ) ;
487- cli . log ( 'Temporary files removed.' ) ;
504+ cli . stopSpinner ( 'Temporary files removed.' ) ;
505+ if ( this . crossRepoPR ) {
506+ cli . warn ( `The configured remote "${ upstream } " does not point to the ` +
507+ 'Pull Request repository.' ) ;
508+ cli . info ( `${ willBeLanded } should likely not be pushed to "${ upstream } "` ) ;
509+ return ;
510+ }
488511 cli . log ( 'To finish landing:' ) ;
489512 cli . log ( '1. Run: ' ) ;
490513 cli . log ( ` git push ${ upstream } ${ branch } ` ) ;
0 commit comments