Skip to content
Snippets Groups Projects
Unverified Commit e5e1a181 authored by Rhys Arkins's avatar Rhys Arkins Committed by GitHub
Browse files

refactor(bitbucket): don’t use endpoint in initRepo (#6457)

parent 4d7c109a
No related branches found
No related tags found
No related merge requests found
...@@ -41,6 +41,8 @@ const BITBUCKET_PROD_ENDPOINT = 'https://api.bitbucket.org/'; ...@@ -41,6 +41,8 @@ const BITBUCKET_PROD_ENDPOINT = 'https://api.bitbucket.org/';
let config: utils.Config = {} as any; let config: utils.Config = {} as any;
let endpoint_ = BITBUCKET_PROD_ENDPOINT;
export function initPlatform({ export function initPlatform({
endpoint, endpoint,
username, username,
...@@ -55,7 +57,9 @@ export function initPlatform({ ...@@ -55,7 +57,9 @@ export function initPlatform({
logger.warn( logger.warn(
`Init: Bitbucket Cloud endpoint should generally be ${BITBUCKET_PROD_ENDPOINT} but is being configured to a different value. Did you mean to use Bitbucket Server?` `Init: Bitbucket Cloud endpoint should generally be ${BITBUCKET_PROD_ENDPOINT} but is being configured to a different value. Did you mean to use Bitbucket Server?`
); );
endpoint_ = endpoint;
} }
setBaseUrl(endpoint_);
// TODO: Add a connection check that endpoint/username/password combination are valid // TODO: Add a connection check that endpoint/username/password combination are valid
const platformConfig: PlatformConfig = { const platformConfig: PlatformConfig = {
endpoint: endpoint || BITBUCKET_PROD_ENDPOINT, endpoint: endpoint || BITBUCKET_PROD_ENDPOINT,
...@@ -83,14 +87,12 @@ export async function initRepo({ ...@@ -83,14 +87,12 @@ export async function initRepo({
localDir, localDir,
optimizeForDisabled, optimizeForDisabled,
bbUseDefaultReviewers, bbUseDefaultReviewers,
endpoint = BITBUCKET_PROD_ENDPOINT,
}: RepoParams): Promise<RepoConfig> { }: RepoParams): Promise<RepoConfig> {
logger.debug(`initRepo("${repository}")`); logger.debug(`initRepo("${repository}")`);
const opts = hostRules.find({ const opts = hostRules.find({
hostType: PLATFORM_TYPE_BITBUCKET, hostType: PLATFORM_TYPE_BITBUCKET,
url: endpoint, url: endpoint_,
}); });
setBaseUrl(endpoint);
config = { config = {
repository, repository,
username: opts.username, username: opts.username,
...@@ -139,7 +141,7 @@ export async function initRepo({ ...@@ -139,7 +141,7 @@ export async function initRepo({
throw err; throw err;
} }
const { hostname } = URL.parse(endpoint); const { hostname } = URL.parse(endpoint_);
// Converts API hostnames to their respective HTTP git hosts: // Converts API hostnames to their respective HTTP git hosts:
// `api.bitbucket.org` to `bitbucket.org` // `api.bitbucket.org` to `bitbucket.org`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment