fix(go): Better condition for quitting major versions fetch loop (#33102)

This commit is contained in:
Sergei Zharinov 2024-12-13 17:43:41 -03:00 committed by GitHub
parent 0633b79d18
commit 3d86982ccb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 6 deletions

View file

@ -602,8 +602,6 @@ describe('modules/datasource/go/releases-goproxy', () => {
.get('/@v/list')
.reply(200)
.get('/@latest')
.reply(404)
.get('/v2/@v/list')
.reply(404);
const res = await datasource.getReleases({
@ -621,9 +619,7 @@ describe('modules/datasource/go/releases-goproxy', () => {
.get('/@v/list')
.reply(200)
.get('/@latest')
.reply(200, { Version: 'v0.0.0-20230905200255-921286631fa9' })
.get('/v2/@v/list')
.reply(404);
.reply(200, { Version: 'v0.0.0-20230905200255-921286631fa9' });
const res = await datasource.getReleases({
packageName: 'github.com/google/btree',

View file

@ -213,9 +213,11 @@ export class GoProxyDatasource extends Datasource {
major += 1; // v0 and v1 are the same module
}
let releases: Release[] = [];
try {
const res = await this.listVersions(baseUrl, pkg);
const releases = await p.map(res, async (versionInfo) => {
releases = await p.map(res, async (versionInfo) => {
const { version, newDigest, releaseTimestamp } = versionInfo;
if (releaseTimestamp) {
@ -258,6 +260,10 @@ export class GoProxyDatasource extends Datasource {
}
}
}
if (!releases.length) {
break;
}
}
return result;