Skip to content

Commit 45190af

Browse files
committed
update commands only after updating the text file contents
Signed-off-by: Kipras Melnikovas <[email protected]>
1 parent ec1598f commit 45190af

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

git-stacked-rebase.ts

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -593,28 +593,6 @@ export const gitStackedRebase = async (
593593
*/
594594
await repo.checkoutBranch(newLatestBranchCmd.targets![0]);
595595

596-
/**
597-
* update the commands
598-
* TODO update in the actual `git-rebase-todo` file
599-
*/
600-
// swapKeys(oldLatestBranchCmd, newLatestBranchCmd, "commandName");
601-
// swapKeys(oldLatestBranchCmd, newLatestBranchCmd, "commandOrAliasName"); // eslint-disable-line prettier/prettier
602-
603-
// // eslint-disable-next-line no-inner-declarations
604-
// function swapKeys<T>(A: T, B: T, key: keyof T): void {
605-
// [A[key], B[key]] = [B[key], A[key]];
606-
// }
607-
608-
/**
609-
* need to change to "branch-end", instead of "branch-end-new",
610-
* since obviously the branch already exists
611-
*/
612-
oldLatestBranchCmd.commandName = "branch-end";
613-
oldLatestBranchCmd.commandOrAliasName = "branch-end";
614-
615-
newLatestBranchCmd.commandName = "branch-end-last";
616-
newLatestBranchCmd.commandOrAliasName = "branch-end-last";
617-
618596
/**
619597
* TODO FIXME don't do this so hackishly lmao
620598
*/
@@ -649,11 +627,37 @@ export const gitStackedRebase = async (
649627
"invalid old name of command in git-rebase-todo file"
650628
);
651629
words[0] = newName;
630+
console.log({ before: linesOfEditedRebaseTodo[oldLatestBranchCmd.lineNumber] });
652631
linesOfEditedRebaseTodo[oldLatestBranchCmd.lineNumber] = words.join(" ");
632+
console.log({ after: linesOfEditedRebaseTodo[oldLatestBranchCmd.lineNumber] });
653633
}
654634

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

637+
/**
638+
* update the commands
639+
* TODO update in the actual `git-rebase-todo` file
640+
*/
641+
// swapKeys(oldLatestBranchCmd, newLatestBranchCmd, "commandName");
642+
// swapKeys(oldLatestBranchCmd, newLatestBranchCmd, "commandOrAliasName"); // eslint-disable-line prettier/prettier
643+
644+
// // eslint-disable-next-line no-inner-declarations
645+
// function swapKeys<T>(A: T, B: T, key: keyof T): void {
646+
// [A[key], B[key]] = [B[key], A[key]];
647+
// }
648+
649+
/**
650+
* need to change to "branch-end", instead of "branch-end-new",
651+
* since obviously the branch already exists
652+
*
653+
* TODO RE-PARSE ALL COMMANDS FROM THE FILE INSTEAD
654+
*/
655+
oldLatestBranchCmd.commandName = "branch-end";
656+
oldLatestBranchCmd.commandOrAliasName = "branch-end";
657+
658+
newLatestBranchCmd.commandName = "branch-end-last";
659+
newLatestBranchCmd.commandOrAliasName = "branch-end-last";
660+
657661
/**
658662
* it's fine if the new "latest branch" does not have
659663
* a remote set yet, because `--push` handles that,

0 commit comments

Comments
 (0)