@@ -26,6 +26,7 @@ import {
2626 GoodCommandStacked , //
2727 namesOfRebaseCommandsThatMakeRebaseExitToPause ,
2828 StackedRebaseCommand ,
29+ StackedRebaseEitherCommandOrAlias ,
2930} from "./parse-todo-of-stacked-rebase/validator" ;
3031
3132// console.log = () => {};
@@ -592,18 +593,37 @@ export const gitStackedRebase = async (
592593 await repo . checkoutBranch ( newLatestBranchCmd . targets ! [ 0 ] ) ;
593594
594595 /**
595- * TODO update in the actual `git-rebase-todo` file
596+ * need to change to "branch-end", instead of "branch-end-new",
597+ * since obviously the branch already exists
596598 */
599+ oldLatestBranchCmd . commandName = "branch-end" ;
600+ oldLatestBranchCmd . commandOrAliasName = "branch-end" ;
601+
602+ newLatestBranchCmd . commandName = "branch-end-last" ;
603+ newLatestBranchCmd . commandOrAliasName = "branch-end-last" ;
597604
598605 /**
599- * need to change to "branch-end", instead of "branch-end-new",
600- * since obviously the branch already exists
606+ * TODO FIXME don't do this so hackishly lmao
601607 */
602- goodCommands [ oldLatestBranchCmdIndex ] . commandName = "branch-end" ;
603- goodCommands [ oldLatestBranchCmdIndex ] . commandOrAliasName = "branch-end" ;
608+ const editedRebaseTodo : string = fs . readFileSync ( pathToStackedRebaseTodoFile , { encoding : "utf-8" } ) ;
609+ const linesOfEditedRebaseTodo : string [ ] = editedRebaseTodo . split ( "\n" ) ;
610+
611+ replaceCommandInText ( oldLatestBranchCmd , "branch-end-last" , "branch-end" ) ;
612+ replaceCommandInText ( newLatestBranchCmd , "branch-end-new" , "branch-end-last" ) ;
613+
614+ // eslint-disable-next-line no-inner-declarations
615+ function replaceCommandInText (
616+ cmd : GoodCommandStacked , //
617+ expectedOldName : StackedRebaseEitherCommandOrAlias ,
618+ newName : StackedRebaseCommand
619+ ) : void {
620+ const words = linesOfEditedRebaseTodo [ cmd . lineNumber ] . split ( " " ) ;
621+ assert . equal ( words [ 0 ] , expectedOldName ) ;
622+ words [ 0 ] = newName ;
623+ linesOfEditedRebaseTodo [ oldLatestBranchCmd . lineNumber ] = words . join ( " " ) ;
624+ }
604625
605- goodCommands [ newLatestBranchCmdIndex ] . commandName = "branch-end-last" ;
606- goodCommands [ newLatestBranchCmdIndex ] . commandOrAliasName = "branch-end-last" ;
626+ fs . writeFileSync ( pathToStackedRebaseTodoFile , linesOfEditedRebaseTodo . join ( "\n" ) , { encoding : "utf-8" } ) ;
607627
608628 /**
609629 * it's fine if the new "latest branch" does not have
0 commit comments