fix: reuse unchanged project files by source hash
This commit is contained in:
@@ -116,6 +116,7 @@ export async function reviseProjectRun(args: {
|
||||
run.commentAuthorCoverage = previous.commentAuthorCoverage;
|
||||
run.reviewAuthorCoverage = previous.reviewAuthorCoverage;
|
||||
run.mapping = plan.mapping;
|
||||
run.sourceState = {};
|
||||
run.matchModes = Object.fromEntries(Object.entries(previous.matchModes ?? {})
|
||||
.filter(([key]) => key in plan.mapping));
|
||||
run.sourceInPlace = inPlace;
|
||||
@@ -153,6 +154,15 @@ export async function reviseProjectRun(args: {
|
||||
isMarkdownFile(file.output)), "utf8");
|
||||
await fs.writeFile(target, output, { flag: "wx", mode: 0o600 });
|
||||
run.files.push({ source: file.output, output: outputPath, kind: file.kind });
|
||||
if (inPlace) run.sourceState[outputPath] = { hash: digest(output), output: outputPath };
|
||||
}
|
||||
if (!inPlace && previous.sourceState) {
|
||||
const revisedOutput = new Map(run.files.map((file) => [file.source, file.output]));
|
||||
run.sourceState = Object.fromEntries(Object.entries(previous.sourceState)
|
||||
.filter(([, state]) => revisedOutput.has(state.output))
|
||||
.map(([path, state]) => [path, {
|
||||
hash: state.hash, output: revisedOutput.get(state.output)!,
|
||||
}]));
|
||||
}
|
||||
if (plan.whitelist.length) {
|
||||
await saveProjectWhitelist(previous.projectPath, [...previousWhitelist, ...plan.whitelist], support);
|
||||
|
||||
Reference in New Issue
Block a user