- const diff = new Deno.Command("git", {
- args: [
- "diff",
- "-z",
- "--name-only",
- "--no-renames",
- "--diff-filter=AM",
- commit,
- ],
- stdout: "piped",
- stderr: "piped",
- }).spawn();
- const [diffNames] = await Promise.allSettled([
- new Response(diff.stdout).text(),
- new Response(diff.stderr).text(),
- ]).then(logErrorsAndCollectResults);
- return [...references(diffNames.split("\0"))];
+ const results = new Array(6);
+ const seen = new Set();
+ let recency = 5;
+ let current;
+ do {
+ const show = new Deno.Command("git", {
+ args: [
+ "show",
+ "-s",
+ "--format=%H%x00%cI%x00%cD",
+ recency ? `HEAD~${5 - recency}` : commit,
+ ],
+ stdout: "piped",
+ stderr: "piped",
+ }).spawn();
+ const [
+ [hash, dateTime, humanReadable],
+ ] = await Promise.allSettled([
+ new Response(show.stdout).text().then((rev) =>
+ rev.trim().split("\0")
+ ),
+ new Response(show.stderr).text(),
+ ]).then(logErrorsAndCollectResults);
+ const refs = [];
+ current = hash;
+ for (const ref of (await diffReferences(current))) {
+ if (seen.has(ref)) {
+ /* do nothing */
+ } else {
+ refs.push(ref);
+ seen.add(ref);
+ }
+ }
+ results[recency] = { dateTime, humanReadable, refs };
+ } while (recency-- > 0 && current && current != commit);
+ return results;