@@ -1400,9 +1400,15 @@ async function getWantedCommitsWithBranchBoundariesUsingNativeGitRebase({
14001400
14011401 const regularRebaseDirBackupPath : string = pathToRegularRebaseDirInsideDotGit + ".backup-from-1st" ;
14021402
1403+ const editorScriptSuccessIndicator : string = path . join ( regularRebaseDirBackupPath , "success" ) ;
1404+ const checkIfSucceeded = ( ) : boolean => fs . existsSync ( editorScriptSuccessIndicator ) ;
1405+
14031406 const editorScript = `\
14041407#!/usr/bin/env bash
14051408
1409+ # remove beforehand
1410+ rm -rf ${ editorScriptSuccessIndicator }
1411+
14061412printf "yes sir\n\n"
14071413
14081414pushd "${ dotGitDirPath } "
@@ -1415,7 +1421,13 @@ cat ${pathToRegularRebaseTodoFile}
14151421# cat ${ pathToRegularRebaseTodoFile } > ${ pathToStackedRebaseTodoFile } .regular
14161422cp -r ${ pathToRegularRebaseDirInsideDotGit } ${ regularRebaseDirBackupPath }
14171423
1418- # abort the rebase before even starting it
1424+ # indicate success (MUST BE THE LAST COMMAND BEFORE EXITING)
1425+ touch ${ editorScriptSuccessIndicator }
1426+
1427+ # abort the rebase before even starting it --
1428+ # we get what we want - the git-rebase-todo file,
1429+ # and we exit so that the rebase won't proceed
1430+ # and wil cleanup instead.
14191431exit 1
14201432 ` ;
14211433 const editorScriptPath : string = path . join ( dotGitDirPath , "editorScript.sh" ) ;
@@ -1465,13 +1477,17 @@ exit 1
14651477 // https://git-scm.com/docs/git-rebase#Documentation/git-rebase.txt-sequenceeditor
14661478 GIT_SEQUENCE_EDITOR : editorScriptPath ,
14671479 } ,
1480+ stdio : "pipe" ,
14681481 } ) ;
14691482 } catch ( e ) {
1470- // as expected. do nothing.
1471- // TODO verify that it actually came from our script exiting intentionally
1483+ if ( ! checkIfSucceeded ( ) ) {
1484+ throw e ;
1485+ } else {
1486+ // as expected. do nothing & continue.
1487+ }
14721488 }
14731489
1474- console . log ( "rebase -i exited" ) ;
1490+ console . log ( "rebase -i exited successfully " ) ;
14751491
14761492 const goodRegularCommands : GoodCommandRegular [ ] = parseTodoOfStackedRebase (
14771493 path . join ( regularRebaseDirBackupPath , filenames . gitRebaseTodo )
0 commit comments