Skip to content

Commit c65a231

Browse files
committed
remove .git/stacked-rebase dir from existance after apply'ing (need to make work for push & others)
Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
1 parent 414e1f5 commit c65a231

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

apply.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ const getPaths = (
171171
rewrittenListPath: path.join(pathToStackedRebaseDirInsideDotGit, filenames.rewrittenList),
172172
needsToApplyPath: path.join(pathToStackedRebaseDirInsideDotGit, filenames.needsToApply),
173173
appliedPath: path.join(pathToStackedRebaseDirInsideDotGit, filenames.applied),
174+
gitRebaseTodoPath: path.join(pathToStackedRebaseDirInsideDotGit, filenames.gitRebaseTodo),
174175
} as const);
175176

176177
export const markThatNeedsToApply = (
@@ -188,7 +189,7 @@ export const markThatNeedsToApply = (
188189

189190
export const markThatApplied = (pathToStackedRebaseDirInsideDotGit: string): void =>
190191
[getPaths(pathToStackedRebaseDirInsideDotGit)].map(
191-
({ rewrittenListPath, needsToApplyPath, appliedPath }) => (
192+
({ rewrittenListPath, needsToApplyPath, gitRebaseTodoPath }) => (
192193
fs.existsSync(needsToApplyPath) && fs.unlinkSync(needsToApplyPath), //
193194
/**
194195
* need to check if the `rewrittenListPath` exists,
@@ -199,13 +200,17 @@ export const markThatApplied = (pathToStackedRebaseDirInsideDotGit: string): voi
199200
* or is there a case where it's useful still?
200201
*
201202
*/
202-
fs.existsSync(rewrittenListPath) && fs.renameSync(rewrittenListPath, appliedPath),
203-
// fs.existsSync(rewrittenListPath)
204-
// ? fs.renameSync(rewrittenListPath, appliedPath)
205-
// : !fs.existsSync(appliedPath) &&
206-
// (() => {
207-
// throw new Error("applying uselessly");
208-
// })(),
203+
// fs.existsSync(rewrittenListPath) && fs.renameSync(rewrittenListPath, appliedPath),
204+
// // fs.existsSync(rewrittenListPath)
205+
// // ? fs.renameSync(rewrittenListPath, appliedPath)
206+
// // : !fs.existsSync(appliedPath) &&
207+
// // (() => {
208+
// // throw new Error("applying uselessly");
209+
// // })(),
210+
fs.existsSync(rewrittenListPath) && fs.unlinkSync(rewrittenListPath),
211+
fs.existsSync(gitRebaseTodoPath) && fs.unlinkSync(gitRebaseTodoPath),
212+
fs.readdirSync(pathToStackedRebaseDirInsideDotGit).length === 0 &&
213+
fs.rmdirSync(pathToStackedRebaseDirInsideDotGit, { recursive: true }),
209214
void 0
210215
)
211216
)[0];

0 commit comments

Comments
 (0)