Skip to content

Commit

Permalink
more review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NiasSt90 committed Dec 19, 2023
1 parent 9514878 commit da6778c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/modules/platform/gerrit/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import JSON5 from 'json5';
import { logger } from '../../../logger';
import type { BranchStatus } from '../../../types';
import { parseJson } from '../../../util/common';
import * as git from '../../../util/git';
import { setBaseUrl } from '../../../util/http/gerrit';
import { regEx } from '../../../util/regex';
Expand Down Expand Up @@ -348,8 +348,8 @@ export async function getJsonFile(
repoName?: string,
branchOrTag?: string,
): Promise<any> {
const raw = (await getRawFile(fileName, repoName, branchOrTag))!;
return JSON5.parse(raw);
const raw = await getRawFile(fileName, repoName, branchOrTag);
return parseJson(raw, fileName);
}

export function getRepoForceRebase(): Promise<boolean> {
Expand Down
3 changes: 0 additions & 3 deletions lib/modules/platform/gerrit/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ const hostRules = mocked(_hostRules);

describe('modules/platform/gerrit/utils', () => {
beforeEach(() => {
jest.resetModules();
jest.mock('../../../util/host-rules');

setBaseUrl(baseUrl);
});

Expand Down
7 changes: 4 additions & 3 deletions lib/util/http/gerrit.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { parseJson } from '../common';
import { regEx } from '../regex';
import { validateUrl } from '../url';
import type { HttpOptions, HttpResponse, InternalHttpOptions } from './types';
import { Http } from './index';

let baseUrl: string;
export const setBaseUrl = (url: string): void => {
export function setBaseUrl(url: string): void {
baseUrl = url;
};
}

/**
* Access Gerrit REST-API and strip-of the "magic prefix" from responses.
Expand All @@ -26,7 +27,7 @@ export class GerritHttp extends Http {
const url = validateUrl(path) ? path : baseUrl + path;
const opts: InternalHttpOptions = {
parseJson: (text: string) =>
JSON.parse(text.replace(GerritHttp.magicPrefix, '')),
parseJson(text.replace(GerritHttp.magicPrefix, ''), path),
...options,
};
opts.headers = {
Expand Down

0 comments on commit da6778c

Please sign in to comment.