diff --git a/apply.ts b/apply.ts index 03bc8785..c37f976b 100644 --- a/apply.ts +++ b/apply.ts @@ -109,7 +109,7 @@ const getPaths = ( appliedPath: path.join(pathToStackedRebaseDirInsideDotGit, filenames.applied), } as const); -const markThatNeedsToApply = ( +export const markThatNeedsToApply = ( pathToStackedRebaseDirInsideDotGit: string // ): void => [getPaths(pathToStackedRebaseDirInsideDotGit)].map( diff --git a/filenames.ts b/filenames.ts index ccc32479..518504d4 100644 --- a/filenames.ts +++ b/filenames.ts @@ -3,6 +3,7 @@ */ export const filenames = { rewrittenList: "rewritten-list", + willNeedToApply: "will-need-to-apply", needsToApply: "needs-to-apply", applied: "applied", // diff --git a/git-stacked-rebase.ts b/git-stacked-rebase.ts index f5599164..b9f42a00 100755 --- a/git-stacked-rebase.ts +++ b/git-stacked-rebase.ts @@ -11,7 +11,7 @@ import { bullets } from "nice-comment"; import { filenames } from "./filenames"; import { configKeys } from "./configKeys"; -import { apply, applyIfNeedsToApply } from "./apply"; +import { apply, applyIfNeedsToApply, markThatNeedsToApply as _markThatNeedsToApply } from "./apply"; import { forcePush } from "./forcePush"; import { branchSequencer } from "./branchSequencer"; @@ -284,6 +284,10 @@ export const gitStackedRebase = async ( const pathToStackedRebaseDirInsideDotGit: string = parsed.pathToStackedRebaseDirInsideDotGit; const pathToStackedRebaseTodoFile: string = parsed.pathToStackedRebaseTodoFile; + if (fs.existsSync(path.join(pathToStackedRebaseDirInsideDotGit, filenames.willNeedToApply))) { + _markThatNeedsToApply(pathToStackedRebaseDirInsideDotGit); + } + if (options.apply) { return await apply({ repo, @@ -704,7 +708,7 @@ mv -f "${preparedRegularRebaseTodoFile}" "${pathToRegularRebaseTodoFile}" /** * will need to apply, unless proven otherwise */ - markThatNeedsToApply(); + fs.writeFileSync(path.join(pathToStackedRebaseDirInsideDotGit, filenames.willNeedToApply), ""); /** * part 2 of "the different ways to launch git rebase" @@ -780,11 +784,14 @@ mv -f "${preparedRegularRebaseTodoFile}" "${pathToRegularRebaseTodoFile}" }); console.log(""); - if (!rebaseChangedLocalHistory) { - /** - * TODO `unmarkThatNeedsToApply` (NOT the same as `markThatApplied`!) - */ - // unmarkThatNeedsToApply(); + fs.unlinkSync(path.join(pathToStackedRebaseDirInsideDotGit, filenames.willNeedToApply)); + if (rebaseChangedLocalHistory) { + markThatNeedsToApply(); + } else { + // /** + // * TODO `unmarkThatNeedsToApply` (NOT the same as `markThatApplied`!) + // */ + // // unmarkThatNeedsToApply(); } /**