Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

ci: count README contributors from main's commits

LeoXingfe62d7f2e924
diff --git a/.github/workflows/contributors.yml b/.github/workflows/contributors.yml
index 1ad65c11..39eb5442 100644
--- a/.github/workflows/contributors.yml
+++ b/.github/workflows/contributors.yml
@@ -1,9 +1,10 @@
name: Contributors
-# Draws the README's contributor avatars from the GitHub API after every push
-# to main and publishes the image as the only commit on the contributors
-# branch: the default branch accepts changes only through pull requests, and
-# raw.githubusercontent.com serves the branch's file with a five-minute cache.
+# Draws the README's contributor avatars from the authors of main's commits
+# after every push to main and publishes the image as the only commit on the
+# contributors branch: the default branch accepts changes only through pull
+# requests, and raw.githubusercontent.com serves the branch's file with a
+# five-minute cache.
# The avatars are embedded as data URIs because an SVG shown as an image
# cannot load anything else.
on:
@@ -26,6 +27,7 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
+ BRANCH: ${{ github.event.repository.default_branch }}
OUT: ${{ runner.temp }}/contributors/contributors.svg
run: |
mkdir -p "$(dirname "$OUT")"
@@ -35,17 +37,26 @@ jobs:
accept: "application/vnd.github+json",
authorization: `Bearer ${process.env.GH_TOKEN}`,
};
- const people = [];
+ // Count authors over main's commits: the contributors endpoint is
+ // computed in the background and can lag new or rewritten history
+ // by hours.
+ const counts = new Map();
for (let page = 1; ; page += 1) {
const res = await fetch(
- `https://api.github.com/repos/${process.env.REPO}/contributors?per_page=100&page=${page}`,
+ `https://api.github.com/repos/${process.env.REPO}/commits?sha=${process.env.BRANCH}&per_page=100&page=${page}`,
{ headers },
);
- if (!res.ok) throw new Error(`contributors: HTTP ${res.status}`);
+ if (!res.ok) throw new Error(`commits: HTTP ${res.status}`);
const batch = await res.json();
- people.push(...batch.filter((person) => person.type === "User"));
+ for (const { author } of batch) {
+ if (author?.type !== "User") continue;
+ const entry = counts.get(author.login) ?? { ...author, commits: 0 };
+ entry.commits += 1;
+ counts.set(author.login, entry);
+ }
if (batch.length < 100) break;
}
+ const people = [...counts.values()].sort((a, b) => b.commits - a.commits);
const size = 64;
const step = size + 8;
const columns = 12;