Skip to content

Commit

Permalink
refactor(gitlab): Use new http wrapper for Gitlab platform (#6275)
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov committed May 29, 2020
1 parent 0fcd548 commit 9617248
Show file tree
Hide file tree
Showing 11 changed files with 684 additions and 223 deletions.
8 changes: 4 additions & 4 deletions lib/config/presets/gitlab/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { logger } from '../../../logger';
import { api } from '../../../platform/gitlab/gl-got-wrapper';
import { GitlabHttp } from '../../../util/http/gitlab';
import { ensureTrailingSlash } from '../../../util/url';
import { Preset, PresetConfig } from '../common';

const { get: glGot } = api;
const gitlabApi = new GitlabHttp();

async function getDefaultBranchName(
urlEncodedPkgName: string,
Expand All @@ -15,7 +15,7 @@ async function getDefaultBranchName(
name: string;
}[];

const res = await glGot<GlBranch>(branchesUrl);
const res = await gitlabApi.getJson<GlBranch>(branchesUrl);
const branches = res.body;
let defautlBranchName = 'master';
for (const branch of branches) {
Expand Down Expand Up @@ -52,7 +52,7 @@ export async function getPresetFromEndpoint(

const presetUrl = `${endpoint}projects/${urlEncodedPkgName}/repository/files/renovate.json?ref=${defautlBranchName}`;
res = Buffer.from(
(await glGot(presetUrl)).body.content,
(await gitlabApi.getJson<{ content: string }>(presetUrl)).body.content,
'base64'
).toString();
} catch (err) {
Expand Down
6 changes: 3 additions & 3 deletions lib/datasource/gitlab-tags/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import is from '@sindresorhus/is';
import { logger } from '../../logger';
import { api } from '../../platform/gitlab/gl-got-wrapper';
import * as globalCache from '../../util/cache/global';
import { GitlabHttp } from '../../util/http/gitlab';
import { GetReleasesConfig, ReleaseResult } from '../common';

const { get: glGot } = api;
const gitlabApi = new GitlabHttp();

export const id = 'gitlab-tags';

Expand Down Expand Up @@ -46,7 +46,7 @@ export async function getReleases({
const url = `${depHost}/api/v4/projects/${urlEncodedRepo}/repository/tags?per_page=100`;

gitlabTags = (
await glGot<GitlabTag[]>(url, {
await gitlabApi.getJson<GitlabTag[]>(url, {
paginate: true,
})
).body;
Expand Down
86 changes: 0 additions & 86 deletions lib/platform/gitlab/gl-got-wrapper.ts

This file was deleted.

0 comments on commit 9617248

Please sign in to comment.