Skip to content

Commit

Permalink
feat: detect bitbucket hosts (#23074)
Browse files Browse the repository at this point in the history
  • Loading branch information
setchy committed Jul 1, 2023
1 parent 6a2564d commit 7089d1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/util/common.spec.ts
Expand Up @@ -15,6 +15,8 @@ describe('util/common', () => {
${'https://gitlab-enterprise.example.com/chalk/chalk'} | ${'gitlab'}
${'https://dev.azure.com/my-organization/my-project/_git/my-repo.git'} | ${'azure'}
${'https://myorg.visualstudio.com/my-project/_git/my-repo.git'} | ${'azure'}
${'https://bitbucket.org/some-org/some-repo'} | ${'bitbucket'}
${'https://bitbucket.com/some-org/some-repo'} | ${'bitbucket'}
`('("$url") === $hostType', ({ url, hostType }) => {
expect(detectPlatform(url)).toBe(hostType);
});
Expand Down
5 changes: 4 additions & 1 deletion lib/util/common.ts
Expand Up @@ -13,7 +13,7 @@ import { parseUrl } from './url';
*/
export function detectPlatform(
url: string
): 'gitlab' | 'github' | 'azure' | null {
): 'gitlab' | 'github' | 'azure' | 'bitbucket' | null {
const { hostname } = parseUrl(url) ?? {};
if (hostname === 'github.com' || hostname?.includes('github')) {
return 'github';
Expand All @@ -24,6 +24,9 @@ export function detectPlatform(
if (hostname === 'dev.azure.com' || hostname?.endsWith('.visualstudio.com')) {
return 'azure';
}
if (hostname === 'bitbucket.org' || hostname?.includes('bitbucket')) {
return 'bitbucket';
}

const hostType = hostRules.hostType({ url });

Expand Down

0 comments on commit 7089d1e

Please sign in to comment.