From 4319a9b8a96204d504ed5a3c6d66757679f44ea8 Mon Sep 17 00:00:00 2001 From: Tobias Gabriel Date: Wed, 7 Aug 2024 14:11:47 +0200 Subject: [PATCH 1/2] feat(platform): export PLATFORM_HOST_TYPES constant as value --- lib/constants/platforms.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/constants/platforms.ts b/lib/constants/platforms.ts index 9b5a34c4654355..d9f97058f9dab6 100644 --- a/lib/constants/platforms.ts +++ b/lib/constants/platforms.ts @@ -1,13 +1,17 @@ -export type PlatformId = - | 'azure' - | 'codecommit' - | 'bitbucket' - | 'bitbucket-server' - | 'gerrit' - | 'gitea' - | 'github' - | 'gitlab' - | 'local'; +export const PLATFORM_HOST_TYPES = [ + // All known git platforms + 'azure', + 'bitbucket', + 'bitbucket-server', + 'codecommit', + 'gerrit', + 'gitea', + 'github', + 'gitlab', + 'local', +] as const; + +export type PlatformId = (typeof PLATFORM_HOST_TYPES)[number]; export const GITEA_API_USING_HOST_TYPES = [ 'gitea', From fad09dbc5fb98a2ec5b2b22227a3f2134036d54a Mon Sep 17 00:00:00 2001 From: Tobias Gabriel Date: Wed, 7 Aug 2024 14:16:35 +0200 Subject: [PATCH 2/2] chore(git): use all PLATFORM_HOST_TYPES as supported git hosts --- lib/util/git/auth.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/lib/util/git/auth.ts b/lib/util/git/auth.ts index 9bbffcbc4c8126..ad2726797ba201 100644 --- a/lib/util/git/auth.ts +++ b/lib/util/git/auth.ts @@ -1,4 +1,4 @@ -import type { PlatformId } from '../../constants/platforms'; +import { PLATFORM_HOST_TYPES } from '../../constants/platforms'; import { logger } from '../../logger'; import type { HostRule } from '../../types'; import { detectPlatform } from '../common'; @@ -15,16 +15,6 @@ const githubApiUrls = new Set([ 'https://api.github.com/', ]); -const standardGitAllowedHostTypes = [ - // All known git platforms - 'azure', - 'bitbucket', - 'bitbucket-server', - 'gitea', - 'github', - 'gitlab', -] satisfies PlatformId[]; - /** * Add authorization to a Git Url and returns a new environment variables object * @returns a new NodeJS.ProcessEnv object without modifying any input parameters @@ -194,7 +184,7 @@ export function getGitEnvironmentVariables( // construct the Set of allowed hostTypes consisting of the standard Git provides // plus additionalHostTypes, which are provided as parameter const gitAllowedHostTypes = new Set([ - ...standardGitAllowedHostTypes, + ...PLATFORM_HOST_TYPES, ...additionalHostTypes, ]);