Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(datasource/gitlab-packages): prefer checking for conan_package_name if it exists #33099

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
],
}
`;
44 changes: 44 additions & 0 deletions lib/modules/datasource/gitlab-packages/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Comment on lines +88 to +89
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use toEqual here

});

it('returns null for 404', async () => {
httpMock
.scope('https://gitlab.com')
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/datasource/gitlab-packages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions lib/modules/datasource/gitlab-packages/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export interface GitlabPackage {
version: string;
created_at: string;
name: string;
conan_package_name?: string;
}
Loading