From c2cf5a96cc45a34b9d6e4b0d2d757951727e8479 Mon Sep 17 00:00:00 2001 From: Lars Kappert Date: Wed, 27 Apr 2022 08:56:17 -0300 Subject: [PATCH] Remove support for GitLab < v12.4 --- lib/plugin/gitlab/GitLab.js | 14 +------------- test/gitlab.js | 14 -------------- test/stub/gitlab.js | 8 -------- 3 files changed, 1 insertion(+), 35 deletions(-) diff --git a/lib/plugin/gitlab/GitLab.js b/lib/plugin/gitlab/GitLab.js index bb058859..8f480c2a 100644 --- a/lib/plugin/gitlab/GitLab.js +++ b/lib/plugin/gitlab/GitLab.js @@ -92,19 +92,7 @@ class GitLab extends Release { return access_level && access_level >= 30; } catch (err) { this.debug(err); - if (err.name === 'HTTPError' && err.response.statusCode === 404) { - // Using another endpoint, since "/projects/:id/members/all/:user_id" was introduced in v12.4 - const endpoint = `projects/${id}/members/${user.id}`; - try { - const { access_level } = await this.request(endpoint, { method: 'GET' }); - return access_level && access_level >= 30; - } catch (err) { - this.debug(err); - return false; - } - } else { - return false; - } + return false; } } diff --git a/test/gitlab.js b/test/gitlab.js index 876e2bfb..929ba6af 100644 --- a/test/gitlab.js +++ b/test/gitlab.js @@ -6,7 +6,6 @@ import { factory, runTasks } from './util/index.js'; import { interceptUser, interceptCollaborator, - interceptCollaboratorFallback, interceptPublish, interceptAsset, interceptMilestones @@ -220,19 +219,6 @@ test.serial('should throw for insufficient access level', async t => { await t.throwsAsync(runTasks(gitlab), { message: /^User john is not a collaborator for john\/repo/ }); }); -test.serial('should fallback for gitlab < v12.4', async t => { - const host = 'https://gitlab.com'; - const pushRepo = `${host}/user/repo`; - const options = { gitlab: { tokenRef, pushRepo, host } }; - const gitlab = factory(GitLab, { options }); - const scope = nock(host); - scope.get(`/api/v4/projects/user%2Frepo/members/all/1`).reply(404); - interceptUser(); - interceptCollaboratorFallback(); - - await t.notThrowsAsync(gitlab.init()); -}); - test('should not make requests in dry run', async t => { const [host, owner, repo] = ['https://gitlab.example.org', 'user', 'repo']; const pushRepo = `${host}/${owner}/${repo}`; diff --git a/test/stub/gitlab.js b/test/stub/gitlab.js index 3304329a..9a29e82d 100644 --- a/test/stub/gitlab.js +++ b/test/stub/gitlab.js @@ -11,14 +11,6 @@ export let interceptCollaborator = ( .get(`/api/v4/projects/${group ? `${group}%2F` : ''}${owner}%2F${project}/members/all/${userId}`) .reply(200, { id: userId, username: owner, access_level: 30 }); -export let interceptCollaboratorFallback = ( - { host = 'https://gitlab.com', owner = 'user', project = 'repo', group, userId = 1 } = {}, - options -) => - nock(host, options) - .get(`/api/v4/projects/${group ? `${group}%2F` : ''}${owner}%2F${project}/members/${userId}`) - .reply(200, { id: userId, username: owner, access_level: 30 }); - export let interceptPublish = ({ host = 'https://gitlab.com', owner = 'user', project = 'repo', body } = {}, options) => nock(host, options).post(`/api/v4/projects/${owner}%2F${project}/releases`, body).reply(200, {});