Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gomod): treat v0 pseudo version updates as digest updates #29042

Merged
merged 12 commits into from
May 17, 2024
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