Fix: Set Gitea Orgs to Public, update if exists

This commit is contained in:
2026-01-06 13:10:37 -08:00
parent 8cd2accad9
commit 3ff2412f37

View File

@@ -14,7 +14,7 @@ const req = async (url, h, m = 'GET', b = null) => {
} }
return res.ok ? (m === 'GET' ? res.json() : res) : null; return res.ok ? (m === 'GET' ? res.json() : res) : null;
} catch (e) { } catch (e) {
if (m !== 'GET') throw e; // Re-throw for non-GET to handle in loop if (m !== 'GET') throw e;
return null; return null;
} }
}; };
@@ -48,8 +48,12 @@ const getPages = async (url) => {
const gOrg = await req(`${G_API}/orgs/${org.login}`, headers.GT); const gOrg = await req(`${G_API}/orgs/${org.login}`, headers.GT);
if (!gOrg) { if (!gOrg) {
console.log(`Creating Org: ${org.login}`); console.log(`Creating Org: ${org.login}`);
await req(`${G_API}/orgs`, headers.GT, 'POST', { username: org.login, visibility: 'private' }); await req(`${G_API}/orgs`, headers.GT, 'POST', { username: org.login, visibility: 'public' });
} else if (gOrg.visibility !== 'public') {
console.log(`Updating Org Visibility: ${org.login}`);
await req(`${G_API}/orgs/${org.login}`, headers.GT, 'PATCH', { visibility: 'public' });
} }
const orgRepos = await getPages(`https://api.github.com/orgs/${org.login}/repos?type=all`); const orgRepos = await getPages(`https://api.github.com/orgs/${org.login}/repos?type=all`);
allRepos.push(...orgRepos); allRepos.push(...orgRepos);
} catch (e) { } catch (e) {