diff --git a/lib/modules/datasource/gitlab-packages/index.spec.ts b/lib/modules/datasource/gitlab-packages/index.spec.ts index a2fce223c466d5..730bc797c39492 100644 --- a/lib/modules/datasource/gitlab-packages/index.spec.ts +++ b/lib/modules/datasource/gitlab-packages/index.spec.ts @@ -45,6 +45,50 @@ describe('modules/datasource/gitlab-packages/index', () => { expect(res?.releases).toHaveLength(3); }); + it('returns conan package from custom registry', async () => { + const body = [ + { + version: '1.0.0', + created_at: '2020-03-04T12:01:37.000-06:00', + name: 'myconanpkg/1.0.0@mycompany/stable', + conan_package_name: 'myconanpkg', + }, + { + version: 'v1.1.0', + created_at: '2020-04-04T12:01:37.000-06:00', + name: 'myconanpkg/1.1.0@mycompany/stable', + conan_package_name: 'myconanpkg', + }, + { + version: 'v1.1.1', + created_at: '2020-05-04T12:01:37.000-06:00', + name: 'myconanpkg/1.1.0@mycompany/stable', + conan_package_name: 'myconanpkg', + }, + { + version: 'v2.0.0', + created_at: '2020-05-04T12:01:37.000-06:00', + name: 'otherpkg/2.0.0@mycompany/stable', + conan_package_name: 'otherpkg', + }, + ]; + httpMock + .scope('https://gitlab.com') + .get('/api/v4/projects/user%2Fproject1/packages') + .query({ + package_name: 'myconanpkg', + per_page: '100', + }) + .reply(200, body); + const res = await getPkgReleases({ + datasource, + registryUrls: ['https://gitlab.com'], + packageName: 'user/project1:myconanpkg', + }); + expect(res).toMatchSnapshot(); + expect(res?.releases).toHaveLength(3); + }); + it('returns null for 404', async () => { httpMock .scope('https://gitlab.com') diff --git a/lib/modules/datasource/gitlab-packages/index.ts b/lib/modules/datasource/gitlab-packages/index.ts index 28d0483aae5069..486d6839248ced 100644 --- a/lib/modules/datasource/gitlab-packages/index.ts +++ b/lib/modules/datasource/gitlab-packages/index.ts @@ -80,7 +80,7 @@ export class GitlabPackagesDatasource extends Datasource { result.releases = response // Setting the package_name option when calling the GitLab API isn't enough to filter information about other packages // because this option is only implemented on GitLab > 12.9 and it only does a fuzzy search. - .filter((r) => r.name === packagePart) + .filter((r) => (r.conan_package_name ?? r.name) === packagePart) .map(({ version, created_at }) => ({ version, releaseTimestamp: created_at, diff --git a/lib/modules/datasource/gitlab-packages/types.ts b/lib/modules/datasource/gitlab-packages/types.ts index e68eecfa1fd153..3deaa84ab27028 100644 --- a/lib/modules/datasource/gitlab-packages/types.ts +++ b/lib/modules/datasource/gitlab-packages/types.ts @@ -2,4 +2,5 @@ export interface GitlabPackage { version: string; created_at: string; name: string; + conan_package_name?: string; }