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

Function serverGetRepos

packages/backend/src/bitbucket.ts:526–571  ·  view source on GitHub ↗
(client: BitbucketClient, repoList: string[])

Source from the content-addressed store, hash-verified

524}
525
526async function serverGetRepos(client: BitbucketClient, repoList: string[]): Promise<{repos: ServerRepository[], warnings: string[]}> {
527 const results = await Promise.allSettled(repoList.map(async (repo) => {
528 const [project, repo_slug] = repo.split('/');
529 if (!project || !repo_slug) {
530 const warning = `Invalid repo ${repo}`;
531 logger.warn(warning);
532 return {
533 type: 'warning' as const,
534 warning
535 };
536 }
537
538 logger.debug(`Fetching repo ${repo_slug} for project ${project}...`);
539 try {
540 const path = `/rest/api/1.0/projects/${project}/repos/${repo_slug}` as ServerGetRequestPath;
541 const data = await fetchWithRetry(async () => {
542 const { data } = await client.apiClient.GET(path);
543 return data;
544 }, `repo ${repo}`, logger);
545 return {
546 type: 'valid' as const,
547 data: [data]
548 };
549 } catch (e: any) {
550 Sentry.captureException(e);
551 logger.error(`Failed to fetch repo ${repo}: ${e}`);
552
553 if (e?.status === 404) {
554 const warning = `Repo ${repo} not found in project ${project} or invalid access`;
555 logger.warn(warning);
556 return {
557 type: 'warning' as const,
558 warning
559 };
560 }
561 throw e;
562 }
563 }));
564
565 throwIfAnyFailed(results);
566 const { validItems: repos, warnings } = processPromiseResults(results);
567 return {
568 repos,
569 warnings
570 };
571}
572
573async function serverGetAllRepos(client: BitbucketClient): Promise<{repos: ServerRepository[], warnings: string[]}> {
574 logger.debug(`Fetching all repos from Bitbucket Server...`);

Callers

nothing calls this directly

Calls 3

throwIfAnyFailedFunction · 0.85
processPromiseResultsFunction · 0.85
fetchWithRetryFunction · 0.70

Tested by

no test coverage detected