({
webUrl,
codeHostType,
branchName: _branchName,
filePath,
}: {
webUrl?: string | null,
codeHostType: CodeHostType,
branchName: string,
filePath: string,
})
| 412 | } |
| 413 | |
| 414 | export const getCodeHostBrowseFileAtBranchUrl = ({ |
| 415 | webUrl, |
| 416 | codeHostType, |
| 417 | branchName: _branchName, |
| 418 | filePath, |
| 419 | }: { |
| 420 | webUrl?: string | null, |
| 421 | codeHostType: CodeHostType, |
| 422 | branchName: string, |
| 423 | filePath: string, |
| 424 | }) => { |
| 425 | if (!webUrl) { |
| 426 | return undefined; |
| 427 | } |
| 428 | |
| 429 | const branchName = _branchName.replace(/^refs\/(heads|tags)\//, ''); |
| 430 | |
| 431 | switch (codeHostType) { |
| 432 | case 'github': |
| 433 | return `${webUrl}/blob/${branchName}/${filePath}`; |
| 434 | case 'gitlab': |
| 435 | return `${webUrl}/-/blob/${branchName}/${filePath}`; |
| 436 | case 'gitea': |
| 437 | return `${webUrl}/src/branch/${branchName}/${filePath}`; |
| 438 | case 'azuredevops': |
| 439 | return `${webUrl}?path=${filePath}&version=${branchName}`; |
| 440 | case 'bitbucketCloud': |
| 441 | return `${webUrl}/src/${branchName}/${filePath}`; |
| 442 | case 'bitbucketServer': |
| 443 | return `${webUrl}/browse/${filePath}?at=${branchName}`; |
| 444 | case 'gerrit': |
| 445 | return `${webUrl}/+/${branchName}/${filePath}`; |
| 446 | case 'genericGitHost': |
| 447 | return undefined; |
| 448 | |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | export const isServiceError = (data: unknown): data is ServiceError => { |
| 453 | return typeof data === 'object' && |
no outgoing calls
no test coverage detected