mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
fix: Update repology multi package project filtering (#13368)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
parent
9e7c3ae074
commit
a3d38b1e0d
3 changed files with 125 additions and 8 deletions
1
lib/datasource/repology/__fixtures__/python.json
Normal file
1
lib/datasource/repology/__fixtures__/python.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -51,6 +51,7 @@ const fixtureGccDefaults = loadFixture(`gcc-defaults.json`);
|
||||||
const fixtureGcc = loadFixture(`gcc.json`);
|
const fixtureGcc = loadFixture(`gcc.json`);
|
||||||
const fixturePulseaudio = loadFixture(`pulseaudio.json`);
|
const fixturePulseaudio = loadFixture(`pulseaudio.json`);
|
||||||
const fixtureJdk = loadFixture(`openjdk.json`);
|
const fixtureJdk = loadFixture(`openjdk.json`);
|
||||||
|
const fixturePython = loadFixture(`python.json`);
|
||||||
|
|
||||||
describe('datasource/repology/index', () => {
|
describe('datasource/repology/index', () => {
|
||||||
describe('getReleases', () => {
|
describe('getReleases', () => {
|
||||||
|
@ -343,5 +344,121 @@ describe('datasource/repology/index', () => {
|
||||||
expect(release).toBeNull();
|
expect(release).toBeNull();
|
||||||
expect(httpMock.getTrace()).toMatchSnapshot();
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns correct package types for api_call', async () => {
|
||||||
|
const pkgs: RepologyPackage[] = [
|
||||||
|
{
|
||||||
|
repo: 'some_repo',
|
||||||
|
version: '1.0.0',
|
||||||
|
visiblename: 'some-package',
|
||||||
|
srcname: 'some-package',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
repo: 'some_repo',
|
||||||
|
version: '2.0.0',
|
||||||
|
visiblename: 'not-some-package',
|
||||||
|
srcname: 'not-some-package',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
repo: 'some_repo',
|
||||||
|
version: '3.0.0',
|
||||||
|
visiblename: 'some-package',
|
||||||
|
srcname: 'not-some-package',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
repo: 'some_repo',
|
||||||
|
version: '4.0.0',
|
||||||
|
visiblename: 'some-package',
|
||||||
|
binname: 'some-package',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
repo: 'some_repo',
|
||||||
|
version: '5.0.0',
|
||||||
|
visiblename: 'not-some-package',
|
||||||
|
binname: 'not-some-package',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
repo: 'some_repo',
|
||||||
|
version: '6.0.0',
|
||||||
|
visiblename: 'some-package',
|
||||||
|
binname: 'not-some-package',
|
||||||
|
},
|
||||||
|
{ repo: 'some_repo', version: '7.0.0', visiblename: 'some-package' },
|
||||||
|
{
|
||||||
|
repo: 'some_repo',
|
||||||
|
version: '8.0.0',
|
||||||
|
visiblename: 'not-some-package',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
repo: 'not_some_repo',
|
||||||
|
version: '9.0.0',
|
||||||
|
visiblename: 'some-package',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
repo: 'not_some_repo',
|
||||||
|
version: '10.0.0',
|
||||||
|
visiblename: 'some-package',
|
||||||
|
srcname: 'some-package',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
repo: 'not_some_repo',
|
||||||
|
version: '11.0.0',
|
||||||
|
visiblename: 'some-package',
|
||||||
|
binname: 'some-package',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const pkgsJSON = JSON.stringify(pkgs);
|
||||||
|
|
||||||
|
mockResolverCall('some_repo', 'some-package', 'binname', {
|
||||||
|
status: 403,
|
||||||
|
});
|
||||||
|
|
||||||
|
mockApiCall('some-package', {
|
||||||
|
status: 200,
|
||||||
|
body: pkgsJSON,
|
||||||
|
});
|
||||||
|
|
||||||
|
const res = await getPkgReleases({
|
||||||
|
datasource,
|
||||||
|
versioning,
|
||||||
|
depName: 'some_repo/some-package',
|
||||||
|
});
|
||||||
|
expect(res).toEqual({
|
||||||
|
registryUrl: 'https://repology.org',
|
||||||
|
releases: [
|
||||||
|
{ version: '1.0.0' },
|
||||||
|
{
|
||||||
|
version: '4.0.0',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns correct package versions for multi-package project', async () => {
|
||||||
|
mockResolverCall('ubuntu_20_04', 'python3.8', 'binname', {
|
||||||
|
status: 200,
|
||||||
|
body: fixturePython,
|
||||||
|
});
|
||||||
|
|
||||||
|
mockResolverCall('ubuntu_20_04', 'python3.8', 'srcname', {
|
||||||
|
status: 200,
|
||||||
|
body: fixturePython,
|
||||||
|
});
|
||||||
|
|
||||||
|
const res = await getPkgReleases({
|
||||||
|
datasource,
|
||||||
|
versioning,
|
||||||
|
depName: 'ubuntu_20_04/python3.8',
|
||||||
|
});
|
||||||
|
expect(res).toEqual({
|
||||||
|
registryUrl: 'https://repology.org',
|
||||||
|
releases: [
|
||||||
|
{ version: '3.8.2-1ubuntu1' },
|
||||||
|
{
|
||||||
|
version: '3.8.10-0ubuntu1~20.04.2',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -92,15 +92,14 @@ function findPackageInResponse(
|
||||||
// In some cases Repology bundles multiple packages into a single project, which might result in ambiguous results.
|
// In some cases Repology bundles multiple packages into a single project, which might result in ambiguous results.
|
||||||
// We need to do additional filtering by matching allowed package types passed as params with package description.
|
// We need to do additional filtering by matching allowed package types passed as params with package description.
|
||||||
// Remaining packages are the one we are looking for
|
// Remaining packages are the one we are looking for
|
||||||
let packagesWithType: RepologyPackage[];
|
const packagesWithType = repoPackages.filter((pkg) => {
|
||||||
for (const pkgType of types) {
|
for (const pkgType of types) {
|
||||||
packagesWithType = repoPackages.filter(
|
if (pkg[pkgType] && pkg[pkgType] === pkgName) {
|
||||||
(pkg) => !pkg[pkgType] || pkg[pkgType] === pkgName
|
return true;
|
||||||
);
|
}
|
||||||
if (packagesWithType.length === 1) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
return packagesWithType.length > 0 ? packagesWithType : null;
|
return packagesWithType.length > 0 ? packagesWithType : null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue