feat: detect bitbucket host types (#23075)

This commit is contained in:
Adam Setch 2023-07-01 08:15:00 -04:00 committed by GitHub
parent 7089d1ef2a
commit db91079d6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View file

@ -34,12 +34,19 @@ describe('util/common', () => {
hostType: 'gitea',
matchHost: 'gt.example.com',
});
hostRules.add({
hostType: 'bitbucket',
matchHost: 'bb.example.com',
});
expect(detectPlatform('https://gl.example.com/chalk/chalk')).toBe(
'gitlab'
);
expect(detectPlatform('https://gh.example.com/chalk/chalk')).toBe(
'github'
);
expect(detectPlatform('https://bb.example.com/chalk/chalk')).toBe(
'bitbucket'
);
expect(detectPlatform('https://gt.example.com/chalk/chalk')).toBeNull();
});
});

View file

@ -1,4 +1,5 @@
import {
BITBUCKET_API_USING_HOST_TYPES,
GITHUB_API_USING_HOST_TYPES,
GITLAB_API_USING_HOST_TYPES,
} from '../constants';
@ -34,6 +35,9 @@ export function detectPlatform(
return null;
}
if (BITBUCKET_API_USING_HOST_TYPES.includes(hostType)) {
return 'bitbucket';
}
if (GITLAB_API_USING_HOST_TYPES.includes(hostType)) {
return 'gitlab';
}