From b6036f52789276f9bc9cb23733908c80ff7d7543 Mon Sep 17 00:00:00 2001 From: FFace32 Date: Fri, 13 Dec 2024 21:25:30 +0200 Subject: [PATCH 1/5] fix(datasource/gitlab-packages): prefer checking for conan_package_name if it exists --- lib/modules/datasource/gitlab-packages/index.ts | 2 +- lib/modules/datasource/gitlab-packages/types.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/modules/datasource/gitlab-packages/index.ts b/lib/modules/datasource/gitlab-packages/index.ts index 28d0483aae5069..3d267b18017e45 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; } From 0b079690c53edbec37aae4398dce976eb5269a6a Mon Sep 17 00:00:00 2001 From: FFace32 Date: Sat, 14 Dec 2024 14:20:03 +0200 Subject: [PATCH 2/5] fix(datasource/gitlab-packages): fixed eslint error --- lib/modules/datasource/gitlab-packages/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modules/datasource/gitlab-packages/index.ts b/lib/modules/datasource/gitlab-packages/index.ts index 3d267b18017e45..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.conan_package_name || r.name) === packagePart) + .filter((r) => (r.conan_package_name ?? r.name) === packagePart) .map(({ version, created_at }) => ({ version, releaseTimestamp: created_at, From 22e1327f09096e60fa73866aa6150de5d5ae22d7 Mon Sep 17 00:00:00 2001 From: FFace32 Date: Sat, 14 Dec 2024 14:28:04 +0200 Subject: [PATCH 3/5] test(datasource/gitlab-packages): added conan packages test --- .../datasource/gitlab-packages/index.spec.ts | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/lib/modules/datasource/gitlab-packages/index.spec.ts b/lib/modules/datasource/gitlab-packages/index.spec.ts index a2fce223c466d5..fed4525d9dfaf3 100644 --- a/lib/modules/datasource/gitlab-packages/index.spec.ts +++ b/lib/modules/datasource/gitlab-packages/index.spec.ts @@ -8,7 +8,7 @@ describe('modules/datasource/gitlab-packages/index', () => { it('returns package from custom registry', async () => { const body = [ { - version: '1.0.0', + version: 'v1.0.0', created_at: '2020-03-04T12:01:37.000-06:00', name: 'mypkg', }, @@ -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: 'v1.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') From f631bc4fa7f569dc928a0430524bc4c7471c8446 Mon Sep 17 00:00:00 2001 From: FFace32 Date: Sat, 14 Dec 2024 18:45:18 +0200 Subject: [PATCH 4/5] test(datasource/gitlab-packages): reverted v prefix for some versions --- lib/modules/datasource/gitlab-packages/index.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/modules/datasource/gitlab-packages/index.spec.ts b/lib/modules/datasource/gitlab-packages/index.spec.ts index fed4525d9dfaf3..730bc797c39492 100644 --- a/lib/modules/datasource/gitlab-packages/index.spec.ts +++ b/lib/modules/datasource/gitlab-packages/index.spec.ts @@ -8,7 +8,7 @@ describe('modules/datasource/gitlab-packages/index', () => { it('returns package from custom registry', async () => { const body = [ { - version: 'v1.0.0', + version: '1.0.0', created_at: '2020-03-04T12:01:37.000-06:00', name: 'mypkg', }, @@ -48,7 +48,7 @@ describe('modules/datasource/gitlab-packages/index', () => { it('returns conan package from custom registry', async () => { const body = [ { - version: 'v1.0.0', + 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', From c18479a443e6a9d83f96ec400f23d673aac23aa5 Mon Sep 17 00:00:00 2001 From: FFace32 Date: Sun, 22 Dec 2024 23:54:24 +0200 Subject: [PATCH 5/5] test(datasource/gitlab-packages): added conan packages snapshot --- .../__snapshots__/index.spec.ts.snap | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/modules/datasource/gitlab-packages/__snapshots__/index.spec.ts.snap b/lib/modules/datasource/gitlab-packages/__snapshots__/index.spec.ts.snap index 55b594d1487252..5f35bac1731d74 100644 --- a/lib/modules/datasource/gitlab-packages/__snapshots__/index.spec.ts.snap +++ b/lib/modules/datasource/gitlab-packages/__snapshots__/index.spec.ts.snap @@ -19,3 +19,23 @@ exports[`modules/datasource/gitlab-packages/index getReleases returns package fr ], } `; + +exports[`modules/datasource/gitlab-packages/index getReleases returns conan package from custom registry 1`] = ` +{ + "registryUrl": "https://gitlab.com", + "releases": [ + { + "releaseTimestamp": "2020-03-04T18:01:37.000Z", + "version": "1.0.0", + }, + { + "releaseTimestamp": "2020-04-04T18:01:37.000Z", + "version": "v1.1.0", + }, + { + "releaseTimestamp": "2020-05-04T18:01:37.000Z", + "version": "v1.1.1", + }, + ], +} +`;