MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / getCodeHostBrowseAtBranchUrl

Function getCodeHostBrowseAtBranchUrl

packages/web/src/lib/utils.ts:379–412  ·  view source on GitHub ↗
({
    webUrl,
    codeHostType,
    branchName: _branchName,
}: {
    webUrl?: string | null,
    codeHostType: CodeHostType,
    branchName: string,
})

Source from the content-addressed store, hash-verified

377}
378
379export const getCodeHostBrowseAtBranchUrl = ({
380 webUrl,
381 codeHostType,
382 branchName: _branchName,
383}: {
384 webUrl?: string | null,
385 codeHostType: CodeHostType,
386 branchName: string,
387}) => {
388 if (!webUrl) {
389 return undefined;
390 }
391
392 const branchName = _branchName.replace(/^refs\/(heads|tags)\//, '');
393
394 switch (codeHostType) {
395 case 'github':
396 return `${webUrl}/tree/${branchName}`;
397 case 'gitlab':
398 return `${webUrl}/-/tree/${branchName}`;
399 case 'gitea':
400 return `${webUrl}/src/branch/${branchName}`;
401 case 'azuredevops':
402 return `${webUrl}?branch=${branchName}`;
403 case 'bitbucketCloud':
404 return `${webUrl}?at=${branchName}`;
405 case 'bitbucketServer':
406 return `${webUrl}?at=${branchName}`;
407 case 'gerrit':
408 return `${webUrl}/+/${branchName}`;
409 case 'genericGitHost':
410 return undefined;
411 }
412}
413
414export const getCodeHostBrowseFileAtBranchUrl = ({
415 webUrl,

Callers 1

RepoBranchesTableFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected