Merge remote-tracking branch 'origin/main' into HEAD

# Conflicts:
#	public/asset-manifest.json
#	public/css/all.min.css
#	public/css/style.css
#	public/script/vendor.min.js
#	scripts/dev-mock.js
This commit is contained in:
Thomas Durieux committed 2026-11-29 12:05:37 +00:00
commit 50657b58a8
21 files changed
+1057 -161

No files matched your search

+42 -3
View File
@@ -1028,12 +1028,51 @@ app.get("/api/admin/users/:username", (req, res) => {
});
app.post("/api/admin/users/:username/ban", (req, res) => res.json({ ok: true, reposQueued: 2 }));
app.post("/api/admin/users/:username/:action", ok);
// Stored "Your repositories" list, as the server keeps it in MongoDB: paging
// and search read it, `force=1` simulates a GitHub refresh (about 2.5 s, then
// one new repository), and a simulated App webhook changes it in place:
// curl -XPOST localhost:4002/__mock/repository-webhook -H 'Content-Type: application/json' \
// -d '{"action":"added","fullName":"research/new-paper"}' # also: removed, renamed (+ newName)
// `{"action":"reset"}` restores the fixture list, saved 3 minutes ago.
// `?repos=empty` on the first picker call starts from an empty list (first fetch).
const fixtureRepos = () => Array.from({ length: 63 }, (_, id) => ({ id, fullName: `research/project-${String(id + 1).padStart(2, "0")}`, private: id % 3 === 0 }));
const storedRepos = { rows: fixtureRepos(), syncedAt: new Date(Date.now() - 3 * 60000), syncingUntil: 0, nextId: 1000 };
const finishMockSync = () => {
if (!storedRepos.syncingUntil || Date.now() < storedRepos.syncingUntil) return;
storedRepos.syncingUntil = 0;
storedRepos.syncedAt = new Date();
if (!storedRepos.rows.some(r => r.fullName === "research/camera-ready")) storedRepos.rows.push({ id: storedRepos.nextId++, fullName: "research/camera-ready", private: true });
};
app.get("/api/user/repository_picker", (req, res) => {
finishMockSync();
if (req.query.repos === "empty") { storedRepos.rows = []; storedRepos.syncedAt = null; }
if (req.query.force === "1" || (!storedRepos.rows.length && !storedRepos.syncingUntil)) {
storedRepos.syncingUntil = Date.now() + 2500;
if (!storedRepos.rows.length) storedRepos.rows = fixtureRepos();
}
const cursor = Number(req.query.cursor || 0);
const query = String(req.query.q || "").toLowerCase();
const repos = Array.from({ length: 63 }, (_, id) => ({ id, fullName: id === 2 ? "ASSERT-KTH/ci-hackathon-reproducible-builds-replication-package-2026" : `research/project-${String(id + 1).padStart(2, "0")}` }));
const matches = repos.filter(repo => repo.fullName.toLowerCase().includes(query));
res.json({ items: matches.slice(cursor, cursor + 20), nextCursor: cursor + 20 < matches.length ? cursor + 20 : null });
const matches = storedRepos.rows.filter(repo => repo.fullName.toLowerCase().includes(query))
.sort((a, b) => a.fullName.toLowerCase().localeCompare(b.fullName.toLowerCase()));
res.json({
items: matches.slice(cursor, cursor + 20),
nextCursor: cursor + 20 < matches.length ? cursor + 20 : null,
syncedAt: storedRepos.syncedAt, syncing: !!storedRepos.syncingUntil,
webhooks: req.query.connection !== "oauth",
});
});
app.post("/__mock/repository-webhook", express.json(), (req, res) => {
const { action, fullName, newName } = req.body || {};
if (action === "reset") {
Object.assign(storedRepos, { rows: fixtureRepos(), syncedAt: new Date(Date.now() - 3 * 60000), syncingUntil: 0 });
return res.json({ count: storedRepos.rows.length });
}
if (!/^[^/\s]+\/[^/\s]+$/.test(fullName || "")) return res.status(400).json({ error: "fullName owner/name required" });
const existing = storedRepos.rows.find(r => r.fullName === fullName);
if (action === "added" && !existing) storedRepos.rows.push({ id: storedRepos.nextId++, fullName, private: true });
else if (action === "removed") storedRepos.rows = storedRepos.rows.filter(r => r.fullName !== fullName);
else if (action === "renamed" && existing && /^[^/\s]+\/[^/\s]+$/.test(newName || "")) existing.fullName = newName;
res.json({ count: storedRepos.rows.length });
});
app.get("/api/user/:username/all_repositories", (req, res) => {