Skip to content

Commit

Permalink
fix: add grey mark - will eventually need to apply if rebase exits
Browse files Browse the repository at this point in the history
Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
  • Loading branch information
kiprasmel committed May 8, 2022
1 parent f78d990 commit e5a9c54
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions filenames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
export const filenames = {
rewrittenList: "rewritten-list",
willNeedToApply: "will-need-to-apply",
needsToApply: "needs-to-apply",
applied: "applied",
//
Expand Down
21 changes: 14 additions & 7 deletions git-stacked-rebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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();
}

/**
Expand Down

0 comments on commit e5a9c54

Please sign in to comment.