@@ -21,6 +21,7 @@ import {
2121 gitRebaseArguments ,
2222 IGitStringExecutionOptions ,
2323 IGitStringResult ,
24+ HookCallbackOptions ,
2425} from './core'
2526import { stageManualConflictResolution } from './stage'
2627import { stageFiles } from './update-index'
@@ -438,8 +439,7 @@ export async function continueRebase(
438439 repository : Repository ,
439440 files : ReadonlyArray < WorkingDirectoryFileChange > ,
440441 manualResolutions : ReadonlyMap < string , ManualConflictResolution > = new Map ( ) ,
441- progressCallback ?: ( progress : IMultiCommitOperationProgress ) => void ,
442- gitEditor : string = ':'
442+ opts ?: RebaseInteractiveOptions
443443) : Promise < RebaseResult > {
444444 const trackedFiles = files . filter ( f => {
445445 return f . status . kind !== AppFileStatusKind . Untracked
@@ -484,13 +484,13 @@ export async function continueRebase(
484484 GitError . UnresolvedConflicts ,
485485 ] ) ,
486486 env : {
487- GIT_EDITOR : gitEditor ,
487+ GIT_EDITOR : opts ?. gitEditor ?? ':' ,
488488 } ,
489489 }
490490
491491 let options = baseOptions
492492
493- if ( progressCallback !== undefined ) {
493+ if ( opts ?. progressCallback ) {
494494 const snapshot = await getRebaseSnapshot ( repository )
495495
496496 if ( snapshot === null ) {
@@ -502,17 +502,24 @@ export async function continueRebase(
502502
503503 options = configureOptionsForRebase ( baseOptions , {
504504 commits : snapshot . commits ,
505- progressCallback,
505+ progressCallback : opts . progressCallback ,
506506 } )
507507 }
508508
509+ options = {
510+ ...options ,
511+ onTerminalOutputAvailable : opts ?. onTerminalOutputAvailable ,
512+ onHookFailure : opts ?. onHookFailure ,
513+ onHookProgress : opts ?. onHookProgress ,
514+ }
515+
509516 if ( trackedFilesAfter . length === 0 ) {
510517 log . warn (
511518 `[rebase] no tracked changes to commit for ${ rebaseCurrentCommit } , continuing rebase but skipping this commit`
512519 )
513520
514521 const result = await git (
515- [ 'rebase' , '--skip' ] ,
522+ [ 'rebase' , '--skip' , ... ( opts ?. noVerify ? [ '--no-verify' ] : [ ] ) ] ,
516523 repository . path ,
517524 'continueRebaseSkipCurrentCommit' ,
518525 options
@@ -522,7 +529,7 @@ export async function continueRebase(
522529 }
523530
524531 const result = await git (
525- [ 'rebase' , '--continue' ] ,
532+ [ 'rebase' , '--continue' , ... ( opts ?. noVerify ? [ '--no-verify' ] : [ ] ) ] ,
526533 repository . path ,
527534 'continueRebase' ,
528535 options
@@ -531,6 +538,22 @@ export async function continueRebase(
531538 return parseRebaseResult ( result )
532539}
533540
541+ export type RebaseInteractiveOptions = {
542+ /**
543+ * a description of the action to be displayed in the progress dialog - i.e. Squash, Amend, etc..
544+ */
545+ action ?: string
546+
547+ /**
548+ * the GIT_EDITOR environment variable to use during the interactive rebase,
549+ * defaults to ':' which is a no-op command
550+ */
551+ gitEditor ?: string
552+ progressCallback ?: ( progress : IMultiCommitOperationProgress ) => void
553+ commits ?: ReadonlyArray < Commit >
554+ noVerify ?: boolean
555+ } & HookCallbackOptions
556+
534557/**
535558 * Method for initiating interactive rebase in the app.
536559 *
@@ -543,30 +566,27 @@ export async function continueRebase(
543566 * @param lastRetainedCommitRef the commit before the earliest commit to be
544567 * changed during the interactive rebase or null if commit is root (first commit
545568 * in history) of branch
546- * @param action a description of the action to be displayed in the progress
547- * dialog - i.e. Squash, Amend, etc..
548569 */
549570export async function rebaseInteractive (
550571 repository : Repository ,
551572 pathOfGeneratedTodo : string ,
552573 lastRetainedCommitRef : string | null ,
553- action : string = 'Interactive rebase' ,
554- gitEditor : string = ':' ,
555- progressCallback ?: ( progress : IMultiCommitOperationProgress ) => void ,
556- commits ?: ReadonlyArray < Commit >
574+ opts ?: RebaseInteractiveOptions
557575) : Promise < RebaseResult > {
558576 const baseOptions : IGitStringExecutionOptions = {
559577 expectedErrors : new Set ( [ GitError . RebaseConflicts ] ) ,
560578 env : {
561579 GIT_SEQUENCE_EDITOR : undefined ,
562- GIT_EDITOR : gitEditor ,
580+ GIT_EDITOR : opts ?. gitEditor ?? ':' ,
563581 } ,
564582 }
565583
566584 let options = baseOptions
567585
568- if ( progressCallback !== undefined ) {
569- if ( commits === undefined ) {
586+ const { progressCallback, commits } = opts ?? { }
587+
588+ if ( progressCallback ) {
589+ if ( ! commits ) {
570590 log . warn ( `Unable to interactively rebase if no commits` )
571591 return RebaseResult . Error
572592 }
@@ -577,6 +597,13 @@ export async function rebaseInteractive(
577597 } )
578598 }
579599
600+ options = {
601+ ...options ,
602+ onHookProgress : opts ?. onHookProgress ,
603+ onHookFailure : opts ?. onHookFailure ,
604+ onTerminalOutputAvailable : opts ?. onTerminalOutputAvailable ,
605+ }
606+
580607 /* If the commit is the first commit in the branch, we cannot reference it
581608 using the sha thus if lastRetainedCommitRef is null (we couldn't define it),
582609 we must use the --root flag */
@@ -587,11 +614,12 @@ export async function rebaseInteractive(
587614 // This replaces interactive todo with contents of file at pathOfGeneratedTodo
588615 `sequence.editor=cat "${ pathOfGeneratedTodo } " >` ,
589616 'rebase' ,
617+ ...( opts ?. noVerify ? [ '--no-verify' ] : [ ] ) ,
590618 '-i' ,
591619 ref ,
592620 ] ,
593621 repository . path ,
594- action ,
622+ opts ?. action ?? 'Interactive rebase' ,
595623 options
596624 )
597625
0 commit comments