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

Function getRepoInfoByName

packages/web/src/actions.ts:319–376  ·  view source on GitHub ↗
(repoName: string)

Source from the content-addressed store, hash-verified

317);
318
319export const getRepoInfoByName = async (repoName: string) => sew(() =>
320 withOptionalAuth(async ({ org, prisma }) => {
321 // @note: repo names are represented by their remote url
322 // on the code host. E.g.,:
323 // - github.com/sourcebot-dev/sourcebot
324 // - gitlab.com/gitlab-org/gitlab
325 // - gerrit.wikimedia.org/r/mediawiki/extensions/OnionsPorFavor
326 // etc.
327 //
328 // For most purposes, repo names are unique within an org, so using
329 // findFirst is equivalent to findUnique. Duplicates _can_ occur when
330 // a repository is specified by its remote url in a generic `git`
331 // connection. For example:
332 //
333 // ```json
334 // {
335 // "connections": {
336 // "connection-1": {
337 // "type": "github",
338 // "repos": [
339 // "sourcebot-dev/sourcebot"
340 // ]
341 // },
342 // "connection-2": {
343 // "type": "git",
344 // "url": "file:///tmp/repos/sourcebot"
345 // }
346 // }
347 // }
348 // ```
349 //
350 // In this scenario, both repos will be named "github.com/sourcebot-dev/sourcebot".
351 // We will leave this as an edge case for now since it's unlikely to happen in practice.
352 //
353 // @v4-todo: we could add a unique constraint on repo name + orgId to help de-duplicate
354 // these cases.
355 // @see: repoCompileUtils.ts
356 const repo = await prisma.repo.findFirst({
357 where: {
358 name: repoName,
359 orgId: org.id,
360 },
361 });
362
363 if (!repo) {
364 return notFound();
365 }
366
367 return {
368 id: repo.id,
369 name: repo.name,
370 displayName: repo.displayName ?? undefined,
371 codeHostType: repo.external_codeHostType,
372 externalWebUrl: repo.webUrl ?? undefined,
373 imageUrl: repo.imageUrl ?? undefined,
374 indexedAt: repo.indexedAt ?? undefined,
375 }
376 }));

Callers 12

grep.tsFile · 0.90
listTree.tsFile · 0.90
listCommits.tsFile · 0.90
getDiff.tsFile · 0.90
glob.tsFile · 0.90
readFile.tsFile · 0.90
CodePreviewPanelFunction · 0.90
CommitsPanelFunction · 0.90
TreePreviewPanelFunction · 0.90
FocusedCommitDiffPanelFunction · 0.90

Calls 3

sewFunction · 0.90
withOptionalAuthFunction · 0.90
notFoundFunction · 0.90

Tested by

no test coverage detected