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
27 changes: 25 additions & 2 deletions lib/workers/repository/process/lookup/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { getUpdateType } from './update-type';
export async function generateUpdate(
config: LookupUpdateConfig,
currentValue: string | undefined,
currentDigest: string | undefined,
versioning: VersioningApi,
rangeStrategy: RangeStrategy,
currentVersion: string,
Expand Down Expand Up @@ -68,8 +69,30 @@ export async function generateUpdate(
} else {
update.newValue = currentValue;
}
update.newMajor = versioning.getMajor(newVersion)!;
update.newMinor = versioning.getMinor(newVersion)!;

const newMajor = versioning.getMajor(newVersion);
if (is.number(newMajor)) {
update.newMajor = newMajor;
}

const newMinor = versioning.getMinor(newVersion);
if (is.number(newMinor)) {
update.newMinor = newMinor;
}

const newPatch = versioning.getPatch(newVersion);

// istanbul ignore next
zharinov marked this conversation as resolved.
Show resolved Hide resolved
rarkins marked this conversation as resolved.
Show resolved Hide resolved
if (
update.newDigest &&
currentDigest !== update.newDigest &&
newMajor === versioning.getMajor(currentVersion) &&
newMinor === versioning.getMinor(currentVersion) &&
newPatch === versioning.getPatch(currentVersion)
) {
update.updateType = 'digest';
}

// istanbul ignore if
if (!update.updateType && !currentVersion) {
logger.debug({ update }, 'Update has no currentVersion');
Expand Down
2 changes: 0 additions & 2 deletions lib/workers/repository/process/lookup/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3492,7 +3492,6 @@ describe('workers/repository/process/lookup/index', () => {
{
bucket: 'major',
newMajor: 9,
newMinor: null,
newValue: '9',
newVersion: '9',
updateType: 'major',
Expand Down Expand Up @@ -3664,7 +3663,6 @@ describe('workers/repository/process/lookup/index', () => {
{
bucket: 'major',
newMajor: 12,
newMinor: null,
newValue: 'bookworm-slim',
newVersion: 'bookworm',
updateType: 'major',
Expand Down
1 change: 1 addition & 0 deletions lib/workers/repository/process/lookup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ export async function lookupUpdates(
const update = await generateUpdate(
config,
compareValue,
config.currentDigest,
versioning,
// TODO #22198

Expand Down