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

Function compileGiteaConfig

packages/backend/src/repoCompileUtils.ts:248–316  ·  view source on GitHub ↗
(
    config: GiteaConnectionConfig,
    connectionId: number)

Source from the content-addressed store, hash-verified

246}
247
248export const compileGiteaConfig = async (
249 config: GiteaConnectionConfig,
250 connectionId: number): Promise<CompileResult> => {
251
252 const giteaReposResult = await getGiteaReposFromConfig(config);
253 const giteaRepos = giteaReposResult.repos;
254 const warnings = giteaReposResult.warnings;
255
256 const hostUrl = (config.url ?? 'https://gitea.com').replace(/\/+$/, '');
257 const repoNameRoot = new URL(hostUrl)
258 .toString()
259 .replace(/^https?:\/\//, '');
260
261 const repos = giteaRepos.map((repo) => {
262 const configUrl = new URL(hostUrl);
263 const cloneUrl = new URL(repo.clone_url!);
264 cloneUrl.host = configUrl.host
265 const repoDisplayName = repo.full_name!;
266 const repoName = path.join(repoNameRoot, repoDisplayName);
267 const isPublic = repo.internal === false && repo.private === false;
268
269 logger.debug(`Found gitea repo ${repoDisplayName} with webUrl: ${repo.html_url}`);
270
271 const record: RepoData = {
272 external_id: repo.id!.toString(),
273 external_codeHostType: 'gitea',
274 external_codeHostUrl: hostUrl,
275 cloneUrl: cloneUrl.toString(),
276 webUrl: repo.html_url,
277 name: repoName,
278 displayName: repoDisplayName,
279 defaultBranch: repo.default_branch,
280 imageUrl: repo.owner?.avatar_url,
281 isFork: repo.fork!,
282 isPublic: isPublic,
283 isArchived: !!repo.archived,
284 org: {
285 connect: {
286 id: SINGLE_TENANT_ORG_ID,
287 },
288 },
289 connections: {
290 create: {
291 connectionId: connectionId,
292 }
293 },
294 metadata: {
295 gitConfig: {
296 'zoekt.web-url-type': 'gitea',
297 'zoekt.web-url': repo.html_url!,
298 'zoekt.name': repoName,
299 'zoekt.archived': marshalBool(repo.archived),
300 'zoekt.fork': marshalBool(repo.fork!),
301 'zoekt.public': marshalBool(isPublic),
302 'zoekt.display-name': repoDisplayName,
303 },
304 branches: config.revisions?.branches ?? undefined,
305 tags: config.revisions?.tags ?? undefined,

Callers 1

runJobMethod · 0.85

Calls 2

getGiteaReposFromConfigFunction · 0.85
marshalBoolFunction · 0.85

Tested by

no test coverage detected