File tree Expand file tree Collapse file tree 2 files changed +24
-7
lines changed Expand file tree Collapse file tree 2 files changed +24
-7
lines changed Original file line number Diff line number Diff line change @@ -15,16 +15,24 @@ import {rebasePr} from './index.js';
1515/** The options available to the rebase command via CLI. */
1616export interface RebaseOptions {
1717 pr : number ;
18+ i ?: boolean ;
1819}
1920
2021/** Builds the rebase pull request command. */
2122function builder ( argv : Argv ) : Argv < RebaseOptions > {
22- return addGithubTokenOption ( argv ) . positional ( 'pr' , { type : 'number' , demandOption : true } ) ;
23+ return addGithubTokenOption ( argv )
24+ . positional ( 'pr' , { type : 'number' , demandOption : true } )
25+ . option ( 'interactive' , {
26+ type : 'boolean' ,
27+ alias : [ 'i' ] ,
28+ demandOption : false ,
29+ describe : 'Do the rebase interactively so that things can be squashed and amended' ,
30+ } ) ;
2331}
2432
2533/** Handles the rebase pull request command. */
26- async function handler ( { pr} : Arguments < RebaseOptions > ) {
27- process . exitCode = await rebasePr ( pr ) ;
34+ async function handler ( { pr, i } : Arguments < RebaseOptions > ) {
35+ process . exitCode = await rebasePr ( pr , i ) ;
2836}
2937
3038/** yargs command module for rebasing a PR */
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import {fetchPullRequestFromGithub} from '../common/fetch-pull-request.js';
1919 *
2020 * @returns a status code indicating whether the rebase was successful.
2121 */
22- export async function rebasePr ( prNumber : number ) : Promise < number > {
22+ export async function rebasePr ( prNumber : number , interactive : boolean = false ) : Promise < number > {
2323 /** The singleton instance of the authenticated git client. */
2424 const git = await AuthenticatedGitClient . get ( ) ;
2525
@@ -99,9 +99,18 @@ export async function rebasePr(prNumber: number): Promise<number> {
9999 * Additional flags to perform the autosquashing are added when the user confirm squashing of
100100 * fixup commits should occur.
101101 */
102- const [ flags , env ] = squashFixups
103- ? [ [ '--interactive' , '--autosquash' ] , { ...process . env , GIT_SEQUENCE_EDITOR : 'true' } ]
104- : [ [ ] , undefined ] ;
102+
103+ let flags : string [ ] = [ ] ;
104+ let env = undefined ;
105+
106+ if ( squashFixups || interactive ) {
107+ env = { ...process . env , GIT_SEQUENCE_EDITOR : 'true' } ;
108+ flags . push ( '--interactive' ) ;
109+ }
110+ if ( squashFixups ) {
111+ flags . push ( '--autosquash' ) ;
112+ }
113+
105114 const rebaseResult = git . runGraceful ( [ 'rebase' , ...flags , 'FETCH_HEAD' ] , { env : env } ) ;
106115
107116 // If the rebase was clean, push the rebased PR up to the authors fork.
You can’t perform that action at this time.
0 commit comments