Skip to content

Commit a73d19d

Browse files
committed
fix: part 1 - exit immediately after rebase --continue if regular rebase didn't finish
Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
1 parent def3259 commit a73d19d

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

git-stacked-rebase.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,43 @@ cat "$REWRITTEN_LIST_FILE_PATH" > "$REWRITTEN_LIST_BACKUP_FILE_PATH"
501501
*
502502
*/
503503
execSyncInRepo(`${options.gitCmd} rebase --continue`);
504+
/**
505+
* if the rebase finishes and ONLY THEN EXITS,
506+
* it's fine and we continue.
507+
*
508+
* otherwise, there was some commands that made the git rebase exit
509+
* in order to allow the user to perform actions
510+
* (i.e. break, edit),
511+
* and thus the `execSync` command will exit and if we ran,
512+
* we'd run without the actual rebase having finished,
513+
*
514+
* so the information would be incomplete
515+
* and we'd cause other actions that will further f it up.
516+
*
517+
* thus, to avoid this, we exit ourselves if the regular rebase
518+
* is still in progress.
519+
*
520+
* ---
521+
*
522+
* note: we would not have to deal with this if we implemented git rebase ourselves here,
523+
* but that'd be a lot of work + maintainability,
524+
* + also we'd need to
525+
*
526+
* edit: wait nvm, we'd fall into the same issues in the same exact scenarios
527+
* (because we are interactive, but break off as soon as need manual input from user
528+
* and cannot get it without exiting),
529+
* so no, this is a given then.
530+
*
531+
*/
532+
// taken from "part 1" from "canAndShouldBeApplying" from below,
533+
// though using the actual (regular) rebase folder instead of ours
534+
const isRegularRebaseStillInProgress: boolean = fs.existsSync(
535+
path.join(pathToRegularRebaseDirInsideDotGit, filenames.rewrittenList)
536+
);
537+
538+
if (isRegularRebaseStillInProgress) {
539+
return;
540+
}
504541

505542
// await repo.continueRebase(undefined as any, () => {
506543
// //
@@ -518,6 +555,8 @@ cat "$REWRITTEN_LIST_FILE_PATH" > "$REWRITTEN_LIST_BACKUP_FILE_PATH"
518555

519556
// const rebase = await Git.Rebase.init()
520557

558+
console.log("CONTINUING AFTER EXEC SYNC rebase --continue");
559+
521560
const commitShaOfNewCurrentCommit = await getCurrentCommit();
522561
const rebaseChangedLocalHistory: boolean = commitShaOfCurrentCommit !== commitShaOfNewCurrentCommit;
523562

0 commit comments

Comments
 (0)