@@ -21,12 +21,13 @@ import { uniq } from "./util/uniq";
2121import { parseTodoOfStackedRebase } from "./parse-todo-of-stacked-rebase/parseTodoOfStackedRebase" ;
2222import { Termination } from "./util/error" ;
2323import { assertNever } from "./util/assertNever" ;
24+ import { Single , Tuple } from "./util/tuple" ;
2425import {
2526 GoodCommand ,
2627 GoodCommandStacked , //
2728 namesOfRebaseCommandsThatMakeRebaseExitToPause ,
2829 StackedRebaseCommand ,
29- StackedRebaseEitherCommandOrAlias ,
30+ StackedRebaseCommandAlias ,
3031} from "./parse-todo-of-stacked-rebase/validator" ;
3132
3233// console.log = () => {};
@@ -608,17 +609,20 @@ export const gitStackedRebase = async (
608609 const editedRebaseTodo : string = fs . readFileSync ( pathToStackedRebaseTodoFile , { encoding : "utf-8" } ) ;
609610 const linesOfEditedRebaseTodo : string [ ] = editedRebaseTodo . split ( "\n" ) ;
610611
611- replaceCommandInText ( oldLatestBranchCmd , "branch-end-last" , "branch-end" ) ;
612- replaceCommandInText ( newLatestBranchCmd , "branch-end-new" , "branch-end-last" ) ;
612+ replaceCommandInText ( oldLatestBranchCmd , [ "branch-end-last" ] , "branch-end" ) ;
613+ replaceCommandInText ( newLatestBranchCmd , [ "branch-end-new" , "ben" ] , "branch-end-last" ) ;
613614
614615 // eslint-disable-next-line no-inner-declarations
615616 function replaceCommandInText (
616617 cmd : GoodCommandStacked , //
617- expectedOldName : StackedRebaseEitherCommandOrAlias ,
618+ allowedOldName : Single < StackedRebaseCommand > | Tuple < StackedRebaseCommand , StackedRebaseCommandAlias > ,
618619 newName : StackedRebaseCommand
619620 ) : void {
620621 const words = linesOfEditedRebaseTodo [ cmd . lineNumber ] . split ( " " ) ;
621- assert . equal ( words [ 0 ] , expectedOldName ) ;
622+ assert (
623+ allowedOldName . some ( ( n ) => n === words [ 0 ] ) ,
624+ `invalid old name of command in git-rebase-todo file. got "${ words [ 0 ] } ", expected one of "${ allowedOldName } ".`
625+ ) ;
622626 words [ 0 ] = newName ;
623627 linesOfEditedRebaseTodo [ oldLatestBranchCmd . lineNumber ] = words . join ( " " ) ;
624628 }
0 commit comments