From 14019fed169623ca71db15ada2d7677da542761c Mon Sep 17 00:00:00 2001 From: Maxime Brunet <max@brnt.mx> Date: Sat, 4 Mar 2023 00:32:04 -0800 Subject: [PATCH] feat(gomod): enable gomodUpdateImportPaths for gopkg.in (#20743) --- lib/modules/manager/gomod/artifacts.spec.ts | 19 +++++++++++++++++-- lib/modules/manager/gomod/artifacts.ts | 4 ++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/modules/manager/gomod/artifacts.spec.ts b/lib/modules/manager/gomod/artifacts.spec.ts index 410a1d04b8..869d5891cf 100644 --- a/lib/modules/manager/gomod/artifacts.spec.ts +++ b/lib/modules/manager/gomod/artifacts.spec.ts @@ -1625,7 +1625,7 @@ describe('modules/manager/gomod/artifacts', () => { ]); }); - it('skips updating import paths for gopkg.in dependencies', async () => { + it('updates import paths for gopkg.in dependencies including v0 to v1', async () => { fs.readLocalFile.mockResolvedValueOnce('Current go.sum'); fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename const execSnapshots = mockExecAll(); @@ -1640,7 +1640,10 @@ describe('modules/manager/gomod/artifacts', () => { expect( await gomod.updateArtifacts({ packageFileName: 'go.mod', - updatedDeps: [{ depName: 'gopkg.in/yaml.v2', newVersion: 'v28.0.0' }], + updatedDeps: [ + { depName: 'gopkg.in/yaml.v2', newVersion: 'v28.0.0' }, + { depName: 'gopkg.in/foo.v0', newVersion: 'v1.0.0' }, + ], newPackageFileContent: gomod1, config: { ...config, @@ -1657,6 +1660,18 @@ describe('modules/manager/gomod/artifacts', () => { cmd: 'go get -d -t ./...', options: { cwd: '/tmp/github/some/repo' }, }, + { + cmd: 'go install github.com/marwan-at-work/mod/cmd/mod@latest', + options: { cwd: '/tmp/github/some/repo' }, + }, + { + cmd: 'mod upgrade --mod-name=gopkg.in/yaml.v2 -t=28', + options: { cwd: '/tmp/github/some/repo' }, + }, + { + cmd: 'mod upgrade --mod-name=gopkg.in/foo.v0 -t=1', + options: { cwd: '/tmp/github/some/repo' }, + }, { cmd: 'go mod tidy', options: { cwd: '/tmp/github/some/repo' }, diff --git a/lib/modules/manager/gomod/artifacts.ts b/lib/modules/manager/gomod/artifacts.ts index 6378f7cd53..570ffed67a 100644 --- a/lib/modules/manager/gomod/artifacts.ts +++ b/lib/modules/manager/gomod/artifacts.ts @@ -134,9 +134,9 @@ function getUpdateImportPathCmds( depName: depName!, newMajor: major(newVersion!), })) - // Skip path upates going from v0 to v1 + // Skip path updates going from v0 to v1 .filter( - ({ depName, newMajor }) => !depName.startsWith('gopkg.in') && newMajor > 1 + ({ depName, newMajor }) => depName.startsWith('gopkg.in') || newMajor > 1 ) .map( -- GitLab