Skip to content

Commit

Permalink
fix(gomod): treat v0 pseudo version updates as digest updates (#29042)
Browse files Browse the repository at this point in the history
Co-authored-by: Rhys Arkins <[email protected]>
  • Loading branch information
zharinov and rarkins authored May 17, 2024
1 parent f951139 commit 6f8cde4
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lib/workers/repository/process/lookup/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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',
},
]);
});
});
});
11 changes: 11 additions & 0 deletions lib/workers/repository/process/lookup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 6f8cde4

Please sign in to comment.