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

Function getWebUrl

packages/backend/src/repoCompileUtils.ts:457–479  ·  view source on GitHub ↗
(repo: BitbucketRepository)

Source from the content-addressed store, hash-verified

455 }
456
457 const getWebUrl = (repo: BitbucketRepository) => {
458 const isServer = config.deploymentType === 'server';
459 const repoLinks = (repo as BitbucketServerRepository | BitbucketCloudRepository).links;
460 const repoName = isServer ? (repo as BitbucketServerRepository).name : (repo as BitbucketCloudRepository).full_name;
461
462 if (!repoLinks) {
463 throw new Error(`No links found for ${isServer ? 'server' : 'cloud'} repo ${repoName}`);
464 }
465
466 // In server case we get an array of length == 1 links in the self field, while in cloud case we get a single
467 // link object in the html field
468 const link = isServer ? (repoLinks.self as { name: string, href: string }[])?.[0] : repoLinks.html as { href: string };
469 if (!link || !link.href) {
470 throw new Error(`No ${isServer ? 'self' : 'html'} link found for ${isServer ? 'server' : 'cloud'} repo ${repoName}`);
471 }
472
473 // @note: Bitbucket Server's self link includes `/browse` at the end.
474 // Strip it so that we can simply append either `/browse`, `/commits`, etc. to
475 // the base URL.
476 const href = isServer ? link.href.replace(/\/browse\/?$/, '') : link.href;
477
478 return href;
479 }
480
481 const repos = bitbucketRepos.map((repo) => {
482 const isServer = config.deploymentType === 'server';

Callers 1

compileBitbucketConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected