From 6f8cde4e679bea23fea64fefd65200e87578e0b5 Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Fri, 17 May 2024 02:25:48 -0300 Subject: [PATCH] fix(gomod): treat v0 pseudo version updates as digest updates (#29042) Co-authored-by: Rhys Arkins --- .../repository/process/lookup/index.spec.ts | 38 +++++++++++++++++++ .../repository/process/lookup/index.ts | 11 ++++++ 2 files changed, 49 insertions(+) diff --git a/lib/workers/repository/process/lookup/index.spec.ts b/lib/workers/repository/process/lookup/index.spec.ts index 89843c3b2f6e85..88636faa6c2e05 100644 --- a/lib/workers/repository/process/lookup/index.spec.ts +++ b/lib/workers/repository/process/lookup/index.spec.ts @@ -10,6 +10,7 @@ import { DockerDatasource } from '../../../../modules/datasource/docker'; import { GitRefsDatasource } from '../../../../modules/datasource/git-refs'; import { GithubReleasesDatasource } from '../../../../modules/datasource/github-releases'; import { GithubTagsDatasource } from '../../../../modules/datasource/github-tags'; +import { GoDatasource } from '../../../../modules/datasource/go'; import { MavenDatasource } from '../../../../modules/datasource/maven'; import { NpmDatasource } from '../../../../modules/datasource/npm'; import { PackagistDatasource } from '../../../../modules/datasource/packagist'; @@ -4560,5 +4561,42 @@ describe('workers/repository/process/lookup/index', () => { expect(updates).toBeEmptyArray(); }); }); + + it('detects gomod updates and uses updateType=digest when appropriate', async () => { + config.manager = 'gomod'; + config.datasource = GoDatasource.id; + config.currentValue = 'v0.0.0-20240506185236-b8a5c65736ae'; + config.currentDigest = 'b8a5c65736ae'; + config.packageName = 'google.golang.org/genproto/googleapis/rpc'; + config.digestOneAndOnly = true; + + httpMock + .scope( + 'https://proxy.golang.org/google.golang.org/genproto/googleapis/rpc', + ) + .get('/@v/list') + .reply(200, '') + .get('/v2/@v/list') + .reply(404) + .get('/@latest') + .reply(200, { Version: 'v0.0.0-20240509183442-62759503f434' }); + + const { updates } = await Result.wrap( + lookup.lookupUpdates(config), + ).unwrapOrThrow(); + + expect(updates).toEqual([ + { + bucket: 'non-major', + newDigest: '62759503f434', + newMajor: 0, + newMinor: 0, + newValue: 'v0.0.0-20240509183442-62759503f434', + newVersion: 'v0.0.0-20240509183442-62759503f434', + releaseTimestamp: '2024-05-09T18:34:42.000Z', + updateType: 'digest', + }, + ]); + }); }); }); diff --git a/lib/workers/repository/process/lookup/index.ts b/lib/workers/repository/process/lookup/index.ts index ca9ed8e876afa7..15c5835ff6d27b 100644 --- a/lib/workers/repository/process/lookup/index.ts +++ b/lib/workers/repository/process/lookup/index.ts @@ -409,6 +409,17 @@ export async function lookupUpdates( bucket, release, ); + + // #29034 + if ( + config.manager === 'gomod' && + compareValue?.startsWith('v0.0.0-') && + update.newValue?.startsWith('v0.0.0-') && + config.currentDigest !== update.newDigest + ) { + update.updateType = 'digest'; + } + if (pendingChecks) { update.pendingChecks = pendingChecks; }