(client: BitbucketClient, repoList: string[])
| 524 | } |
| 525 | |
| 526 | async 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 | |
| 573 | async function serverGetAllRepos(client: BitbucketClient): Promise<{repos: ServerRepository[], warnings: string[]}> { |
| 574 | logger.debug(`Fetching all repos from Bitbucket Server...`); |
nothing calls this directly
no test coverage detected