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

Function cloudGetReposForWorkspace

packages/backend/src/bitbucket.ts:213–260  ·  view source on GitHub ↗
(client: BitbucketClient, workspaces: string[])

Source from the content-addressed store, hash-verified

211
212
213async function cloudGetReposForWorkspace(client: BitbucketClient, workspaces: string[]): Promise<{repos: CloudRepository[], warnings: string[]}> {
214 const results = await Promise.allSettled(workspaces.map(async (workspace) => {
215 try {
216 logger.debug(`Fetching all repos for workspace ${workspace}...`);
217
218 const { durationMs, data } = await measure(async () => {
219 const fetchFn = () => getPaginatedCloud<CloudRepository>(`/repositories/${workspace}` as CloudGetRequestPath, async (path, query) => {
220 const { data } = await client.apiClient.GET(path, {
221 params: {
222 path: {
223 workspace,
224 },
225 query: query,
226 }
227 });
228 return data;
229 });
230 return fetchWithRetry(fetchFn, `workspace ${workspace}`, logger);
231 });
232 logger.debug(`Found ${data.length} repos for workspace ${workspace} in ${durationMs}ms.`);
233
234 return {
235 type: 'valid' as const,
236 data: data,
237 };
238 } catch (e: any) {
239 Sentry.captureException(e);
240 logger.error(`Failed to get repos for workspace ${workspace}: ${e}`);
241
242 if (e?.status === 404) {
243 const warning = `Workspace ${workspace} not found or invalid access`;
244 logger.warn(warning);
245 return {
246 type: 'warning' as const,
247 warning
248 }
249 }
250 throw e;
251 }
252 }));
253
254 throwIfAnyFailed(results);
255 const { validItems: repos, warnings } = processPromiseResults(results);
256 return {
257 repos,
258 warnings,
259 };
260}
261
262async function cloudGetReposForProjects(client: BitbucketClient, projects: string[]): Promise<{repos: CloudRepository[], warnings: string[]}> {
263 const results = await Promise.allSettled(projects.map(async (project) => {

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