From 1864d4ebf38cf9750b3ad2c624ba7048b97bb4c9 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Wed, 14 Aug 2019 11:38:13 +0200 Subject: [PATCH] refactor(platform): return baseBranch from initRepo --- lib/platform/azure/index.ts | 1 + lib/platform/bitbucket-server/index.ts | 1 + lib/platform/bitbucket/index.ts | 1 + lib/platform/common.ts | 1 + lib/platform/github/index.ts | 1 + lib/platform/gitlab/index.ts | 1 + test/platform/azure/__snapshots__/index.spec.ts.snap | 1 + .../bitbucket-server/__snapshots__/index.spec.ts.snap | 4 ++++ test/platform/bitbucket/__snapshots__/index.spec.ts.snap | 1 + test/platform/github/__snapshots__/index.spec.ts.snap | 6 ++++++ 10 files changed, 18 insertions(+) diff --git a/lib/platform/azure/index.ts b/lib/platform/azure/index.ts index 3c34c13911..9b75df0ff0 100644 --- a/lib/platform/azure/index.ts +++ b/lib/platform/azure/index.ts @@ -122,6 +122,7 @@ export async function initRepo({ url, }); const repoConfig: RepoConfig = { + baseBranch: config.baseBranch, isFork: false, }; return repoConfig; diff --git a/lib/platform/bitbucket-server/index.ts b/lib/platform/bitbucket-server/index.ts index 788d48fb99..c0ae8761a4 100644 --- a/lib/platform/bitbucket-server/index.ts +++ b/lib/platform/bitbucket-server/index.ts @@ -192,6 +192,7 @@ export async function initRepo({ config.baseBranch = config.defaultBranch; config.mergeMethod = 'merge'; const repoConfig: RepoConfig = { + baseBranch: config.baseBranch, isFork: !!info.parent, }; return repoConfig; diff --git a/lib/platform/bitbucket/index.ts b/lib/platform/bitbucket/index.ts index 47f5623fd4..bbbe9d1838 100644 --- a/lib/platform/bitbucket/index.ts +++ b/lib/platform/bitbucket/index.ts @@ -122,6 +122,7 @@ export async function initRepo({ url, }); const repoConfig: RepoConfig = { + baseBranch: config.baseBranch, isFork: info.isFork, }; return repoConfig; diff --git a/lib/platform/common.ts b/lib/platform/common.ts index 57e8c5f3de..43e0ef5f6d 100644 --- a/lib/platform/common.ts +++ b/lib/platform/common.ts @@ -46,6 +46,7 @@ export interface PlatformConfig { } export interface RepoConfig { + baseBranch: string; endpoint?: string; renovateUsername?: any; gitAuthor?: any; diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index 87cee09068..ca3c058c02 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -374,6 +374,7 @@ export async function initRepo({ url, }); const repoConfig: RepoConfig = { + baseBranch: config.baseBranch, isFork: res.body.fork === true, }; return repoConfig; diff --git a/lib/platform/gitlab/index.ts b/lib/platform/gitlab/index.ts index 09a19f3530..87b79926bd 100644 --- a/lib/platform/gitlab/index.ts +++ b/lib/platform/gitlab/index.ts @@ -191,6 +191,7 @@ export async function initRepo({ throw err; } const repoConfig: RepoConfig = { + baseBranch: config.baseBranch, isFork: !!res.body.forked_from_project, }; return repoConfig; diff --git a/test/platform/azure/__snapshots__/index.spec.ts.snap b/test/platform/azure/__snapshots__/index.spec.ts.snap index 5dbe39b57a..3b810b7a1a 100644 --- a/test/platform/azure/__snapshots__/index.spec.ts.snap +++ b/test/platform/azure/__snapshots__/index.spec.ts.snap @@ -135,6 +135,7 @@ Array [ exports[`platform/azure initRepo should initialise the config for a repo 2`] = ` Object { + "baseBranch": "defBr", "isFork": false, } `; diff --git a/test/platform/bitbucket-server/__snapshots__/index.spec.ts.snap b/test/platform/bitbucket-server/__snapshots__/index.spec.ts.snap index 74bd003433..c1cef2e052 100644 --- a/test/platform/bitbucket-server/__snapshots__/index.spec.ts.snap +++ b/test/platform/bitbucket-server/__snapshots__/index.spec.ts.snap @@ -998,12 +998,14 @@ Object { exports[`platform/bitbucket-server endpoint with no path initRepo() does not throw 1`] = ` Object { + "baseBranch": "master", "isFork": false, } `; exports[`platform/bitbucket-server endpoint with no path initRepo() works 1`] = ` Object { + "baseBranch": "master", "isFork": false, } `; @@ -2470,12 +2472,14 @@ Object { exports[`platform/bitbucket-server endpoint with path initRepo() does not throw 1`] = ` Object { + "baseBranch": "master", "isFork": false, } `; exports[`platform/bitbucket-server endpoint with path initRepo() works 1`] = ` Object { + "baseBranch": "master", "isFork": false, } `; diff --git a/test/platform/bitbucket/__snapshots__/index.spec.ts.snap b/test/platform/bitbucket/__snapshots__/index.spec.ts.snap index 35862c35c2..9adeaf50ad 100644 --- a/test/platform/bitbucket/__snapshots__/index.spec.ts.snap +++ b/test/platform/bitbucket/__snapshots__/index.spec.ts.snap @@ -275,6 +275,7 @@ Object { exports[`platform/bitbucket initRepo() works 1`] = ` Object { + "baseBranch": "master", "isFork": false, } `; diff --git a/test/platform/github/__snapshots__/index.spec.ts.snap b/test/platform/github/__snapshots__/index.spec.ts.snap index bf4e9e4ae0..6446d9ae65 100644 --- a/test/platform/github/__snapshots__/index.spec.ts.snap +++ b/test/platform/github/__snapshots__/index.spec.ts.snap @@ -414,36 +414,42 @@ Object { exports[`platform/github initRepo should forks when forkMode 1`] = ` Object { + "baseBranch": "master", "isFork": false, } `; exports[`platform/github initRepo should merge 1`] = ` Object { + "baseBranch": "master", "isFork": false, } `; exports[`platform/github initRepo should not guess at merge 1`] = ` Object { + "baseBranch": "master", "isFork": false, } `; exports[`platform/github initRepo should rebase 1`] = ` Object { + "baseBranch": "master", "isFork": false, } `; exports[`platform/github initRepo should squash 1`] = ` Object { + "baseBranch": "master", "isFork": false, } `; exports[`platform/github initRepo should update fork when forkMode 1`] = ` Object { + "baseBranch": "master", "isFork": false, } `; -- GitLab