MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / serverGetReposForProjects

Function serverGetReposForProjects

packages/backend/src/bitbucket.ts:476–524  ·  view source on GitHub ↗
(client: BitbucketClient, projects: string[])

Source from the content-addressed store, hash-verified

474}
475
476async function serverGetReposForProjects(client: BitbucketClient, projects: string[]): Promise<{repos: ServerRepository[], warnings: string[]}> {
477 const results = await Promise.allSettled(projects.map(async (project) => {
478 try {
479 logger.debug(`Fetching all repos for project ${project}...`);
480
481 const path = `/rest/api/1.0/projects/${project}/repos` as ServerGetRequestPath;
482 const { durationMs, data } = await measure(async () => {
483 const fetchFn = () => getPaginatedServer<ServerRepository>(path, async (url, start) => {
484 const { data } = await client.apiClient.GET(url, {
485 params: {
486 query: {
487 limit: 1000,
488 start,
489 }
490 }
491 });
492 return data;
493 });
494 return fetchWithRetry(fetchFn, `project ${project}`, logger);
495 });
496 logger.debug(`Found ${data.length} repos for project ${project} in ${durationMs}ms.`);
497
498 return {
499 type: 'valid' as const,
500 data: data,
501 };
502 } catch (e: any) {
503 Sentry.captureException(e);
504 logger.error(`Failed to get repos for project ${project}: ${e}`);
505
506 if (e?.status === 404) {
507 const warning = `Project ${project} not found or invalid access`;
508 logger.warn(warning);
509 return {
510 type: 'warning' as const,
511 warning
512 };
513 }
514 throw e;
515 }
516 }));
517
518 throwIfAnyFailed(results);
519 const { validItems: repos, warnings } = processPromiseResults(results);
520 return {
521 repos,
522 warnings
523 };
524}
525
526async function serverGetRepos(client: BitbucketClient, repoList: string[]): Promise<{repos: ServerRepository[], warnings: string[]}> {
527 const results = await Promise.allSettled(repoList.map(async (repo) => {

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected