diff --git a/lib/platform/bitbucket-server/index.ts b/lib/platform/bitbucket-server/index.ts index 6aa0e78b1ee7b8b4dd71a3229070838a47063f94..788d48fb9982eabd93f503ff4ef50b947a14ef4a 100644 --- a/lib/platform/bitbucket-server/index.ts +++ b/lib/platform/bitbucket-server/index.ts @@ -180,13 +180,10 @@ export async function initRepo({ url: gitUrl, }); - const repoConfig: RepoConfig = {} as any; - try { const info = (await api.get( `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}` )).body; - repoConfig.isFork = !!info.parent; config.owner = info.project.key; logger.debug(`${repository} owner = ${config.owner}`); config.defaultBranch = (await api.get( @@ -194,6 +191,10 @@ export async function initRepo({ )).body.displayId; config.baseBranch = config.defaultBranch; config.mergeMethod = 'merge'; + const repoConfig: RepoConfig = { + isFork: !!info.parent, + }; + return repoConfig; } catch (err) /* istanbul ignore next */ { logger.debug(err); if (err.statusCode === 404) { @@ -202,11 +203,6 @@ export async function initRepo({ logger.info({ err }, 'Unknown Bitbucket initRepo error'); throw err; } - logger.debug( - { repoConfig }, - `repoConfig for ${config.projectKey}/${config.repositorySlug}` - ); - return repoConfig; } export function getRepoForceRebase() { diff --git a/lib/platform/bitbucket/index.ts b/lib/platform/bitbucket/index.ts index e0e4b09980cf59a04a21ac97eac41a2d0d8feaac..47f5623fd4d70f503bed7ac6fde36c048963b383 100644 --- a/lib/platform/bitbucket/index.ts +++ b/lib/platform/bitbucket/index.ts @@ -67,12 +67,9 @@ export async function initRepo({ repository, username: opts!.username, } as any; - - // TODO: get in touch with @rarkins about lifting up the caching into the app layer - const repoConfig: RepoConfig = {} as any; - + let info; try { - const info = utils.repoInfoTransformer( + info = utils.repoInfoTransformer( (await api.get(`/2.0/repositories/${repository}`)).body ); @@ -94,8 +91,6 @@ export async function initRepo({ } } - repoConfig.isFork = info.isFork; - Object.assign(config, { owner: info.owner, defaultBranch: info.mainbranch, @@ -126,6 +121,9 @@ export async function initRepo({ localDir, url, }); + const repoConfig: RepoConfig = { + isFork: info.isFork, + }; return repoConfig; } diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index 2c634ab00d916305d0c0f9bd37e5fd16cb25234f..87cee09068c7fa9d44602e5f577aa0f065db8803 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -180,8 +180,6 @@ export async function initRepo({ config.repository = repository; [config.repositoryOwner, config.repositoryName] = repository.split('/'); config.gitPrivateKey = gitPrivateKey; - // repoConfig is passed back to the app layer and contains info about the platform they require - const repoConfig: RepoConfig = {} as any; let res; try { res = await api.get(`repos/${repository}`); @@ -237,7 +235,6 @@ export async function initRepo({ throw new Error('disabled'); } } - repoConfig.isFork = res.body.fork === true; const owner = res.body.owner.login; logger.debug(`${repository} owner = ${owner}`); // Use default branch as PR target unless later overridden. @@ -376,7 +373,9 @@ export async function initRepo({ ...config, url, }); - + const repoConfig: RepoConfig = { + isFork: res.body.fork === true, + }; return repoConfig; } diff --git a/lib/platform/gitlab/index.ts b/lib/platform/gitlab/index.ts index 4139d264d52646272504a9489a3cba4467e4cd1c..09a19f35301172eeeadac3659399309a00c91963 100644 --- a/lib/platform/gitlab/index.ts +++ b/lib/platform/gitlab/index.ts @@ -102,7 +102,6 @@ export async function initRepo({ config.repository = urlEscape(repository); config.localDir = localDir; let res; - const repoConfig: RepoConfig = {} as any; try { res = await api.get(`projects/${config.repository}`); if (res.body.archived) { @@ -140,7 +139,6 @@ export async function initRepo({ } config.defaultBranch = res.body.default_branch; config.baseBranch = config.defaultBranch; - repoConfig.isFork = !!res.body.forked_from_project; logger.debug(`${repository} default branch = ${config.baseBranch}`); // Discover our user email config.email = (await api.get(`user`)).body.email; @@ -192,6 +190,9 @@ export async function initRepo({ logger.info({ err }, 'Unknown GitLab initRepo error'); throw err; } + const repoConfig: RepoConfig = { + isFork: !!res.body.forked_from_project, + }; return repoConfig; }