fix: fetch changelog from self-hosted gitlab independent from url (#8336)

This commit is contained in:
Stefan 2021-01-19 09:36:27 +01:00 committed by GitHub
parent 52c70f0b2b
commit 91d30caed7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 1 deletions

View file

@ -190,6 +190,49 @@ Object {
} }
`; `;
exports[`workers/pr/changelog/gitlab getChangeLogJSON supports self-hosted gitlab changelog 1`] = `
Object {
"hasReleaseNotes": false,
"project": Object {
"apiBaseUrl": "https://git.test.com/api/v4/",
"baseUrl": "https://git.test.com/",
"depName": "renovate",
"gitlab": "meno/dropzone",
"repository": "https://git.test.com/meno/dropzone/",
},
"versions": Array [
Object {
"changes": Array [],
"compare": Object {},
"date": undefined,
"releaseNotes": null,
"version": "5.6.1",
},
Object {
"changes": Array [],
"compare": Object {},
"date": "2020-02-13T15:37:00.000Z",
"releaseNotes": null,
"version": "5.6.0",
},
Object {
"changes": Array [],
"compare": Object {},
"date": undefined,
"releaseNotes": null,
"version": "5.5.0",
},
Object {
"changes": Array [],
"compare": Object {},
"date": "2018-08-24T14:23:00.000Z",
"releaseNotes": null,
"version": "5.4.0",
},
],
}
`;
exports[`workers/pr/changelog/gitlab getChangeLogJSON uses GitLab tags 1`] = ` exports[`workers/pr/changelog/gitlab getChangeLogJSON uses GitLab tags 1`] = `
Object { Object {
"hasReleaseNotes": true, "hasReleaseNotes": true,

View file

@ -189,5 +189,22 @@ describe(getName(__filename), () => {
}) })
).toMatchSnapshot(); ).toMatchSnapshot();
}); });
it('supports self-hosted gitlab changelog', async () => {
httpMock.scope('https://git.test.com').persist().get(/.*/).reply(200, []);
hostRules.add({
hostType: PLATFORM_TYPE_GITLAB,
baseUrl: 'https://git.test.com/',
token: 'abc',
});
process.env.GITHUB_ENDPOINT = '';
expect(
await getChangeLogJSON({
...upgrade,
platform: PLATFORM_TYPE_GITLAB,
sourceUrl: 'https://git.test.com/meno/dropzone/',
endpoint: 'https://git.test.com/api/v4/',
})
).toMatchSnapshot();
});
}); });
}); });

View file

@ -27,7 +27,11 @@ export async function getChangeLogJSON(
let res: ChangeLogResult | null = null; let res: ChangeLogResult | null = null;
if (args.sourceUrl?.includes('gitlab')) { if (
args.sourceUrl?.includes('gitlab') ||
(args.platform === 'gitlab' &&
new URL(args.sourceUrl).hostname === new URL(args.endpoint).hostname)
) {
res = await sourceGitlab.getChangeLogJSON({ ...args, releases }); res = await sourceGitlab.getChangeLogJSON({ ...args, releases });
} else { } else {
res = await sourceGithub.getChangeLogJSON({ ...args, releases }); res = await sourceGithub.getChangeLogJSON({ ...args, releases });