From db91079d6e0c29d8e03cbc9bd23d5ede8b7fd0b7 Mon Sep 17 00:00:00 2001 From: Adam Setch <adam.setch@outlook.com> Date: Sat, 1 Jul 2023 08:15:00 -0400 Subject: [PATCH] feat: detect bitbucket host types (#23075) --- lib/util/common.spec.ts | 7 +++++++ lib/util/common.ts | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/lib/util/common.spec.ts b/lib/util/common.spec.ts index a97ffef6ab..b74ba87226 100644 --- a/lib/util/common.spec.ts +++ b/lib/util/common.spec.ts @@ -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(); }); }); diff --git a/lib/util/common.ts b/lib/util/common.ts index 783eba37a4..381f850c46 100644 --- a/lib/util/common.ts +++ b/lib/util/common.ts @@ -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'; } -- GitLab