MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / getGiteaReposFromConfig

Function getGiteaReposFromConfig

packages/backend/src/gitea.ts:15–76  ·  view source on GitHub ↗
(config: GiteaConnectionConfig)

Source from the content-addressed store, hash-verified

13const GITEA_CLOUD_HOSTNAME = "gitea.com";
14
15export const getGiteaReposFromConfig = async (config: GiteaConnectionConfig) => {
16 const hostname = config.url ?
17 new URL(config.url).hostname :
18 GITEA_CLOUD_HOSTNAME;
19
20 const token = config.token ?
21 await getTokenFromConfig(config.token) :
22 hostname === GITEA_CLOUD_HOSTNAME ?
23 env.FALLBACK_GITEA_CLOUD_TOKEN :
24 undefined;
25
26 const api = giteaApi(config.url ?? 'https://gitea.com', {
27 token: token,
28 customFetch: fetch,
29 });
30
31 let allRepos: GiteaRepository[] = [];
32 let allWarnings: string[] = [];
33
34 if (config.orgs) {
35 const { repos, warnings } = await getReposForOrgs(config.orgs, api);
36 allRepos = allRepos.concat(repos);
37 allWarnings = allWarnings.concat(warnings);
38 }
39
40 if (config.repos) {
41 const { repos, warnings } = await getRepos(config.repos, api);
42 allRepos = allRepos.concat(repos);
43 allWarnings = allWarnings.concat(warnings);
44 }
45
46 if (config.users) {
47 const { repos, warnings } = await getReposOwnedByUsers(config.users, api);
48 allRepos = allRepos.concat(repos);
49 allWarnings = allWarnings.concat(warnings);
50 }
51
52 allRepos = allRepos.filter(repo => repo.full_name !== undefined);
53 allRepos = allRepos.filter(repo => {
54 if (repo.full_name === undefined) {
55 logger.warn(`Repository with undefined full_name found: repoId=${repo.id}`);
56 return false;
57 }
58 return true;
59 });
60
61 let repos = allRepos
62 .filter((repo) => {
63 const isExcluded = shouldExcludeRepo({
64 repo,
65 exclude: config.exclude,
66 });
67
68 return !isExcluded;
69 });
70
71 logger.debug(`Found ${repos.length} total repositories.`);
72 return {

Callers 1

compileGiteaConfigFunction · 0.85

Calls 5

getTokenFromConfigFunction · 0.90
getReposForOrgsFunction · 0.70
getReposFunction · 0.70
getReposOwnedByUsersFunction · 0.70
shouldExcludeRepoFunction · 0.70

Tested by

no test coverage detected