Skip to content

Commit 0ecff8c

Browse files
committed
fix: add grey mark - will eventually need to apply if rebase exits
Signed-off-by: Kipras Melnikovas <[email protected]>
1 parent 6dd3c25 commit 0ecff8c

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

apply.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const getPaths = (
109109
appliedPath: path.join(pathToStackedRebaseDirInsideDotGit, filenames.applied),
110110
} as const);
111111

112-
const markThatNeedsToApply = (
112+
export const markThatNeedsToApply = (
113113
pathToStackedRebaseDirInsideDotGit: string //
114114
): void =>
115115
[getPaths(pathToStackedRebaseDirInsideDotGit)].map(

filenames.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
export const filenames = {
55
rewrittenList: "rewritten-list",
6+
willNeedToApply: "will-need-to-apply",
67
needsToApply: "needs-to-apply",
78
applied: "applied",
89
//

git-stacked-rebase.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { bullets } from "nice-comment";
1111

1212
import { filenames } from "./filenames";
1313
import { configKeys } from "./configKeys";
14-
import { apply, applyIfNeedsToApply } from "./apply";
14+
import { apply, applyIfNeedsToApply, markThatNeedsToApply as _markThatNeedsToApply } from "./apply";
1515
import { forcePush } from "./forcePush";
1616
import { branchSequencer } from "./branchSequencer";
1717

@@ -284,6 +284,10 @@ export const gitStackedRebase = async (
284284
const pathToStackedRebaseDirInsideDotGit: string = parsed.pathToStackedRebaseDirInsideDotGit;
285285
const pathToStackedRebaseTodoFile: string = parsed.pathToStackedRebaseTodoFile;
286286

287+
if (fs.existsSync(path.join(pathToStackedRebaseDirInsideDotGit, filenames.willNeedToApply))) {
288+
_markThatNeedsToApply(pathToStackedRebaseDirInsideDotGit);
289+
}
290+
287291
if (options.apply) {
288292
return await apply({
289293
repo,
@@ -701,7 +705,7 @@ mv -f "${preparedRegularRebaseTodoFile}" "${pathToRegularRebaseTodoFile}"
701705
/**
702706
* will need to apply, unless proven otherwise
703707
*/
704-
markThatNeedsToApply();
708+
fs.writeFileSync(path.join(pathToStackedRebaseDirInsideDotGit, filenames.willNeedToApply), "");
705709

706710
/**
707711
* part 2 of "the different ways to launch git rebase"
@@ -775,11 +779,14 @@ mv -f "${preparedRegularRebaseTodoFile}" "${pathToRegularRebaseTodoFile}"
775779
});
776780
console.log("");
777781

778-
if (!rebaseChangedLocalHistory) {
779-
/**
780-
* TODO `unmarkThatNeedsToApply` (NOT the same as `markThatApplied`!)
781-
*/
782-
// unmarkThatNeedsToApply();
782+
fs.unlinkSync(path.join(pathToStackedRebaseDirInsideDotGit, filenames.willNeedToApply));
783+
if (rebaseChangedLocalHistory) {
784+
markThatNeedsToApply();
785+
} else {
786+
// /**
787+
// * TODO `unmarkThatNeedsToApply` (NOT the same as `markThatApplied`!)
788+
// */
789+
// // unmarkThatNeedsToApply();
783790
}
784791

785792
/**

0 commit comments

Comments
 (0)