Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions site/lib/added-dates.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { latestAllowedDate } from "./shared.mjs";

/**
* An entry's `added` date is when it joined the catalog, and it never
* changes afterwards. Moving a file to another category is a rename in git,
Expand Down Expand Up @@ -38,8 +40,11 @@ export function lateAddedDates(entries, firstAdded) {
const errors = [];
for (const { rel, added } of entries) {
const first = firstAdded.get(rel);
if (first && added && String(added) > first) {
errors.push(`${rel} added ${added} is later than the file's first commit (${first}, following renames); set added: ${first}`);
if (first && added) {
const limit = latestAllowedDate(Date.parse(`${first}T00:00:00Z`));
if (String(added) > limit) {
errors.push(`${rel} added ${added} is later than the file's first commit (${first}, following renames); set added: ${first}`);
}
}
}
return errors;
Expand Down
2 changes: 2 additions & 0 deletions site/lib/lib.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1783,6 +1783,8 @@ await section("added dates follow renames (added-dates.mjs)", async () => {
const utc = firstAddedFromLog(["\0" + String(Date.UTC(2026, 10, 7, 2, 30) / 1000), "", "A\tcatalog/2d/late.md"].join("\n"));
eq("added: a timestamp header is read as a UTC day", utc.get("catalog/2d/late.md"), "2026-11-07");
eq("added: a UTC added date on an evening commit passes", lateAddedDates([{ rel: "catalog/2d/late.md", added: "2026-11-07" }], utc).length, 0);
eq("added: one day after first commit's UTC date passes for contributors east of UTC", lateAddedDates([{ rel: "catalog/2d/late.md", added: "2026-11-08" }], utc).length, 0);
eq("added: two days after first commit's UTC date fails", lateAddedDates([{ rel: "catalog/2d/late.md", added: "2026-11-09" }], utc).length, 1);
});

/* engine scope and limits on entry pages (#173) --------------------------- */
Expand Down