From 6f4da76c719559e544892af8a830dc08c3695d52 Mon Sep 17 00:00:00 2001 From: Russell Rollins <russell@hashicorp.com> Date: Wed, 27 Feb 2019 16:23:01 -0500 Subject: [PATCH] fix(gomod): handling of the "+incompatible" tag. (#3279) --- lib/manager/gomod/update.js | 3 +++ test/_fixtures/go/1/go.mod | 1 + test/manager/gomod/__snapshots__/extract.spec.js.snap | 8 ++++++++ test/manager/gomod/__snapshots__/update.spec.js.snap | 2 ++ test/manager/gomod/extract.spec.js | 2 +- test/manager/gomod/update.spec.js | 11 +++++++++++ 6 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/manager/gomod/update.js b/lib/manager/gomod/update.js index ceac156029..912a837a6b 100644 --- a/lib/manager/gomod/update.js +++ b/lib/manager/gomod/update.js @@ -75,6 +75,9 @@ function updateDependency(currentFileContent, upgrade) { } } } + if (lineToChange.endsWith('+incompatible')) { + newLine += '+incompatible'; + } if (newLine === lineToChange) { logger.debug('No changes necessary'); return currentFileContent; diff --git a/test/_fixtures/go/1/go.mod b/test/_fixtures/go/1/go.mod index 61e316ad7a..a3e27f4b42 100644 --- a/test/_fixtures/go/1/go.mod +++ b/test/_fixtures/go/1/go.mod @@ -6,5 +6,6 @@ require github.com/davecgh/go-spew v1.0.0 require golang.org/x/foo v1.0.0 require github.com/rarkins/foo abcdef1 require gopkg.in/russross/blackfriday.v1 v1.0.0 +require github.com/Azure/azure-sdk-for-go v25.1.0+incompatible replace github.com/pkg/errors => ../errors diff --git a/test/manager/gomod/__snapshots__/extract.spec.js.snap b/test/manager/gomod/__snapshots__/extract.spec.js.snap index 72503ec35f..24ffa3972b 100644 --- a/test/manager/gomod/__snapshots__/extract.spec.js.snap +++ b/test/manager/gomod/__snapshots__/extract.spec.js.snap @@ -628,5 +628,13 @@ Array [ "depType": "require", "lineNumber": 7, }, + Object { + "currentValue": "v25.1.0+incompatible", + "datasource": "go", + "depName": "github.com/Azure/azure-sdk-for-go", + "depNameShort": "Azure/azure-sdk-for-go", + "depType": "require", + "lineNumber": 8, + }, ] `; diff --git a/test/manager/gomod/__snapshots__/update.spec.js.snap b/test/manager/gomod/__snapshots__/update.spec.js.snap index 8528f18f37..06173bcf04 100644 --- a/test/manager/gomod/__snapshots__/update.spec.js.snap +++ b/test/manager/gomod/__snapshots__/update.spec.js.snap @@ -9,6 +9,7 @@ require github.com/davecgh/go-spew v1.0.0 require golang.org/x/foo v1.0.0 require github.com/rarkins/foo abcdef1 require gopkg.in/russross/blackfriday.v2 v2.0.0 +require github.com/Azure/azure-sdk-for-go v25.1.0+incompatible replace github.com/pkg/errors => ../errors " @@ -90,6 +91,7 @@ require github.com/davecgh/go-spew v1.0.0 require golang.org/x/foo v1.0.0 require github.com/rarkins/foo abcdef1 require gopkg.in/russross/blackfriday.v1 v1.0.0 +require github.com/Azure/azure-sdk-for-go v25.1.0+incompatible replace github.com/pkg/errors => ../errors " diff --git a/test/manager/gomod/extract.spec.js b/test/manager/gomod/extract.spec.js index 9a912a0096..c6b95cfcea 100644 --- a/test/manager/gomod/extract.spec.js +++ b/test/manager/gomod/extract.spec.js @@ -16,7 +16,7 @@ describe('lib/manager/gomod/extract', () => { it('extracts single-line requires', () => { const res = extractPackageFile(gomod1, config).deps; expect(res).toMatchSnapshot(); - expect(res).toHaveLength(6); + expect(res).toHaveLength(7); expect(res.filter(e => e.skipReason).length).toBe(1); }); it('extracts multi-line requires', () => { diff --git a/test/manager/gomod/update.spec.js b/test/manager/gomod/update.spec.js index 664e16e278..1ab1b87c9e 100644 --- a/test/manager/gomod/update.spec.js +++ b/test/manager/gomod/update.spec.js @@ -176,5 +176,16 @@ describe('manager/gomod/update', () => { const res = goUpdate.updateDependency(gomod2, upgrade); expect(res).toBe(null); }); + it('handles +incompatible tag', () => { + const upgrade = { + depName: 'github.com/Azure/azure-sdk-for-go', + lineNumber: 8, + newValue: 'v26.0.0', + }; + const res = goUpdate.updateDependency(gomod1, upgrade); + expect(res).not.toEqual(gomod1); + // Assert that the version still contains +incompatible tag. + expect(res.includes(upgrade.newValue + '+incompatible')).toBe(true); + }); }); }); -- GitLab