From 04f89843b132f30bc0af343e23e249e01169c43c Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Tue, 2 Oct 2018 18:49:00 +0200
Subject: [PATCH] fix(gomod): handle quoted dependencies

---
 lib/manager/gomod/extract.js                  |  4 +-
 test/_fixtures/go/2/go.mod                    |  2 +-
 .../gomod/__snapshots__/update.spec.js.snap   | 67 +++++++++++++++++++
 test/manager/gomod/update.spec.js             | 12 ++++
 4 files changed, 83 insertions(+), 2 deletions(-)

diff --git a/lib/manager/gomod/extract.js b/lib/manager/gomod/extract.js
index f6bee68933..549b1cd180 100644
--- a/lib/manager/gomod/extract.js
+++ b/lib/manager/gomod/extract.js
@@ -7,7 +7,9 @@ module.exports = {
 };
 
 function getDep(lineNumber, match) {
-  const [, depName, currentValue] = match;
+  const [, , currentValue] = match;
+  let [, depName] = match;
+  depName = depName.replace(/"/g, '');
   const dep = {
     lineNumber,
     depName,
diff --git a/test/_fixtures/go/2/go.mod b/test/_fixtures/go/2/go.mod
index 75e6957d4b..6be860e0cc 100644
--- a/test/_fixtures/go/2/go.mod
+++ b/test/_fixtures/go/2/go.mod
@@ -55,7 +55,7 @@ require (
 	golang.org/x/net v0.0.0-20180811021610-c39426892332
 	golang.org/x/sys v0.0.0-20180810173357-98c5dad5d1a0
 	golang.org/x/text v0.3.0
-	gopkg.in/src-d/go-billy.v4 v4.2.0
+	"gopkg.in/src-d/go-billy.v4" v4.2.0
 	gopkg.in/src-d/go-git.v4 v4.0.0-20180807092216-43d17e14b714
 	gopkg.in/warnings.v0 v0.1.2
 	gopkg.in/yaml.v2 v2.2.1
diff --git a/test/manager/gomod/__snapshots__/update.spec.js.snap b/test/manager/gomod/__snapshots__/update.spec.js.snap
index 2ca9d426b2..405829a75a 100644
--- a/test/manager/gomod/__snapshots__/update.spec.js.snap
+++ b/test/manager/gomod/__snapshots__/update.spec.js.snap
@@ -12,6 +12,73 @@ require gopkg.in/russross/blackfriday.v2 v2.0.0
 "
 `;
 
+exports[`manager/gomod/update updateDependency replaces quoted multiline 1`] = `
+"module github.com/jesseduffield/lazygit
+
+require (
+	github.com/aws/aws-sdk-go v1.15.21
+	github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d
+	github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21
+	github.com/davecgh/go-spew v1.1.0
+	github.com/emirpasic/gods v1.9.0
+	github.com/fatih/color v1.7.0
+	github.com/fsnotify/fsnotify v1.4.7
+	github.com/go-ini/ini v1.38.2
+	github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
+	github.com/hashicorp/go-cleanhttp v0.0.0-20171218145408-d5fe4b57a186
+	github.com/hashicorp/go-getter v0.0.0-20180809191950-4bda8fa99001
+	github.com/hashicorp/go-safetemp v0.0.0-20180326211150-b1a1dbde6fdc
+	github.com/hashicorp/go-version v1.0.0
+	github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce
+	github.com/heroku/rollrus v0.0.0-20180515183152-fc0cef2ff331
+	github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99
+	github.com/jesseduffield/go-getter v0.0.0-20180822080847-906e15686e63
+	github.com/jesseduffield/gocui v0.0.0-20180921065632-03e26ff3f1de
+	github.com/jesseduffield/termbox-go v0.0.0-20180919093808-1e272ff78dcb
+	github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8
+	github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1
+	github.com/kevinburke/ssh_config v0.0.0-20180317175531-9fc7bb800b55
+	github.com/magiconair/properties v1.8.0
+	github.com/mattn/go-colorable v0.0.9
+	github.com/mattn/go-isatty v0.0.3
+	github.com/mattn/go-runewidth v0.0.2
+	github.com/mgutz/str v1.2.0
+	github.com/mitchellh/go-homedir v0.0.0-20180801233206-58046073cbff
+	github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77
+	github.com/mitchellh/mapstructure v0.0.0-20180715050151-f15292f7a699
+	github.com/nicksnyder/go-i18n v0.0.0-20180803040939-a16b91a3ba80
+	github.com/pelletier/go-buffruneio v0.2.0
+	github.com/pelletier/go-toml v1.2.0
+	github.com/pkg/errors v0.8.0
+	github.com/pmezard/go-difflib v1.0.0
+	github.com/sergi/go-diff v1.0.0
+	github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0
+	github.com/sirupsen/logrus v1.0.6
+	github.com/spf13/afero v1.1.1
+	github.com/spf13/cast v1.2.0
+	github.com/spf13/jwalterweatherman v0.0.0-20180814060501-14d3d4c51834
+	github.com/spf13/pflag v1.0.2
+	github.com/spf13/viper v1.1.0
+	github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad
+	github.com/src-d/gcfg/v2 v2.3.0
+	github.com/stretchr/testify v1.2.2
+	github.com/stvp/roll v0.0.0-20170522205222-3627a5cbeaea
+	github.com/tcnksm/go-gitconfig v0.1.2
+	github.com/ulikunitz/xz v0.5.4
+	github.com/xanzy/ssh-agent v0.2.0
+	golang.org/x/crypto v0.0.0-20180808211826-de0752318171
+	golang.org/x/net v0.0.0-20180811021610-c39426892332
+	golang.org/x/sys v0.0.0-20180810173357-98c5dad5d1a0
+	golang.org/x/text v0.3.0
+	\\"gopkg.in/src-d/go-billy.v4\\" v4.8.0
+	gopkg.in/src-d/go-git.v4 v4.0.0-20180807092216-43d17e14b714
+	gopkg.in/warnings.v0 v0.1.2
+	gopkg.in/yaml.v2 v2.2.1
+
+)
+"
+`;
+
 exports[`manager/gomod/update updateDependency replaces two values in one file 1`] = `
 "module github.com/renovate-tests/gomod1
 
diff --git a/test/manager/gomod/update.spec.js b/test/manager/gomod/update.spec.js
index ff76a56a97..664e16e278 100644
--- a/test/manager/gomod/update.spec.js
+++ b/test/manager/gomod/update.spec.js
@@ -97,6 +97,18 @@ describe('manager/gomod/update', () => {
       expect(res).not.toEqual(gomod2);
       expect(res.includes(upgrade.newValue)).toBe(true);
     });
+    it('replaces quoted multiline', () => {
+      const upgrade = {
+        depName: 'gopkg.in/src-d/go-billy.v4',
+        lineNumber: 57,
+        multiLine: true,
+        newValue: 'v4.8.0',
+      };
+      const res = goUpdate.updateDependency(gomod2, upgrade);
+      expect(res).toMatchSnapshot();
+      expect(res).not.toEqual(gomod2);
+      expect(res.includes(upgrade.newValue)).toBe(true);
+    });
     it('replaces major multiline', () => {
       const upgrade = {
         depName: 'github.com/emirpasic/gods',
-- 
GitLab