Skip to content

Commit fbb8fdf

Browse files
committed
update commands only after updating the text file contents
Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
1 parent 7b35dcd commit fbb8fdf

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

git-stacked-rebase.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -592,16 +592,6 @@ export const gitStackedRebase = async (
592592
*/
593593
await repo.checkoutBranch(newLatestBranchCmd.targets![0]);
594594

595-
/**
596-
* need to change to "branch-end", instead of "branch-end-new",
597-
* since obviously the branch already exists
598-
*/
599-
oldLatestBranchCmd.commandName = "branch-end";
600-
oldLatestBranchCmd.commandOrAliasName = "branch-end";
601-
602-
newLatestBranchCmd.commandName = "branch-end-last";
603-
newLatestBranchCmd.commandOrAliasName = "branch-end-last";
604-
605595
/**
606596
* TODO FIXME don't do this so hackishly lmao
607597
*/
@@ -623,11 +613,22 @@ export const gitStackedRebase = async (
623613
`invalid old name of command in git-rebase-todo file. got "${words[0]}", expected one of "${allowedOldName}".`
624614
);
625615
words[0] = newName;
616+
console.log({ before: linesOfEditedRebaseTodo[oldLatestBranchCmd.lineNumber] });
626617
linesOfEditedRebaseTodo[oldLatestBranchCmd.lineNumber] = words.join(" ");
618+
console.log({ after: linesOfEditedRebaseTodo[oldLatestBranchCmd.lineNumber] });
627619
}
628620

629621
fs.writeFileSync(pathToStackedRebaseTodoFile, linesOfEditedRebaseTodo.join("\n"), { encoding: "utf-8" });
630622

623+
/**
624+
* TODO RE-PARSE ALL COMMANDS FROM THE FILE INSTEAD
625+
*/
626+
oldLatestBranchCmd.commandName = "branch-end";
627+
oldLatestBranchCmd.commandOrAliasName = "branch-end";
628+
629+
newLatestBranchCmd.commandName = "branch-end-last";
630+
newLatestBranchCmd.commandOrAliasName = "branch-end-last";
631+
631632
/**
632633
* it's fine if the new "latest branch" does not have
633634
* a remote set yet, because `--push` handles that,

0 commit comments

Comments
 (0)