@@ -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 = () => {};
@@ -591,18 +592,37 @@ export const gitStackedRebase = async (
591592 await repo . checkoutBranch ( newLatestBranchCmd . targets ! [ 0 ] ) ;
592593
593594 /**
594- * TODO update in the actual `git-rebase-todo` file
595+ * need to change to "branch-end", instead of "branch-end-new",
596+ * since obviously the branch already exists
595597 */
598+ oldLatestBranchCmd . commandName = "branch-end" ;
599+ oldLatestBranchCmd . commandOrAliasName = "branch-end" ;
600+
601+ newLatestBranchCmd . commandName = "branch-end-last" ;
602+ newLatestBranchCmd . commandOrAliasName = "branch-end-last" ;
596603
597604 /**
598- * need to change to "branch-end", instead of "branch-end-new",
599- * since obviously the branch already exists
605+ * TODO FIXME don't do this so hackishly lmao
600606 */
601- goodCommands [ oldLatestBranchCmdIndex ] . commandName = "branch-end" ;
602- goodCommands [ oldLatestBranchCmdIndex ] . commandOrAliasName = "branch-end" ;
607+ const editedRebaseTodo : string = fs . readFileSync ( pathToStackedRebaseTodoFile , { encoding : "utf-8" } ) ;
608+ const linesOfEditedRebaseTodo : string [ ] = editedRebaseTodo . split ( "\n" ) ;
609+
610+ replaceCommandInText ( oldLatestBranchCmd , "branch-end-last" , "branch-end" ) ;
611+ replaceCommandInText ( newLatestBranchCmd , "branch-end-new" , "branch-end-last" ) ;
612+
613+ // eslint-disable-next-line no-inner-declarations
614+ function replaceCommandInText (
615+ cmd : GoodCommandStacked , //
616+ expectedOldName : StackedRebaseEitherCommandOrAlias ,
617+ newName : StackedRebaseCommand
618+ ) : void {
619+ const words = linesOfEditedRebaseTodo [ cmd . lineNumber ] . split ( " " ) ;
620+ assert . equal ( words [ 0 ] , expectedOldName ) ;
621+ words [ 0 ] = newName ;
622+ linesOfEditedRebaseTodo [ oldLatestBranchCmd . lineNumber ] = words . join ( " " ) ;
623+ }
603624
604- goodCommands [ newLatestBranchCmdIndex ] . commandName = "branch-end-last" ;
605- goodCommands [ newLatestBranchCmdIndex ] . commandOrAliasName = "branch-end-last" ;
625+ fs . writeFileSync ( pathToStackedRebaseTodoFile , linesOfEditedRebaseTodo . join ( "\n" ) , { encoding : "utf-8" } ) ;
606626
607627 /**
608628 * it's fine if the new "latest branch" does not have
0 commit comments