From 2f1e1a979a2d86169ca448b90a11f18dddc42f55 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Sat, 19 May 2018 09:15:10 +0200 Subject: [PATCH] fix: Revert "feat: permission check in initRepo (#1983)" This reverts commit 09978ae8dd36a4285c013be050cc2880417b9db5. --- lib/platform/github/index.js | 6 ------ lib/platform/gitlab/index.js | 9 --------- lib/workers/repository/error.js | 4 ---- test/workers/repository/error.spec.js | 1 - 4 files changed, 20 deletions(-) diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js index c9dc8163f0..dba2a4c54d 100644 --- a/lib/platform/github/index.js +++ b/lib/platform/github/index.js @@ -142,9 +142,6 @@ async function initRepo({ // istanbul ignore if if (process.env.NODE_ENV !== 'test') { getBranchCommit(config.baseBranch); // warm the cache - if (!res.body.permissions.push) { - throw new Error('write-forbidden'); - } } logger.debug(`${repository} default branch = ${config.baseBranch}`); // GitHub allows administrators to block certain types of merge, so we need to check it @@ -172,9 +169,6 @@ async function initRepo({ if (err.message.startsWith('Repository access blocked')) { throw new Error('blocked'); } - if (err.message === 'write-forbidden') { - throw new Error('write-forbidden'); - } logger.info( { err, message: err.message, body: res ? res.body : undefined }, 'Unknown GitHub initRepo error' diff --git a/lib/platform/gitlab/index.js b/lib/platform/gitlab/index.js index 55355c1c9a..2a9520bae5 100644 --- a/lib/platform/gitlab/index.js +++ b/lib/platform/gitlab/index.js @@ -93,15 +93,6 @@ async function initRepo({ repository, token, endpoint }) { config.defaultBranch = res.body.default_branch; config.baseBranch = config.defaultBranch; logger.debug(`${repository} default branch = ${config.baseBranch}`); - // istanbul ignore if - if (process.env.NODE_ENV !== 'test') { - if ( - !res.body.permissions.project_access || - res.body.permissions.project_access.access_level < 40 - ) { - throw new Error('write-forbidden'); - } - } // Discover our user email config.email = (await get(`user`)).body.email; delete config.prList; diff --git a/lib/workers/repository/error.js b/lib/workers/repository/error.js index a1ff1ebef0..5f3557cd9d 100644 --- a/lib/workers/repository/error.js +++ b/lib/workers/repository/error.js @@ -28,10 +28,6 @@ async function handleError(config, err) { delete config.branchList; // eslint-disable-line no-param-reassign logger.info('Repository is forbidden'); return err.message; - } else if (err.message === 'write-forbidden') { - delete config.branchList; // eslint-disable-line no-param-reassign - logger.error(`The token doesn't have write permissions to the repository`); - return err.message; } else if (err.message === 'not-found') { delete config.branchList; // eslint-disable-line no-param-reassign logger.error('Repository is not found'); diff --git a/test/workers/repository/error.spec.js b/test/workers/repository/error.spec.js index 4db1659a4d..992c3c4e9b 100644 --- a/test/workers/repository/error.spec.js +++ b/test/workers/repository/error.spec.js @@ -23,7 +23,6 @@ describe('workers/repository/error', () => { 'blocked', 'not-found', 'forbidden', - 'write-forbidden', 'rate-limit-exceeded', ]; errors.forEach(err => { -- GitLab