Skip to content

Commit

Permalink
Return null in case of ambiguous package name resolution in Repology (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
olegkrivtsov committed Sep 10, 2021
1 parent 6113eba commit ef08699
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/datasource/repology/__snapshots__/index.spec.ts.snap
Expand Up @@ -276,6 +276,21 @@ Array [
]
`;

exports[`datasource/repology/index getReleases returns null on Resolver ambiguous binary package 1`] = `
Array [
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate, br",
"host": "repology.org",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://repology.org/tools/project-by?repo=ubuntu_20_04&name_type=binname&target_page=api_v1_project&noautoresolve=on&name=git",
},
]
`;

exports[`datasource/repology/index getReleases throws error on API request timeout 1`] = `
Array [
Object {
Expand Down
16 changes: 16 additions & 0 deletions lib/datasource/repology/index.spec.ts
Expand Up @@ -181,6 +181,22 @@ describe('datasource/repology/index', () => {
expect(httpMock.getTrace()).toMatchSnapshot();
});

it('returns null on Resolver ambiguous binary package', async () => {
mockResolverCall('ubuntu_20_04', 'git', 'binname', {
status: 300,
body: '[]',
});

expect(
await getPkgReleases({
datasource,
versioning,
depName: 'ubuntu_20_04/git',
})
).toBeNull();
expect(httpMock.getTrace()).toMatchSnapshot();
});

it('throws without repository and package name', async () => {
await expect(
getPkgReleases({
Expand Down
7 changes: 7 additions & 0 deletions lib/datasource/repology/index.ts
Expand Up @@ -152,7 +152,14 @@ async function queryPackage(
// exit immediately if package found
return pkg;
}
} else if (err.statusCode === 300) {
logger.warn(
{ repoName, pkgName },
'Ambiguous redirection from package name to project name in Repology. Skipping this package'
);
return null;
}

throw err;
}

Expand Down

0 comments on commit ef08699

Please sign in to comment.