Skip to content

Commit 8f85d8d

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

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
@@ -593,16 +593,6 @@ export const gitStackedRebase = async (
593593
*/
594594
await repo.checkoutBranch(newLatestBranchCmd.targets![0]);
595595

596-
/**
597-
* need to change to "branch-end", instead of "branch-end-new",
598-
* since obviously the branch already exists
599-
*/
600-
oldLatestBranchCmd.commandName = "branch-end";
601-
oldLatestBranchCmd.commandOrAliasName = "branch-end";
602-
603-
newLatestBranchCmd.commandName = "branch-end-last";
604-
newLatestBranchCmd.commandOrAliasName = "branch-end-last";
605-
606596
/**
607597
* TODO FIXME don't do this so hackishly lmao
608598
*/
@@ -624,11 +614,22 @@ export const gitStackedRebase = async (
624614
"invalid old name of command in git-rebase-todo file"
625615
);
626616
words[0] = newName;
617+
console.log({ before: linesOfEditedRebaseTodo[oldLatestBranchCmd.lineNumber] });
627618
linesOfEditedRebaseTodo[oldLatestBranchCmd.lineNumber] = words.join(" ");
619+
console.log({ after: linesOfEditedRebaseTodo[oldLatestBranchCmd.lineNumber] });
628620
}
629621

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

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

0 commit comments

Comments
 (0)