Skip to content

Commit

Permalink
feat(datasource/nuget): extract latest tag (#26351)
Browse files Browse the repository at this point in the history
  • Loading branch information
RahulGautamSingh authored Dec 19, 2023
1 parent 5c810a1 commit 7cd5ab8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
12 changes: 12 additions & 0 deletions lib/modules/datasource/nuget/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ exports[`modules/datasource/nuget/index getReleases handles paginated results (v
"version": "2.0.0",
},
],
"tags": {
"latest": "2.0.0",
},
}
`;

Expand Down Expand Up @@ -200,6 +203,9 @@ exports[`modules/datasource/nuget/index getReleases processes real data (v2) 1`]
},
],
"sourceUrl": "https://nunit.org/",
"tags": {
"latest": "3.12.0",
},
}
`;

Expand Down Expand Up @@ -1692,6 +1698,9 @@ exports[`modules/datasource/nuget/index getReleases processes real data with no
},
],
"sourceUrl": "https://nunit.org",
"tags": {
"latest": "3.11.0",
},
}
`;

Expand Down Expand Up @@ -1829,6 +1838,9 @@ exports[`modules/datasource/nuget/index getReleases processes real data without
"version": "3.11.0",
},
],
"tags": {
"latest": "3.11.0",
},
}
`;

Expand Down
16 changes: 15 additions & 1 deletion lib/modules/datasource/nuget/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ describe('modules/datasource/nuget/index', () => {
expect(res?.sourceUrl).toBeDefined();
});

it('processes real data no relase (v2)', async () => {
it('processes real data no release (v2)', async () => {
httpMock
.scope('https://www.nuget.org')
.get(
Expand Down Expand Up @@ -627,6 +627,20 @@ describe('modules/datasource/nuget/index', () => {
expect(res).toMatchSnapshot();
});

it('extracts latest tag (v2)', async () => {
httpMock
.scope('https://www.nuget.org')
.get(
'/api/v2/FindPackagesById()?id=%27nunit%27&$select=Version,IsLatestVersion,ProjectUrl,Published',
)
.reply(200, pkgListV2NoGitHubProjectUrl);
const res = await getPkgReleases({
...configV2,
});
expect(res).not.toBeNull();
expect(res?.tags?.latest).toBe('3.11.0');
});

it('handles paginated results (v2)', async () => {
httpMock
.scope('https://www.nuget.org')
Expand Down
1 change: 1 addition & 0 deletions lib/modules/datasource/nuget/v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export async function getReleases(
try {
const pkgIsLatestVersion = getPkgProp(pkgInfo, 'IsLatestVersion');
if (pkgIsLatestVersion === 'true') {
dep['tags'] = { latest: removeBuildMeta(`${version}`) };
const projectUrl = getPkgProp(pkgInfo, 'ProjectUrl');
if (projectUrl) {
dep.sourceUrl = massageUrl(projectUrl);
Expand Down

0 comments on commit 7cd5ab8

Please sign in to comment.