Skip to content

Commit 054401e

Browse files
committed
fix the "no-longer-there" rewritten-list by reading the .applied file in "parseNewGoodCommands"
Signed-off-by: Kipras Melnikovas <[email protected]>
1 parent dd2cd44 commit 054401e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

parse-todo-of-stacked-rebase/parseNewGoodCommands.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,17 @@ export function parseNewGoodCommands(
2222
logGoodCmds(oldGoodCommands);
2323

2424
const pathOfRewrittenList: string = path.join(repo.path(), "stacked-rebase", filenames.rewrittenList);
25-
const rewrittenList: string = fs.readFileSync(pathOfRewrittenList, { encoding: "utf-8" });
25+
const pathOfRewrittenListApplied: string = path.join(repo.path(), "stacked-rebase", filenames.applied);
26+
let rewrittenList: string;
27+
if (fs.existsSync(pathOfRewrittenList)) {
28+
rewrittenList = fs.readFileSync(pathOfRewrittenList, { encoding: "utf-8" });
29+
} else if (fs.existsSync(pathOfRewrittenListApplied)) {
30+
rewrittenList = fs.readFileSync(pathOfRewrittenListApplied, { encoding: "utf-8" });
31+
} else {
32+
throw new Error(
33+
`rewritten-list not found neither in ${pathOfRewrittenList}, nor in ${pathOfRewrittenListApplied}`
34+
);
35+
}
2636
const { combinedRewrittenList } = combineRewrittenLists(rewrittenList);
2737
const rewrittenListLines: string[] = combinedRewrittenList.split("\n").filter((line) => !!line);
2838

0 commit comments

Comments
 (0)