Skip to content
Snippets Groups Projects
Unverified Commit 14019fed authored by Maxime Brunet's avatar Maxime Brunet Committed by GitHub
Browse files

feat(gomod): enable gomodUpdateImportPaths for gopkg.in (#20743)

parent 7ff1a3b7
Branches
No related tags found
No related merge requests found
...@@ -1625,7 +1625,7 @@ describe('modules/manager/gomod/artifacts', () => { ...@@ -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('Current go.sum');
fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename fs.readLocalFile.mockResolvedValueOnce(null); // vendor modules filename
const execSnapshots = mockExecAll(); const execSnapshots = mockExecAll();
...@@ -1640,7 +1640,10 @@ describe('modules/manager/gomod/artifacts', () => { ...@@ -1640,7 +1640,10 @@ describe('modules/manager/gomod/artifacts', () => {
expect( expect(
await gomod.updateArtifacts({ await gomod.updateArtifacts({
packageFileName: 'go.mod', 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, newPackageFileContent: gomod1,
config: { config: {
...config, ...config,
...@@ -1657,6 +1660,18 @@ describe('modules/manager/gomod/artifacts', () => { ...@@ -1657,6 +1660,18 @@ describe('modules/manager/gomod/artifacts', () => {
cmd: 'go get -d -t ./...', cmd: 'go get -d -t ./...',
options: { cwd: '/tmp/github/some/repo' }, 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', cmd: 'go mod tidy',
options: { cwd: '/tmp/github/some/repo' }, options: { cwd: '/tmp/github/some/repo' },
......
...@@ -134,9 +134,9 @@ function getUpdateImportPathCmds( ...@@ -134,9 +134,9 @@ function getUpdateImportPathCmds(
depName: depName!, depName: depName!,
newMajor: major(newVersion!), newMajor: major(newVersion!),
})) }))
// Skip path upates going from v0 to v1 // Skip path updates going from v0 to v1
.filter( .filter(
({ depName, newMajor }) => !depName.startsWith('gopkg.in') && newMajor > 1 ({ depName, newMajor }) => depName.startsWith('gopkg.in') || newMajor > 1
) )
.map( .map(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment