Skip to content

Commit

Permalink
fix(go): Better condition for quitting major versions fetch loop (#33102
Browse files Browse the repository at this point in the history
)
  • Loading branch information
zharinov authored Dec 13, 2024
1 parent 0633b79 commit 3d86982
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 1 addition & 5 deletions lib/modules/datasource/go/releases-goproxy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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',
Expand Down
8 changes: 7 additions & 1 deletion lib/modules/datasource/go/releases-goproxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -258,6 +260,10 @@ export class GoProxyDatasource extends Datasource {
}
}
}

if (!releases.length) {
break;
}
}

return result;
Expand Down

0 comments on commit 3d86982

Please sign in to comment.