From 7f44eb38934ef43cb0d3a4d16d6a27c48901a857 Mon Sep 17 00:00:00 2001 From: Denis Gladkikh Date: Sun, 25 Feb 2018 14:14:42 -0800 Subject: [PATCH 1/5] Implement vcs similar to go get For private repositories and git over ssh repositories implementation of dep was different from `go get`. Examples: go get example.com/repo.git Will use remote (scheme)://example.com/repo The most important part that suffix .git tells go get to access the path as git, but it drops the suffix to actually access the remote. Go get will clone this repo as git clone git+ssh://example.com/repo $GOPATH/src/example.com/repo.git It is very unfortunate that you will end up with .git suffixes but at least it works, this is the only way to make `go get` to recognize this import as git. But in case of dep import "example.com/repo.git" Will result for dep to try to access remote as (scheme)://example.com/repo.git Which makes it impossible to teach go get to work with dep. This change is making consistent behavior between *go get* and *dep* by always dropping suffix *.git* for remotes (which is also not ideal, but at least it works now with *go dep*). Other changes related to the schemas, I made the order match to the default schemes in *go get* --- .gitignore | 1 + gps/deduce.go | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 433ced5de1..f7c17fcc63 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ /profile.out /coverage.txt release/ +.idea/ \ No newline at end of file diff --git a/gps/deduce.go b/gps/deduce.go index 796681738f..e4ff758479 100644 --- a/gps/deduce.go +++ b/gps/deduce.go @@ -21,10 +21,10 @@ import ( ) var ( - gitSchemes = []string{"https", "ssh", "git", "http"} - bzrSchemes = []string{"https", "bzr+ssh", "bzr", "http"} - hgSchemes = []string{"https", "ssh", "http"} - svnSchemes = []string{"https", "http", "svn", "svn+ssh"} + gitSchemes = []string{"git+ssh", "https", "ssh", "git", "http"} + bzrSchemes = []string{"bzr+ssh", "https", "bzr", "http"} + hgSchemes = []string{"ssh", "https", "http"} + svnSchemes = []string{"svn+ssh", "https", "http", "svn"} gopkginSchemes = []string{"https", "http"} ) @@ -73,7 +73,7 @@ var ( //gcRegex = regexp.MustCompile(`^(?Pcode\.google\.com/[pr]/(?P[a-z0-9\-]+)(\.(?P[a-z0-9\-]+))?)(/[A-Za-z0-9_.\-]+)*$`) jazzRegex = regexp.MustCompile(`^(?Phub\.jazz\.net(/git/[a-z0-9]+/[A-Za-z0-9_.\-]+))((?:/[A-Za-z0-9_.\-]+)*)$`) apacheRegex = regexp.MustCompile(`^(?Pgit\.apache\.org(/[a-z0-9_.\-]+\.git))((?:/[A-Za-z0-9_.\-]+)*)$`) - vcsExtensionRegex = regexp.MustCompile(`^(?P([a-z0-9.\-]+\.)+[a-z0-9.\-]+(:[0-9]+)?/[A-Za-z0-9_.\-/~]*?\.(?Pbzr|git|hg|svn))((?:/[A-Za-z0-9_.\-]+)*)$`) + vcsExtensionRegex = regexp.MustCompile(`^(?P(?P([a-z0-9.\-]+\.)+[a-z0-9.\-]+(:[0-9]+)?(/~?[A-Za-z0-9_.\-]+)+?)\.(?Pbzr|fossil|git|hg|svn))(/~?[A-Za-z0-9_.\-]+)*$`) ) // Other helper regexes @@ -486,19 +486,26 @@ func (m vcsExtensionDeducer) deduceSource(path string, u *url.URL) (maybeSources return nil, fmt.Errorf("%s contains no vcs extension hints for matching", path) } - switch v[4] { + match := map[string]string{} + for i, name := range m.regexp.SubexpNames() { + if name != "" && match[name] == "" { + match[name] = v[i] + } + } + + switch match["vcs"] { case "git", "hg", "bzr": - x := strings.SplitN(v[1], "/", 2) + x := strings.SplitN(match["repo"], "/", 2) // TODO(sdboyer) is this actually correct for bzr? u.Host = x[0] u.Path = "/" + x[1] if u.Scheme != "" { - if !validateVCSScheme(u.Scheme, v[4]) { + if !validateVCSScheme(u.Scheme, match["vcs"]) { return nil, fmt.Errorf("%s is not a valid scheme for accessing %s repositories (path %s)", u.Scheme, v[4], path) } - switch v[4] { + switch match["vcs"] { case "git": return maybeSources{maybeGitSource{url: u}}, nil case "bzr": @@ -512,7 +519,7 @@ func (m vcsExtensionDeducer) deduceSource(path string, u *url.URL) (maybeSources var mb maybeSources var f func(k int, u *url.URL) - switch v[4] { + switch match["vcs"] { case "git": schemes = gitSchemes f = func(k int, u *url.URL) { From 4f2cc1bf70c6c90c4b09902bd18637a22a6f1923 Mon Sep 17 00:00:00 2001 From: Denis Gladkikh Date: Sun, 25 Feb 2018 14:43:35 -0800 Subject: [PATCH 2/5] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68444d004c..ecbdfc3829 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ NEW FEATURES: BUG FIXES: +* `dep` resolves private repos (including `git`) similarly to `go get` ([#1716](https://github.com/golang/dep/issues/1716)) + IMPROVEMENTS: * Reduce network access by trusting local source information and only pulling From 4f1f5eb10280f42f103950981ac98d0feea09b8a Mon Sep 17 00:00:00 2001 From: Denis Gladkikh Date: Sun, 25 Feb 2018 16:05:40 -0800 Subject: [PATCH 3/5] Fix tests. Revert back order --- gps/deduce.go | 10 +++++----- gps/deduce_test.go | 50 ++++++++++++++++++---------------------------- 2 files changed, 24 insertions(+), 36 deletions(-) diff --git a/gps/deduce.go b/gps/deduce.go index e4ff758479..74a7116847 100644 --- a/gps/deduce.go +++ b/gps/deduce.go @@ -21,10 +21,10 @@ import ( ) var ( - gitSchemes = []string{"git+ssh", "https", "ssh", "git", "http"} - bzrSchemes = []string{"bzr+ssh", "https", "bzr", "http"} - hgSchemes = []string{"ssh", "https", "http"} - svnSchemes = []string{"svn+ssh", "https", "http", "svn"} + gitSchemes = []string{"https", "ssh", "git", "http"} + bzrSchemes = []string{"https", "bzr+ssh", "bzr", "http"} + hgSchemes = []string{"https", "ssh", "http"} + svnSchemes = []string{"https", "http", "svn", "svn+ssh"} gopkginSchemes = []string{"https", "http"} ) @@ -502,7 +502,7 @@ func (m vcsExtensionDeducer) deduceSource(path string, u *url.URL) (maybeSources if u.Scheme != "" { if !validateVCSScheme(u.Scheme, match["vcs"]) { - return nil, fmt.Errorf("%s is not a valid scheme for accessing %s repositories (path %s)", u.Scheme, v[4], path) + return nil, fmt.Errorf("%s is not a valid scheme for accessing %s repositories (path %s)", u.Scheme, match["vcs"], path) } switch match["vcs"] { diff --git a/gps/deduce_test.go b/gps/deduce_test.go index 0eb05eb359..0f8e4c71f2 100644 --- a/gps/deduce_test.go +++ b/gps/deduce_test.go @@ -396,67 +396,67 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "foobar.com/baz.git", root: "foobar.com/baz.git", mb: maybeSources{ - maybeGitSource{url: mkurl("https://foobar.com/baz.git")}, - maybeGitSource{url: mkurl("ssh://foobar.com/baz.git")}, - maybeGitSource{url: mkurl("git://foobar.com/baz.git")}, - maybeGitSource{url: mkurl("http://foobar.com/baz.git")}, + maybeGitSource{url: mkurl("https://foobar.com/baz")}, + maybeGitSource{url: mkurl("ssh://foobar.com/baz")}, + maybeGitSource{url: mkurl("git://foobar.com/baz")}, + maybeGitSource{url: mkurl("http://foobar.com/baz")}, }, }, { in: "foobar.com/baz.git/extra/path", root: "foobar.com/baz.git", mb: maybeSources{ - maybeGitSource{url: mkurl("https://foobar.com/baz.git")}, - maybeGitSource{url: mkurl("ssh://foobar.com/baz.git")}, - maybeGitSource{url: mkurl("git://foobar.com/baz.git")}, - maybeGitSource{url: mkurl("http://foobar.com/baz.git")}, + maybeGitSource{url: mkurl("https://foobar.com/baz")}, + maybeGitSource{url: mkurl("ssh://foobar.com/baz")}, + maybeGitSource{url: mkurl("git://foobar.com/baz")}, + maybeGitSource{url: mkurl("http://foobar.com/baz")}, }, }, { in: "foobar.com/baz.bzr", root: "foobar.com/baz.bzr", mb: maybeSources{ - maybeBzrSource{url: mkurl("https://foobar.com/baz.bzr")}, - maybeBzrSource{url: mkurl("bzr+ssh://foobar.com/baz.bzr")}, - maybeBzrSource{url: mkurl("bzr://foobar.com/baz.bzr")}, - maybeBzrSource{url: mkurl("http://foobar.com/baz.bzr")}, + maybeBzrSource{url: mkurl("https://foobar.com/baz")}, + maybeBzrSource{url: mkurl("bzr+ssh://foobar.com/baz")}, + maybeBzrSource{url: mkurl("bzr://foobar.com/baz")}, + maybeBzrSource{url: mkurl("http://foobar.com/baz")}, }, }, { in: "foo-bar.com/baz.hg", root: "foo-bar.com/baz.hg", mb: maybeSources{ - maybeHgSource{url: mkurl("https://foo-bar.com/baz.hg")}, - maybeHgSource{url: mkurl("ssh://foo-bar.com/baz.hg")}, - maybeHgSource{url: mkurl("http://foo-bar.com/baz.hg")}, + maybeHgSource{url: mkurl("https://foo-bar.com/baz")}, + maybeHgSource{url: mkurl("ssh://foo-bar.com/baz")}, + maybeHgSource{url: mkurl("http://foo-bar.com/baz")}, }, }, { in: "git@foobar.com:baz.git", root: "foobar.com/baz.git", mb: maybeSources{ - maybeGitSource{url: mkurl("ssh://git@foobar.com/baz.git")}, + maybeGitSource{url: mkurl("ssh://git@foobar.com/baz")}, }, }, { in: "bzr+ssh://foobar.com/baz.bzr", root: "foobar.com/baz.bzr", mb: maybeSources{ - maybeBzrSource{url: mkurl("bzr+ssh://foobar.com/baz.bzr")}, + maybeBzrSource{url: mkurl("bzr+ssh://foobar.com/baz")}, }, }, { in: "ssh://foobar.com/baz.bzr", root: "foobar.com/baz.bzr", mb: maybeSources{ - maybeBzrSource{url: mkurl("ssh://foobar.com/baz.bzr")}, + maybeBzrSource{url: mkurl("ssh://foobar.com/baz")}, }, }, { in: "https://foobar.com/baz.hg", root: "foobar.com/baz.hg", mb: maybeSources{ - maybeHgSource{url: mkurl("https://foobar.com/baz.hg")}, + maybeHgSource{url: mkurl("https://foobar.com/baz")}, }, }, { @@ -464,18 +464,6 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ root: "foobar.com/baz.hg", srcerr: errors.New("git is not a valid scheme for accessing hg repositories (path foobar.com/baz.hg)"), }, - // who knows why anyone would do this, but having a second vcs ext - // shouldn't throw us off - only the first one counts - { - in: "foobar.com/baz.git/quark/quizzle.bzr/quorum", - root: "foobar.com/baz.git", - mb: maybeSources{ - maybeGitSource{url: mkurl("https://foobar.com/baz.git")}, - maybeGitSource{url: mkurl("ssh://foobar.com/baz.git")}, - maybeGitSource{url: mkurl("git://foobar.com/baz.git")}, - maybeGitSource{url: mkurl("http://foobar.com/baz.git")}, - }, - }, }, "vanity": { // Vanity imports From ca4c99c0ca00dd728a32f12c22d7f2f9a52ee0c8 Mon Sep 17 00:00:00 2001 From: Denis Gladkikh Date: Sun, 25 Feb 2018 16:17:40 -0800 Subject: [PATCH 4/5] Set order similar to go get --- gps/deduce.go | 8 ++++---- gps/deduce_test.go | 44 ++++++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/gps/deduce.go b/gps/deduce.go index 74a7116847..02ac06ff9c 100644 --- a/gps/deduce.go +++ b/gps/deduce.go @@ -21,10 +21,10 @@ import ( ) var ( - gitSchemes = []string{"https", "ssh", "git", "http"} - bzrSchemes = []string{"https", "bzr+ssh", "bzr", "http"} - hgSchemes = []string{"https", "ssh", "http"} - svnSchemes = []string{"https", "http", "svn", "svn+ssh"} + gitSchemes = []string{"ssh", "https", "git", "http"} + bzrSchemes = []string{"bzr+ssh", "https", "bzr", "http"} + hgSchemes = []string{"ssh", "https", "http"} + svnSchemes = []string{"svn+ssh", "https", "http", "svn"} gopkginSchemes = []string{"https", "http"} ) diff --git a/gps/deduce_test.go b/gps/deduce_test.go index 0f8e4c71f2..55107c0d49 100644 --- a/gps/deduce_test.go +++ b/gps/deduce_test.go @@ -38,8 +38,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "github.com/sdboyer/gps", root: "github.com/sdboyer/gps", mb: maybeSources{ - maybeGitSource{url: mkurl("https://github.com/sdboyer/gps")}, maybeGitSource{url: mkurl("ssh://git@github.com/sdboyer/gps")}, + maybeGitSource{url: mkurl("https://github.com/sdboyer/gps")}, maybeGitSource{url: mkurl("git://github.com/sdboyer/gps")}, maybeGitSource{url: mkurl("http://github.com/sdboyer/gps")}, }, @@ -48,8 +48,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "github.com/sdboyer/gps/foo", root: "github.com/sdboyer/gps", mb: maybeSources{ - maybeGitSource{url: mkurl("https://github.com/sdboyer/gps")}, maybeGitSource{url: mkurl("ssh://git@github.com/sdboyer/gps")}, + maybeGitSource{url: mkurl("https://github.com/sdboyer/gps")}, maybeGitSource{url: mkurl("git://github.com/sdboyer/gps")}, maybeGitSource{url: mkurl("http://github.com/sdboyer/gps")}, }, @@ -60,8 +60,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "github.com/sdboyer/gps.git/foo", root: "github.com/sdboyer/gps.git", mb: maybeSources{ - maybeGitSource{url: mkurl("https://github.com/sdboyer/gps.git")}, maybeGitSource{url: mkurl("ssh://git@github.com/sdboyer/gps.git")}, + maybeGitSource{url: mkurl("https://github.com/sdboyer/gps.git")}, maybeGitSource{url: mkurl("git://github.com/sdboyer/gps.git")}, maybeGitSource{url: mkurl("http://github.com/sdboyer/gps.git")}, }, @@ -91,8 +91,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "github.com/sdboyer-/gps/foo", root: "github.com/sdboyer-/gps", mb: maybeSources{ - maybeGitSource{url: mkurl("https://github.com/sdboyer-/gps")}, maybeGitSource{url: mkurl("ssh://git@github.com/sdboyer-/gps")}, + maybeGitSource{url: mkurl("https://github.com/sdboyer-/gps")}, maybeGitSource{url: mkurl("git://github.com/sdboyer-/gps")}, maybeGitSource{url: mkurl("http://github.com/sdboyer-/gps")}, }, @@ -101,8 +101,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "github.com/a/gps/foo", root: "github.com/a/gps", mb: maybeSources{ - maybeGitSource{url: mkurl("https://github.com/a/gps")}, maybeGitSource{url: mkurl("ssh://git@github.com/a/gps")}, + maybeGitSource{url: mkurl("https://github.com/a/gps")}, maybeGitSource{url: mkurl("git://github.com/a/gps")}, maybeGitSource{url: mkurl("http://github.com/a/gps")}, }, @@ -125,8 +125,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "github.com/kr/pretty", root: "github.com/kr/pretty", mb: maybeSources{ - maybeGitSource{url: mkurl("https://github.com/kr/pretty")}, maybeGitSource{url: mkurl("ssh://git@github.com/kr/pretty")}, + maybeGitSource{url: mkurl("https://github.com/kr/pretty")}, maybeGitSource{url: mkurl("git://github.com/kr/pretty")}, maybeGitSource{url: mkurl("http://github.com/kr/pretty")}, }, @@ -244,11 +244,11 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "bitbucket.org/sdboyer/reporoot", root: "bitbucket.org/sdboyer/reporoot", mb: maybeSources{ - maybeHgSource{url: mkurl("https://bitbucket.org/sdboyer/reporoot")}, maybeHgSource{url: mkurl("ssh://hg@bitbucket.org/sdboyer/reporoot")}, + maybeHgSource{url: mkurl("https://bitbucket.org/sdboyer/reporoot")}, maybeHgSource{url: mkurl("http://bitbucket.org/sdboyer/reporoot")}, - maybeGitSource{url: mkurl("https://bitbucket.org/sdboyer/reporoot")}, maybeGitSource{url: mkurl("ssh://git@bitbucket.org/sdboyer/reporoot")}, + maybeGitSource{url: mkurl("https://bitbucket.org/sdboyer/reporoot")}, maybeGitSource{url: mkurl("git://bitbucket.org/sdboyer/reporoot")}, maybeGitSource{url: mkurl("http://bitbucket.org/sdboyer/reporoot")}, }, @@ -257,11 +257,11 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "bitbucket.org/sdboyer/reporoot/foo/bar", root: "bitbucket.org/sdboyer/reporoot", mb: maybeSources{ - maybeHgSource{url: mkurl("https://bitbucket.org/sdboyer/reporoot")}, maybeHgSource{url: mkurl("ssh://hg@bitbucket.org/sdboyer/reporoot")}, + maybeHgSource{url: mkurl("https://bitbucket.org/sdboyer/reporoot")}, maybeHgSource{url: mkurl("http://bitbucket.org/sdboyer/reporoot")}, - maybeGitSource{url: mkurl("https://bitbucket.org/sdboyer/reporoot")}, maybeGitSource{url: mkurl("ssh://git@bitbucket.org/sdboyer/reporoot")}, + maybeGitSource{url: mkurl("https://bitbucket.org/sdboyer/reporoot")}, maybeGitSource{url: mkurl("git://bitbucket.org/sdboyer/reporoot")}, maybeGitSource{url: mkurl("http://bitbucket.org/sdboyer/reporoot")}, }, @@ -279,8 +279,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "bitbucket.org/sdboyer/reporoot.git", root: "bitbucket.org/sdboyer/reporoot.git", mb: maybeSources{ - maybeGitSource{url: mkurl("https://bitbucket.org/sdboyer/reporoot.git")}, maybeGitSource{url: mkurl("ssh://git@bitbucket.org/sdboyer/reporoot.git")}, + maybeGitSource{url: mkurl("https://bitbucket.org/sdboyer/reporoot.git")}, maybeGitSource{url: mkurl("git://bitbucket.org/sdboyer/reporoot.git")}, maybeGitSource{url: mkurl("http://bitbucket.org/sdboyer/reporoot.git")}, }, @@ -296,8 +296,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "bitbucket.org/sdboyer/reporoot.hg", root: "bitbucket.org/sdboyer/reporoot.hg", mb: maybeSources{ - maybeHgSource{url: mkurl("https://bitbucket.org/sdboyer/reporoot.hg")}, maybeHgSource{url: mkurl("ssh://hg@bitbucket.org/sdboyer/reporoot.hg")}, + maybeHgSource{url: mkurl("https://bitbucket.org/sdboyer/reporoot.hg")}, maybeHgSource{url: mkurl("http://bitbucket.org/sdboyer/reporoot.hg")}, }, }, @@ -321,8 +321,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "launchpad.net/govcstestbzrrepo", root: "launchpad.net/govcstestbzrrepo", mb: maybeSources{ - maybeBzrSource{url: mkurl("https://launchpad.net/govcstestbzrrepo")}, maybeBzrSource{url: mkurl("bzr+ssh://launchpad.net/govcstestbzrrepo")}, + maybeBzrSource{url: mkurl("https://launchpad.net/govcstestbzrrepo")}, maybeBzrSource{url: mkurl("bzr://launchpad.net/govcstestbzrrepo")}, maybeBzrSource{url: mkurl("http://launchpad.net/govcstestbzrrepo")}, }, @@ -331,8 +331,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "launchpad.net/govcstestbzrrepo/foo/bar", root: "launchpad.net/govcstestbzrrepo", mb: maybeSources{ - maybeBzrSource{url: mkurl("https://launchpad.net/govcstestbzrrepo")}, maybeBzrSource{url: mkurl("bzr+ssh://launchpad.net/govcstestbzrrepo")}, + maybeBzrSource{url: mkurl("https://launchpad.net/govcstestbzrrepo")}, maybeBzrSource{url: mkurl("bzr://launchpad.net/govcstestbzrrepo")}, maybeBzrSource{url: mkurl("http://launchpad.net/govcstestbzrrepo")}, }, @@ -347,8 +347,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "git.launchpad.net/reporoot", root: "git.launchpad.net/reporoot", mb: maybeSources{ - maybeGitSource{url: mkurl("https://git.launchpad.net/reporoot")}, maybeGitSource{url: mkurl("ssh://git.launchpad.net/reporoot")}, + maybeGitSource{url: mkurl("https://git.launchpad.net/reporoot")}, maybeGitSource{url: mkurl("git://git.launchpad.net/reporoot")}, maybeGitSource{url: mkurl("http://git.launchpad.net/reporoot")}, }, @@ -357,8 +357,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "git.launchpad.net/reporoot/foo/bar", root: "git.launchpad.net/reporoot", mb: maybeSources{ - maybeGitSource{url: mkurl("https://git.launchpad.net/reporoot")}, maybeGitSource{url: mkurl("ssh://git.launchpad.net/reporoot")}, + maybeGitSource{url: mkurl("https://git.launchpad.net/reporoot")}, maybeGitSource{url: mkurl("git://git.launchpad.net/reporoot")}, maybeGitSource{url: mkurl("http://git.launchpad.net/reporoot")}, }, @@ -373,8 +373,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "git.apache.org/package-name.git", root: "git.apache.org/package-name.git", mb: maybeSources{ - maybeGitSource{url: mkurl("https://git.apache.org/package-name.git")}, maybeGitSource{url: mkurl("ssh://git.apache.org/package-name.git")}, + maybeGitSource{url: mkurl("https://git.apache.org/package-name.git")}, maybeGitSource{url: mkurl("git://git.apache.org/package-name.git")}, maybeGitSource{url: mkurl("http://git.apache.org/package-name.git")}, }, @@ -383,8 +383,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "git.apache.org/package-name.git/foo/bar", root: "git.apache.org/package-name.git", mb: maybeSources{ - maybeGitSource{url: mkurl("https://git.apache.org/package-name.git")}, maybeGitSource{url: mkurl("ssh://git.apache.org/package-name.git")}, + maybeGitSource{url: mkurl("https://git.apache.org/package-name.git")}, maybeGitSource{url: mkurl("git://git.apache.org/package-name.git")}, maybeGitSource{url: mkurl("http://git.apache.org/package-name.git")}, }, @@ -396,8 +396,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "foobar.com/baz.git", root: "foobar.com/baz.git", mb: maybeSources{ - maybeGitSource{url: mkurl("https://foobar.com/baz")}, maybeGitSource{url: mkurl("ssh://foobar.com/baz")}, + maybeGitSource{url: mkurl("https://foobar.com/baz")}, maybeGitSource{url: mkurl("git://foobar.com/baz")}, maybeGitSource{url: mkurl("http://foobar.com/baz")}, }, @@ -406,8 +406,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "foobar.com/baz.git/extra/path", root: "foobar.com/baz.git", mb: maybeSources{ - maybeGitSource{url: mkurl("https://foobar.com/baz")}, maybeGitSource{url: mkurl("ssh://foobar.com/baz")}, + maybeGitSource{url: mkurl("https://foobar.com/baz")}, maybeGitSource{url: mkurl("git://foobar.com/baz")}, maybeGitSource{url: mkurl("http://foobar.com/baz")}, }, @@ -416,8 +416,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "foobar.com/baz.bzr", root: "foobar.com/baz.bzr", mb: maybeSources{ - maybeBzrSource{url: mkurl("https://foobar.com/baz")}, maybeBzrSource{url: mkurl("bzr+ssh://foobar.com/baz")}, + maybeBzrSource{url: mkurl("https://foobar.com/baz")}, maybeBzrSource{url: mkurl("bzr://foobar.com/baz")}, maybeBzrSource{url: mkurl("http://foobar.com/baz")}, }, @@ -426,8 +426,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "foo-bar.com/baz.hg", root: "foo-bar.com/baz.hg", mb: maybeSources{ - maybeHgSource{url: mkurl("https://foo-bar.com/baz")}, maybeHgSource{url: mkurl("ssh://foo-bar.com/baz")}, + maybeHgSource{url: mkurl("https://foo-bar.com/baz")}, maybeHgSource{url: mkurl("http://foo-bar.com/baz")}, }, }, From c2213dcfdef91b9528ee3c5b6357f0389f9ca1d4 Mon Sep 17 00:00:00 2001 From: Denis Gladkikh Date: Sun, 25 Feb 2018 16:58:51 -0800 Subject: [PATCH 5/5] Revert "Set order similar to go get" This reverts commit ca4c99c0ca00dd728a32f12c22d7f2f9a52ee0c8. --- gps/deduce.go | 8 ++++---- gps/deduce_test.go | 44 ++++++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/gps/deduce.go b/gps/deduce.go index 02ac06ff9c..74a7116847 100644 --- a/gps/deduce.go +++ b/gps/deduce.go @@ -21,10 +21,10 @@ import ( ) var ( - gitSchemes = []string{"ssh", "https", "git", "http"} - bzrSchemes = []string{"bzr+ssh", "https", "bzr", "http"} - hgSchemes = []string{"ssh", "https", "http"} - svnSchemes = []string{"svn+ssh", "https", "http", "svn"} + gitSchemes = []string{"https", "ssh", "git", "http"} + bzrSchemes = []string{"https", "bzr+ssh", "bzr", "http"} + hgSchemes = []string{"https", "ssh", "http"} + svnSchemes = []string{"https", "http", "svn", "svn+ssh"} gopkginSchemes = []string{"https", "http"} ) diff --git a/gps/deduce_test.go b/gps/deduce_test.go index 55107c0d49..0f8e4c71f2 100644 --- a/gps/deduce_test.go +++ b/gps/deduce_test.go @@ -38,8 +38,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "github.com/sdboyer/gps", root: "github.com/sdboyer/gps", mb: maybeSources{ - maybeGitSource{url: mkurl("ssh://git@github.com/sdboyer/gps")}, maybeGitSource{url: mkurl("https://github.com/sdboyer/gps")}, + maybeGitSource{url: mkurl("ssh://git@github.com/sdboyer/gps")}, maybeGitSource{url: mkurl("git://github.com/sdboyer/gps")}, maybeGitSource{url: mkurl("http://github.com/sdboyer/gps")}, }, @@ -48,8 +48,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "github.com/sdboyer/gps/foo", root: "github.com/sdboyer/gps", mb: maybeSources{ - maybeGitSource{url: mkurl("ssh://git@github.com/sdboyer/gps")}, maybeGitSource{url: mkurl("https://github.com/sdboyer/gps")}, + maybeGitSource{url: mkurl("ssh://git@github.com/sdboyer/gps")}, maybeGitSource{url: mkurl("git://github.com/sdboyer/gps")}, maybeGitSource{url: mkurl("http://github.com/sdboyer/gps")}, }, @@ -60,8 +60,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "github.com/sdboyer/gps.git/foo", root: "github.com/sdboyer/gps.git", mb: maybeSources{ - maybeGitSource{url: mkurl("ssh://git@github.com/sdboyer/gps.git")}, maybeGitSource{url: mkurl("https://github.com/sdboyer/gps.git")}, + maybeGitSource{url: mkurl("ssh://git@github.com/sdboyer/gps.git")}, maybeGitSource{url: mkurl("git://github.com/sdboyer/gps.git")}, maybeGitSource{url: mkurl("http://github.com/sdboyer/gps.git")}, }, @@ -91,8 +91,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "github.com/sdboyer-/gps/foo", root: "github.com/sdboyer-/gps", mb: maybeSources{ - maybeGitSource{url: mkurl("ssh://git@github.com/sdboyer-/gps")}, maybeGitSource{url: mkurl("https://github.com/sdboyer-/gps")}, + maybeGitSource{url: mkurl("ssh://git@github.com/sdboyer-/gps")}, maybeGitSource{url: mkurl("git://github.com/sdboyer-/gps")}, maybeGitSource{url: mkurl("http://github.com/sdboyer-/gps")}, }, @@ -101,8 +101,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "github.com/a/gps/foo", root: "github.com/a/gps", mb: maybeSources{ - maybeGitSource{url: mkurl("ssh://git@github.com/a/gps")}, maybeGitSource{url: mkurl("https://github.com/a/gps")}, + maybeGitSource{url: mkurl("ssh://git@github.com/a/gps")}, maybeGitSource{url: mkurl("git://github.com/a/gps")}, maybeGitSource{url: mkurl("http://github.com/a/gps")}, }, @@ -125,8 +125,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "github.com/kr/pretty", root: "github.com/kr/pretty", mb: maybeSources{ - maybeGitSource{url: mkurl("ssh://git@github.com/kr/pretty")}, maybeGitSource{url: mkurl("https://github.com/kr/pretty")}, + maybeGitSource{url: mkurl("ssh://git@github.com/kr/pretty")}, maybeGitSource{url: mkurl("git://github.com/kr/pretty")}, maybeGitSource{url: mkurl("http://github.com/kr/pretty")}, }, @@ -244,11 +244,11 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "bitbucket.org/sdboyer/reporoot", root: "bitbucket.org/sdboyer/reporoot", mb: maybeSources{ - maybeHgSource{url: mkurl("ssh://hg@bitbucket.org/sdboyer/reporoot")}, maybeHgSource{url: mkurl("https://bitbucket.org/sdboyer/reporoot")}, + maybeHgSource{url: mkurl("ssh://hg@bitbucket.org/sdboyer/reporoot")}, maybeHgSource{url: mkurl("http://bitbucket.org/sdboyer/reporoot")}, - maybeGitSource{url: mkurl("ssh://git@bitbucket.org/sdboyer/reporoot")}, maybeGitSource{url: mkurl("https://bitbucket.org/sdboyer/reporoot")}, + maybeGitSource{url: mkurl("ssh://git@bitbucket.org/sdboyer/reporoot")}, maybeGitSource{url: mkurl("git://bitbucket.org/sdboyer/reporoot")}, maybeGitSource{url: mkurl("http://bitbucket.org/sdboyer/reporoot")}, }, @@ -257,11 +257,11 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "bitbucket.org/sdboyer/reporoot/foo/bar", root: "bitbucket.org/sdboyer/reporoot", mb: maybeSources{ - maybeHgSource{url: mkurl("ssh://hg@bitbucket.org/sdboyer/reporoot")}, maybeHgSource{url: mkurl("https://bitbucket.org/sdboyer/reporoot")}, + maybeHgSource{url: mkurl("ssh://hg@bitbucket.org/sdboyer/reporoot")}, maybeHgSource{url: mkurl("http://bitbucket.org/sdboyer/reporoot")}, - maybeGitSource{url: mkurl("ssh://git@bitbucket.org/sdboyer/reporoot")}, maybeGitSource{url: mkurl("https://bitbucket.org/sdboyer/reporoot")}, + maybeGitSource{url: mkurl("ssh://git@bitbucket.org/sdboyer/reporoot")}, maybeGitSource{url: mkurl("git://bitbucket.org/sdboyer/reporoot")}, maybeGitSource{url: mkurl("http://bitbucket.org/sdboyer/reporoot")}, }, @@ -279,8 +279,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "bitbucket.org/sdboyer/reporoot.git", root: "bitbucket.org/sdboyer/reporoot.git", mb: maybeSources{ - maybeGitSource{url: mkurl("ssh://git@bitbucket.org/sdboyer/reporoot.git")}, maybeGitSource{url: mkurl("https://bitbucket.org/sdboyer/reporoot.git")}, + maybeGitSource{url: mkurl("ssh://git@bitbucket.org/sdboyer/reporoot.git")}, maybeGitSource{url: mkurl("git://bitbucket.org/sdboyer/reporoot.git")}, maybeGitSource{url: mkurl("http://bitbucket.org/sdboyer/reporoot.git")}, }, @@ -296,8 +296,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "bitbucket.org/sdboyer/reporoot.hg", root: "bitbucket.org/sdboyer/reporoot.hg", mb: maybeSources{ - maybeHgSource{url: mkurl("ssh://hg@bitbucket.org/sdboyer/reporoot.hg")}, maybeHgSource{url: mkurl("https://bitbucket.org/sdboyer/reporoot.hg")}, + maybeHgSource{url: mkurl("ssh://hg@bitbucket.org/sdboyer/reporoot.hg")}, maybeHgSource{url: mkurl("http://bitbucket.org/sdboyer/reporoot.hg")}, }, }, @@ -321,8 +321,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "launchpad.net/govcstestbzrrepo", root: "launchpad.net/govcstestbzrrepo", mb: maybeSources{ - maybeBzrSource{url: mkurl("bzr+ssh://launchpad.net/govcstestbzrrepo")}, maybeBzrSource{url: mkurl("https://launchpad.net/govcstestbzrrepo")}, + maybeBzrSource{url: mkurl("bzr+ssh://launchpad.net/govcstestbzrrepo")}, maybeBzrSource{url: mkurl("bzr://launchpad.net/govcstestbzrrepo")}, maybeBzrSource{url: mkurl("http://launchpad.net/govcstestbzrrepo")}, }, @@ -331,8 +331,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "launchpad.net/govcstestbzrrepo/foo/bar", root: "launchpad.net/govcstestbzrrepo", mb: maybeSources{ - maybeBzrSource{url: mkurl("bzr+ssh://launchpad.net/govcstestbzrrepo")}, maybeBzrSource{url: mkurl("https://launchpad.net/govcstestbzrrepo")}, + maybeBzrSource{url: mkurl("bzr+ssh://launchpad.net/govcstestbzrrepo")}, maybeBzrSource{url: mkurl("bzr://launchpad.net/govcstestbzrrepo")}, maybeBzrSource{url: mkurl("http://launchpad.net/govcstestbzrrepo")}, }, @@ -347,8 +347,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "git.launchpad.net/reporoot", root: "git.launchpad.net/reporoot", mb: maybeSources{ - maybeGitSource{url: mkurl("ssh://git.launchpad.net/reporoot")}, maybeGitSource{url: mkurl("https://git.launchpad.net/reporoot")}, + maybeGitSource{url: mkurl("ssh://git.launchpad.net/reporoot")}, maybeGitSource{url: mkurl("git://git.launchpad.net/reporoot")}, maybeGitSource{url: mkurl("http://git.launchpad.net/reporoot")}, }, @@ -357,8 +357,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "git.launchpad.net/reporoot/foo/bar", root: "git.launchpad.net/reporoot", mb: maybeSources{ - maybeGitSource{url: mkurl("ssh://git.launchpad.net/reporoot")}, maybeGitSource{url: mkurl("https://git.launchpad.net/reporoot")}, + maybeGitSource{url: mkurl("ssh://git.launchpad.net/reporoot")}, maybeGitSource{url: mkurl("git://git.launchpad.net/reporoot")}, maybeGitSource{url: mkurl("http://git.launchpad.net/reporoot")}, }, @@ -373,8 +373,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "git.apache.org/package-name.git", root: "git.apache.org/package-name.git", mb: maybeSources{ - maybeGitSource{url: mkurl("ssh://git.apache.org/package-name.git")}, maybeGitSource{url: mkurl("https://git.apache.org/package-name.git")}, + maybeGitSource{url: mkurl("ssh://git.apache.org/package-name.git")}, maybeGitSource{url: mkurl("git://git.apache.org/package-name.git")}, maybeGitSource{url: mkurl("http://git.apache.org/package-name.git")}, }, @@ -383,8 +383,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "git.apache.org/package-name.git/foo/bar", root: "git.apache.org/package-name.git", mb: maybeSources{ - maybeGitSource{url: mkurl("ssh://git.apache.org/package-name.git")}, maybeGitSource{url: mkurl("https://git.apache.org/package-name.git")}, + maybeGitSource{url: mkurl("ssh://git.apache.org/package-name.git")}, maybeGitSource{url: mkurl("git://git.apache.org/package-name.git")}, maybeGitSource{url: mkurl("http://git.apache.org/package-name.git")}, }, @@ -396,8 +396,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "foobar.com/baz.git", root: "foobar.com/baz.git", mb: maybeSources{ - maybeGitSource{url: mkurl("ssh://foobar.com/baz")}, maybeGitSource{url: mkurl("https://foobar.com/baz")}, + maybeGitSource{url: mkurl("ssh://foobar.com/baz")}, maybeGitSource{url: mkurl("git://foobar.com/baz")}, maybeGitSource{url: mkurl("http://foobar.com/baz")}, }, @@ -406,8 +406,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "foobar.com/baz.git/extra/path", root: "foobar.com/baz.git", mb: maybeSources{ - maybeGitSource{url: mkurl("ssh://foobar.com/baz")}, maybeGitSource{url: mkurl("https://foobar.com/baz")}, + maybeGitSource{url: mkurl("ssh://foobar.com/baz")}, maybeGitSource{url: mkurl("git://foobar.com/baz")}, maybeGitSource{url: mkurl("http://foobar.com/baz")}, }, @@ -416,8 +416,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "foobar.com/baz.bzr", root: "foobar.com/baz.bzr", mb: maybeSources{ - maybeBzrSource{url: mkurl("bzr+ssh://foobar.com/baz")}, maybeBzrSource{url: mkurl("https://foobar.com/baz")}, + maybeBzrSource{url: mkurl("bzr+ssh://foobar.com/baz")}, maybeBzrSource{url: mkurl("bzr://foobar.com/baz")}, maybeBzrSource{url: mkurl("http://foobar.com/baz")}, }, @@ -426,8 +426,8 @@ var pathDeductionFixtures = map[string][]pathDeductionFixture{ in: "foo-bar.com/baz.hg", root: "foo-bar.com/baz.hg", mb: maybeSources{ - maybeHgSource{url: mkurl("ssh://foo-bar.com/baz")}, maybeHgSource{url: mkurl("https://foo-bar.com/baz")}, + maybeHgSource{url: mkurl("ssh://foo-bar.com/baz")}, maybeHgSource{url: mkurl("http://foo-bar.com/baz")}, }, },