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

Function getRepos

packages/backend/src/github.ts:429–477  ·  view source on GitHub ↗
(repoList: string[], octokit: Octokit, signal: AbortSignal, url?: string)

Source from the content-addressed store, hash-verified

427}
428
429const getRepos = async (repoList: string[], octokit: Octokit, signal: AbortSignal, url?: string) => {
430 const results = await Promise.allSettled(repoList.map((repo) => githubQueryLimit(async () => {
431 try {
432 const [owner, repoName] = repo.split('/');
433 logger.debug(`Fetching repository info for ${repo}...`);
434
435 const octokitToUse = await getOctokitWithGithubApp(octokit, owner, url, `repo ${repo}`);
436 const { durationMs, data: result } = await measure(async () => {
437 const fetchFn = () => octokitToUse.repos.get({
438 owner,
439 repo: repoName,
440 request: {
441 signal
442 }
443 });
444
445 return fetchWithRetry(fetchFn, repo, logger);
446 });
447
448 logger.debug(`Found info for repository ${repo} in ${durationMs}ms`);
449 return {
450 type: 'valid' as const,
451 data: [result.data]
452 };
453
454 } catch (error) {
455 Sentry.captureException(error);
456 logger.error(`Failed to fetch repository ${repo}.`, error);
457
458 if (isHttpError(error, 404)) {
459 const warning = `Repository ${repo} not found or no access`;
460 logger.warn(warning);
461 return {
462 type: 'warning' as const,
463 warning
464 };
465 }
466 throw error;
467 }
468 })));
469
470 throwIfAnyFailed(results);
471 const { validItems: repos, warnings } = processPromiseResults<OctokitRepository>(results);
472
473 return {
474 repos,
475 warnings,
476 };
477}
478
479export const shouldExcludeRepo = ({
480 repo,

Callers 1

getGitHubReposFromConfigFunction · 0.70

Calls 6

getOctokitWithGithubAppFunction · 0.85
throwIfAnyFailedFunction · 0.85
processPromiseResultsFunction · 0.85
measureFunction · 0.70
fetchWithRetryFunction · 0.70
isHttpErrorFunction · 0.70

Tested by

no test coverage detected