Skip to content

Commit 132dca6

Browse files
committed
fix: only move rewrittenList to applied if it exists
Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
1 parent ebaef62 commit 132dca6

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

apply.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,22 @@ export const markThatApplied = (pathToStackedRebaseDirInsideDotGit: string): voi
190190
[getPaths(pathToStackedRebaseDirInsideDotGit)].map(
191191
({ rewrittenListPath, needsToApplyPath, appliedPath }) => (
192192
fs.existsSync(needsToApplyPath) && fs.unlinkSync(needsToApplyPath), //
193-
fs.renameSync(rewrittenListPath, appliedPath),
193+
/**
194+
* need to check if the `rewrittenListPath` exists,
195+
* because even if it does not, then the "apply" can still go through
196+
* and "apply", by using the already .applied file, i.e. do nothing.
197+
*
198+
* TODO just do not run "apply" if the file doesn't exist?
199+
* or is there a case where it's useful still?
200+
*
201+
*/
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+
// })(),
194209
void 0
195210
)
196211
)[0];

0 commit comments

Comments
 (0)