Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.

Show differences from the required form #224

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/pr-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,12 @@ function makeJsonCheckerFromCore(requiredForm: any, ignoredKeys: string[]) {
const newDiff = diffFromReq(contents);
if (typeof newDiff === "string") return newDiff;
if (newDiff.length === 0) return undefined;
if (!oldText) return "not the required form";
if (!oldText) return `not the required form \`${JSON.stringify(newDiff)}\``;
const oldDiff = diffFromReq(oldText);
if (typeof oldDiff === "string") return oldDiff;
if (jsonDiff.compare(oldDiff, newDiff).every(({ op }) => op === "remove")) return undefined;
return "not the required form and not moving towards it";
const notRemove = jsonDiff.compare(oldDiff, newDiff).filter(({ op }) => op !== "remove");
if (notRemove.length === 0) return undefined;
return `not the required form and not moving towards it \`${JSON.stringify(notRemove.map(({ path }) => newDiff[Number(path.slice(1))]))}\``;
};
}

Expand Down