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

Function getFileSource

packages/web/src/features/git/getFileSourceApi.ts:103–116  ·  view source on GitHub ↗
({ path: filePath, repo: repoName, ref }: FileSourceRequest, { source }: { source?: string } = {})

Source from the content-addressed store, hash-verified

101});
102
103export const getFileSource = async ({ path: filePath, repo: repoName, ref }: FileSourceRequest, { source }: { source?: string } = {}): Promise<FileSourceResponse | ServiceError> => sew(() => withOptionalAuth(async ({ org, prisma, user }) => {
104 if (user) {
105 const resolvedSource = source ?? (await headers()).get('X-Sourcebot-Client-Source') ?? undefined;
106 await createAudit({
107 action: 'user.fetched_file_source',
108 actor: { id: user.id, type: 'user' },
109 target: { id: org.id.toString(), type: 'org' },
110 orgId: org.id,
111 metadata: { source: resolvedSource },
112 });
113 }
114
115 return getFileSourceForRepo({ path: filePath, repo: repoName, ref }, { org, prisma });
116}));

Callers 4

readFile.tsFile · 0.90
CodePreviewPanelFunction · 0.90
route.tsFile · 0.90
createAgentStreamFunction · 0.90

Calls 4

sewFunction · 0.90
withOptionalAuthFunction · 0.90
createAuditFunction · 0.90
getFileSourceForRepoFunction · 0.85

Tested by

no test coverage detected