diff --git a/lib/api/github.js b/lib/api/github.js index bceb83cf0e80f1b01da385b571d7ef7072f51d93..f47cfb6861365a2a19d4c4930a0f43efbc59f9dc 100644 --- a/lib/api/github.js +++ b/lib/api/github.js @@ -141,6 +141,7 @@ async function initRepo(repoName, token, endpoint, repoLogger) { process.env.GITHUB_ENDPOINT = endpoint; } config.repoName = repoName; + const platformConfig = {}; try { const res = await ghGot(`repos/${repoName}`); config.privateRepo = res.body.private === true; @@ -160,12 +161,12 @@ async function initRepo(repoName, token, endpoint, repoLogger) { } else { logger.debug('Could not find allowed merge methods for repo'); } - config.repoForceRebase = false; + platformConfig.repoForceRebase = false; try { const branchProtection = await getBranchProtection(config.baseBranch); if (branchProtection.strict) { logger.debug('Repo has branch protection and needs PRs up-to-date'); - config.repoForceRebase = true; + platformConfig.repoForceRebase = true; } else { logger.debug( 'Repo has branch protection but does not require up-to-date' @@ -188,7 +189,7 @@ async function initRepo(repoName, token, endpoint, repoLogger) { logger.error({ err }, 'Unknown GitHub initRepo error'); throw err; } - return config; + return platformConfig; } async function getBranchProtection(branchName) { diff --git a/lib/api/gitlab.js b/lib/api/gitlab.js index 62f5d70d6b8a9fc260d463e2e9741cef12b59d3a..568755a7f6ecd0dde2b5ab54016cc113f168e7ab 100644 --- a/lib/api/gitlab.js +++ b/lib/api/gitlab.js @@ -108,7 +108,7 @@ async function initRepo(repoName, token, endpoint, repoLogger) { logger.error({ err }, `GitLab init error`); throw err; } - return config; + return {}; } async function setBaseBranch(branchName) { diff --git a/lib/workers/repository/apis.js b/lib/workers/repository/apis.js index 484387fba034099766b31b577eb49baa1a6f79d7..266dad516142d6b5cfebb7ad3859d24b822647b6 100644 --- a/lib/workers/repository/apis.js +++ b/lib/workers/repository/apis.js @@ -40,13 +40,14 @@ async function initApis(inputConfig, token) { const config = Object.assign({}, inputConfig); config.api = getPlatformApi(config.platform); - await config.api.initRepo( + const platformConfig = await config.api.initRepo( config.repository, token, config.endpoint, config.logger ); // Check for presence of .npmrc in repository + Object.assign(config, platformConfig); await module.exports.setNpmrc(config); return config; } diff --git a/test/api/__snapshots__/github.spec.js.snap b/test/api/__snapshots__/github.spec.js.snap index 65e558347c1562d708c07c1fa43486608d451d4e..b87fdc7ff754ea2bad84d96d1fdb658b2cca90a5 100644 --- a/test/api/__snapshots__/github.spec.js.snap +++ b/test/api/__snapshots__/github.spec.js.snap @@ -910,37 +910,19 @@ Array [ exports[`api/github initRepo should detect repoForceRebase 1`] = ` Object { - "baseBranch": "master", - "baseCommitSHA": "1234", - "defaultBranch": "master", - "owner": "theowner", - "privateRepo": false, "repoForceRebase": true, - "repoName": "some/repo", } `; exports[`api/github initRepo should ignore repoForceRebase 403 1`] = ` Object { - "baseBranch": "master", - "baseCommitSHA": "1234", - "defaultBranch": "master", - "owner": "theowner", - "privateRepo": false, "repoForceRebase": false, - "repoName": "some/repo", } `; exports[`api/github initRepo should ignore repoForceRebase 404 1`] = ` Object { - "baseBranch": "master", - "baseCommitSHA": "1234", - "defaultBranch": "master", - "owner": "theowner", - "privateRepo": false, "repoForceRebase": false, - "repoName": "some/repo", } `; @@ -965,14 +947,7 @@ Array [ exports[`api/github initRepo should initialise the config for the repo - 0 2`] = ` Object { - "baseBranch": "master", - "baseCommitSHA": "1234", - "defaultBranch": "master", - "mergeMethod": "rebase", - "owner": "theowner", - "privateRepo": false, "repoForceRebase": false, - "repoName": "some/repo", } `; @@ -997,14 +972,7 @@ Array [ exports[`api/github initRepo should initialise the config for the repo - 1 2`] = ` Object { - "baseBranch": "master", - "baseCommitSHA": "1234", - "defaultBranch": "master", - "mergeMethod": "rebase", - "owner": "theowner", - "privateRepo": false, "repoForceRebase": false, - "repoName": "some/repo", } `; @@ -1029,65 +997,31 @@ Array [ exports[`api/github initRepo should initialise the config for the repo - 2 2`] = ` Object { - "baseBranch": "master", - "baseCommitSHA": "1234", - "defaultBranch": "master", - "mergeMethod": "rebase", - "owner": "theowner", - "privateRepo": false, "repoForceRebase": false, - "repoName": "some/repo", } `; exports[`api/github initRepo should merge 1`] = ` Object { - "baseBranch": "master", - "baseCommitSHA": "1234", - "defaultBranch": "master", - "mergeMethod": "merge", - "owner": "theowner", - "privateRepo": false, "repoForceRebase": false, - "repoName": "some/repo", } `; exports[`api/github initRepo should not guess at merge 1`] = ` Object { - "baseBranch": "master", - "baseCommitSHA": "1234", - "defaultBranch": "master", - "owner": "theowner", - "privateRepo": false, "repoForceRebase": false, - "repoName": "some/repo", } `; exports[`api/github initRepo should rebase 1`] = ` Object { - "baseBranch": "master", - "baseCommitSHA": "1234", - "defaultBranch": "master", - "mergeMethod": "rebase", - "owner": "theowner", - "privateRepo": false, "repoForceRebase": false, - "repoName": "some/repo", } `; exports[`api/github initRepo should squash 1`] = ` Object { - "baseBranch": "master", - "baseCommitSHA": "1234", - "defaultBranch": "master", - "mergeMethod": "squash", - "owner": "theowner", - "privateRepo": false, "repoForceRebase": false, - "repoName": "some/repo", } `; diff --git a/test/api/__snapshots__/gitlab.spec.js.snap b/test/api/__snapshots__/gitlab.spec.js.snap index 94f55b3a5d46232fc96b47d2b49ff9ac4c22a91f..eb2b7dce456b52a5dbd6f2455b911cc149736154 100644 --- a/test/api/__snapshots__/gitlab.spec.js.snap +++ b/test/api/__snapshots__/gitlab.spec.js.snap @@ -233,15 +233,7 @@ Array [ ] `; -exports[`api/gitlab getFile(filePath, branchName) gets the file with v3 1`] = ` -Object { - "apiVersion": "v3", - "baseBranch": undefined, - "defaultBranch": undefined, - "email": undefined, - "repoName": "some-repo", -} -`; +exports[`api/gitlab getFile(filePath, branchName) gets the file with v3 1`] = `Object {}`; exports[`api/gitlab getFile(filePath, branchName) gets the file with v3 2`] = `"foo"`; @@ -329,15 +321,7 @@ Array [ ] `; -exports[`api/gitlab initRepo should initialise the config for the repo - 0 2`] = ` -Object { - "apiVersion": "v3", - "baseBranch": "master", - "defaultBranch": "master", - "email": "a@b.com", - "repoName": "some%2Frepo", -} -`; +exports[`api/gitlab initRepo should initialise the config for the repo - 0 2`] = `Object {}`; exports[`api/gitlab initRepo should initialise the config for the repo - 1 1`] = ` Array [ @@ -353,15 +337,7 @@ Array [ ] `; -exports[`api/gitlab initRepo should initialise the config for the repo - 1 2`] = ` -Object { - "apiVersion": "v3", - "baseBranch": "master", - "defaultBranch": "master", - "email": "a@b.com", - "repoName": "some%2Frepo", -} -`; +exports[`api/gitlab initRepo should initialise the config for the repo - 1 2`] = `Object {}`; exports[`api/gitlab initRepo should initialise the config for the repo - 2 1`] = ` Array [ @@ -377,35 +353,11 @@ Array [ ] `; -exports[`api/gitlab initRepo should initialise the config for the repo - 2 2`] = ` -Object { - "apiVersion": "v3", - "baseBranch": "master", - "defaultBranch": "master", - "email": "a@b.com", - "repoName": "some%2Frepo", -} -`; +exports[`api/gitlab initRepo should initialise the config for the repo - 2 2`] = `Object {}`; -exports[`api/gitlab initRepo should use api v4 1`] = ` -Object { - "apiVersion": "v4", - "baseBranch": "master", - "defaultBranch": "master", - "email": "a@b.com", - "repoName": "some%2Frepo", -} -`; +exports[`api/gitlab initRepo should use api v4 1`] = `Object {}`; -exports[`api/gitlab initRepo uses provided logger 1`] = ` -Object { - "apiVersion": "v3", - "baseBranch": "master", - "defaultBranch": "master", - "email": "a@b.com", - "repoName": "some%2Frepo", -} -`; +exports[`api/gitlab initRepo uses provided logger 1`] = `Object {}`; exports[`api/gitlab setBaseBranch(branchName) sets the base branch 1`] = ` Array [