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

Function getGerritReposFromConfig

packages/backend/src/gerrit.ts:35–62  ·  view source on GitHub ↗
(config: GerritConnectionConfig)

Source from the content-addressed store, hash-verified

33const logger = createLogger('gerrit');
34
35export const getGerritReposFromConfig = async (config: GerritConnectionConfig): Promise<GerritProject[]> => {
36 const url = config.url.endsWith('/') ? config.url : `${config.url}/`;
37
38 let { durationMs, data: projects } = await measure(async () => {
39 const fetchFn = () => fetchAllProjects(url);
40 return fetchWithRetry(fetchFn, `projects from ${url}`, logger);
41 });
42
43 // include repos by glob if specified in config
44 if (config.projects) {
45 projects = projects.filter((project) => {
46 return micromatch.isMatch(project.name, config.projects!);
47 });
48 }
49
50 projects = projects
51 .filter((project) => {
52 const isExcluded = shouldExcludeProject({
53 project,
54 exclude: config.exclude,
55 });
56
57 return !isExcluded;
58 });
59
60 logger.debug(`Fetched ${projects.length} projects in ${durationMs}ms.`);
61 return projects;
62};
63
64const fetchAllProjects = async (url: string): Promise<GerritProject[]> => {
65 const projectsEndpoint = `${url}projects/`;

Callers 1

compileGerritConfigFunction · 0.85

Calls 3

measureFunction · 0.70
fetchWithRetryFunction · 0.70
shouldExcludeProjectFunction · 0.70

Tested by

no test coverage detected