CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
list-repos.ts
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| 954b19e | 1 | // List repos for a user — diagnoses "Repository not found" on push. |
| 2 | // | |
| 3 | // Run: EMERGENCY_PAT_USER=<username> bun run scripts/list-repos.ts | |
| 4 | // Or just: bun run scripts/list-repos.ts (lists everything) | |
| 5 | // | |
| 6 | // Uses raw SQL to survive any schema drift. | |
| 7 | ||
| 8 | import { neon } from "@neondatabase/serverless"; | |
| 9 | ||
| 10 | async function main() { | |
| 11 | const url = process.env.DATABASE_URL; | |
| 12 | if (!url) { | |
| 13 | console.error("DATABASE_URL is not set."); | |
| 14 | process.exit(1); | |
| 15 | } | |
| 16 | const sql = neon(url); | |
| 17 | const wanted = process.env.EMERGENCY_PAT_USER?.trim(); | |
| 18 | ||
| 19 | const rows = wanted | |
| 20 | ? (await sql` | |
| 21 | SELECT r.name, r.is_private, u.username AS owner | |
| 22 | FROM repositories r JOIN users u ON u.id = r.owner_id | |
| 23 | WHERE LOWER(u.username) = LOWER(${wanted}) | |
| 24 | ORDER BY r.created_at ASC | |
| 25 | `) as Array<{ name: string; is_private: boolean; owner: string }> | |
| 26 | : (await sql` | |
| 27 | SELECT r.name, r.is_private, u.username AS owner | |
| 28 | FROM repositories r JOIN users u ON u.id = r.owner_id | |
| 29 | ORDER BY u.username, r.created_at ASC LIMIT 50 | |
| 30 | `) as Array<{ name: string; is_private: boolean; owner: string }>; | |
| 31 | ||
| 32 | if (rows.length === 0) { | |
| 33 | console.log(wanted ? `No repos for user "${wanted}".` : "No repos in DB."); | |
| 34 | return; | |
| 35 | } | |
| 36 | ||
| 37 | console.log(""); | |
| 38 | console.log("Repos found:"); | |
| 39 | console.log(""); | |
| 40 | for (const r of rows) { | |
| 41 | console.log( | |
| 42 | ` ${r.owner}/${r.name} private=${r.is_private} push-url=https://gluecron.com/${r.owner}/${r.name}.git` | |
| 43 | ); | |
| 44 | } | |
| 45 | console.log(""); | |
| 46 | } | |
| 47 | ||
| 48 | main().catch((err) => { | |
| 49 | console.error("Failed:", err); | |
| 50 | process.exit(1); | |
| 51 | }); |