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

Function getReposForProjects

packages/backend/src/azuredevops.ts:231–283  ·  view source on GitHub ↗
(
    projects: string[],
    baseUrl: string,
    token: string,
    useTfsPath: boolean
)

Source from the content-addressed store, hash-verified

229}
230
231async function getReposForProjects(
232 projects: string[],
233 baseUrl: string,
234 token: string,
235 useTfsPath: boolean
236) {
237 const results = await Promise.allSettled(projects.map(async (project) => {
238 try {
239 const [org, projectName] = project.split('/');
240 logger.debug(`Fetching repositories for project ${project}...`);
241
242 const { durationMs, data } = await measure(async () => {
243 const fetchFn = async () => {
244 const orgUrl = buildOrgUrl(baseUrl, org, useTfsPath);
245 const connection = createAzureDevOpsConnection(orgUrl, token);
246 const gitApi = await connection.getGitApi();
247
248 const repos = await gitApi.getRepositories(projectName);
249 return repos;
250 };
251
252 return fetchWithRetry(fetchFn, `project ${project}`, logger);
253 });
254
255 logger.debug(`Found ${data.length} repositories in project ${project} in ${durationMs}ms.`);
256 return {
257 type: 'valid' as const,
258 data
259 };
260 } catch (error) {
261 Sentry.captureException(error);
262 logger.error(`Failed to fetch repositories for project ${project}.`, error);
263
264 if (error && typeof error === 'object' && 'statusCode' in error && error.statusCode === 404) {
265 const warning = `Project ${project} not found or no access`;
266 logger.warn(warning);
267 return {
268 type: 'warning' as const,
269 warning
270 };
271 }
272 throw error;
273 }
274 }));
275
276 throwIfAnyFailed(results);
277 const { validItems: repos, warnings } = processPromiseResults<GitRepository>(results);
278
279 return {
280 repos,
281 warnings,
282 };
283}
284
285async function getRepos(
286 repoList: string[],

Callers 1

Calls 4

throwIfAnyFailedFunction · 0.85
processPromiseResultsFunction · 0.85
measureFunction · 0.70
fetchWithRetryFunction · 0.70

Tested by

no test coverage detected