Skip to content

Commit

Permalink
fix(gomod): go.mod directive should not bump by default (#28475)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Apr 17, 2024
1 parent b652e85 commit 2902d17
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
17 changes: 10 additions & 7 deletions lib/modules/versioning/go-mod-directive/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { api as semver } from '.';

describe('modules/versioning/go-mod-directive/index', () => {
it.each`
version | range | expected
${'1.16.0'} | ${'1.16'} | ${true}
${'1.16.1'} | ${'1.16'} | ${true}
${'1.15.0'} | ${'1.16'} | ${false}
${'1.19.1'} | ${'1.16'} | ${true}
${'2.0.0'} | ${'1.16'} | ${false}
version | range | expected
${'1.16.0'} | ${'1.16'} | ${true}
${'1.16.1'} | ${'1.16'} | ${true}
${'1.15.0'} | ${'1.16'} | ${false}
${'1.19.1'} | ${'1.16'} | ${true}
${'2.0.0'} | ${'1.16'} | ${false}
${'1.22.2'} | ${'1.21.9'} | ${true}
`(
'matches("$version", "$range") === "$expected"',
({ version, range, expected }) => {
Expand Down Expand Up @@ -70,10 +71,12 @@ describe('modules/versioning/go-mod-directive/index', () => {
${'1.16'} | ${'bump'} | ${'1.16.4'} | ${'1.17.0'} | ${'1.17'}
${'1.16'} | ${'bump'} | ${'1.16.4'} | ${'1.16.4'} | ${'1.16'}
${'1.16'} | ${'replace'} | ${'1.16.4'} | ${'1.16.4'} | ${'1.16'}
${'1.16'} | ${'replace'} | ${'1.21.2'} | ${'1.21.2'} | ${'1.21.2'}
${'1.16'} | ${'replace'} | ${'1.21.2'} | ${'1.21.2'} | ${'1.16'}
${'1.16'} | ${'widen'} | ${'1.16.4'} | ${'1.16.4'} | ${'1.16'}
${'1.16'} | ${'bump'} | ${'1.16.4'} | ${'1.21.3'} | ${'1.21.3'}
${'1.21.2'} | ${'bump'} | ${'1.21.2'} | ${'1.21.3'} | ${'1.21.3'}
${'1.21.2'} | ${'replace'} | ${'1.21.2'} | ${'1.22.2'} | ${'1.21.2'}
${'1.21.2'} | ${'replace'} | ${'1.21.2'} | ${'2.0.0'} | ${'2.0.0'}
`(
'getNewValue("$currentValue", "$rangeStrategy", "$currentVersion", "$newVersion") === "$expected"',
({ currentValue, rangeStrategy, currentVersion, newVersion, expected }) => {
Expand Down
7 changes: 2 additions & 5 deletions lib/modules/versioning/go-mod-directive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ function getNewValue({
}
return shorten(newVersion);
}
if (rangeStrategy === 'replace' && !matches(currentValue, newVersion)) {
if (npm.matches(newVersion, '>=1.20.0')) {
return newVersion;
}
return shorten(newVersion);
if (rangeStrategy === 'replace' && !matches(newVersion, currentValue)) {
return newVersion;
}
return currentValue;
}
Expand Down

0 comments on commit 2902d17

Please sign in to comment.