@@ -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 = () => {};
@@ -633,17 +634,20 @@ export const gitStackedRebase = async (
633634 // newLineBefore.splice(0, 1, "branch-end-last"); // remove 1st word ("branch-end") and add "branch-end-last"
634635 // linesOfEditedRebaseTodo[newLatestBranchCmd.lineNumber] = newLineBefore.join(" ");
635636
636- replaceCommandInText ( oldLatestBranchCmd , "branch-end-last" , "branch-end" ) ;
637- replaceCommandInText ( newLatestBranchCmd , "branch-end-new" , "branch-end-last" ) ;
637+ replaceCommandInText ( oldLatestBranchCmd , [ "branch-end-last" ] , "branch-end" ) ;
638+ replaceCommandInText ( newLatestBranchCmd , [ "branch-end-new" , "ben" ] , "branch-end-last" ) ;
638639
639640 // eslint-disable-next-line no-inner-declarations
640641 function replaceCommandInText (
641642 cmd : GoodCommandStacked , //
642- expectedOldName : StackedRebaseEitherCommandOrAlias ,
643+ allowedOldName : Single < StackedRebaseCommand > | Tuple < StackedRebaseCommand , StackedRebaseCommandAlias > ,
643644 newName : StackedRebaseCommand
644645 ) : void {
645646 const words = linesOfEditedRebaseTodo [ cmd . lineNumber ] . split ( " " ) ;
646- assert . equal ( words [ 0 ] , expectedOldName ) ;
647+ assert (
648+ allowedOldName . some ( ( n ) => n === words [ 0 ] ) ,
649+ "invalid old name of command in git-rebase-todo file"
650+ ) ;
647651 words [ 0 ] = newName ;
648652 linesOfEditedRebaseTodo [ oldLatestBranchCmd . lineNumber ] = words . join ( " " ) ;
649653 }
0 commit comments