From 08ecf259d1ee3c71c783f34249ff6f19c85c9b4b Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Tue, 7 Sep 2021 11:58:02 +0200 Subject: [PATCH] fix(host-rules): set type-less host rule for platform (#11615) --- lib/platform/index.spec.ts | 5 +++++ lib/platform/index.ts | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/platform/index.spec.ts b/lib/platform/index.spec.ts index 1a29be4909..790180605a 100644 --- a/lib/platform/index.spec.ts +++ b/lib/platform/index.spec.ts @@ -60,6 +60,11 @@ describe('platform/index', () => { endpoint: 'https://api.bitbucket.org/', gitAuthor: 'user@domain.com', hostRules: [ + { + matchHost: 'api.bitbucket.org', + password: '123', + username: 'abc', + }, { hostType: 'bitbucket', matchHost: 'api.bitbucket.org', diff --git a/lib/platform/index.ts b/lib/platform/index.ts index 8780d11ecc..c99763c527 100644 --- a/lib/platform/index.ts +++ b/lib/platform/index.ts @@ -56,7 +56,6 @@ export async function initPlatform(config: AllConfig): Promise<AllConfig> { // This is done for validation and will be overridden later once repo config is incorporated setGitAuthor(returnConfig.gitAuthor); const platformRule: HostRule = { - hostType: returnConfig.platform, matchHost: URL.parse(returnConfig.endpoint).hostname, }; ['token', 'username', 'password'].forEach((field) => { @@ -68,5 +67,11 @@ export async function initPlatform(config: AllConfig): Promise<AllConfig> { returnConfig.hostRules = returnConfig.hostRules || []; returnConfig.hostRules.push(platformRule); hostRules.add(platformRule); + const typedPlatformRule = { + ...platformRule, + hostType: returnConfig.platform, + }; + returnConfig.hostRules.push(typedPlatformRule); + hostRules.add(typedPlatformRule); return returnConfig; } -- GitLab