Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 956f34d

Browse files
committed
gvt importer imports gb-vendor too
1 parent 28f55f7 commit 956f34d

File tree

7 files changed

+34
-10
lines changed

7 files changed

+34
-10
lines changed

cmd/dep/init.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ specified, use the current directory.
2929
When configuration for another dependency management tool is detected, it is
3030
imported into the initial manifest and lock. Use the -skip-tools flag to
3131
disable this behavior. The following external tools are supported:
32-
glide, godep, vndr, govend, gvt.
32+
glide, godep, vndr, govend, gb, gvt.
3333
3434
Any dependencies that are not constrained by external configuration use the
3535
GOPATH analysis below.

cmd/dep/testdata/harness_tests/init/gvt/case1/initial/vendor/manifest

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"importpath": "github.com/sdboyer/deptest",
66
"repository": "https://github.com/sdboyer/deptest",
77
"revision": "3f4c3bea144e112a69bbe5d8d01c1b09a544253f",
8-
"branch": "master"
8+
"branch": "HEAD"
99
},
1010
{
1111
"importpath": "github.com/sdboyer/deptestdos",

docs/FAQ.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ about what's going on.
210210
During `dep init` configuration from other dependency managers is detected
211211
and imported, unless `-skip-tools` is specified.
212212

213-
The following tools are supported: `glide`, `godep`, `vndr`, `govend` and `gvt`.
213+
The following tools are supported: `glide`, `godep`, `vndr`, `govend`, `gb` and `gvt`.
214214

215215
See [#186](https://github.com/golang/dep/issues/186#issuecomment-306363441) for
216216
how to add support for another tool.

internal/importers/gvt/importer.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (g *Importer) Import(dir string, pr gps.ProjectRoot) (*dep.Manifest, *dep.L
6767
}
6868

6969
func (g *Importer) load(projectDir string) error {
70-
g.Logger.Println("Detected gvt configuration files...")
70+
g.Logger.Println("Detected gb/gvt configuration files...")
7171
j := filepath.Join(projectDir, gvtPath)
7272
if g.Verbose {
7373
g.Logger.Printf(" Loading %s", j)
@@ -101,7 +101,13 @@ func (g *Importer) convert(pr gps.ProjectRoot) (*dep.Manifest, *dep.Lock, error)
101101
}
102102

103103
var contstraintHint = ""
104-
if pkg.Branch != "master" {
104+
if pkg.Branch == "HEAD" {
105+
// gb-vendor sets "branch" to "HEAD", if the package was feteched via -tag or -revision,
106+
// we we pass the revision as the constraint hint
107+
contstraintHint = pkg.Revision
108+
} else if pkg.Branch != "master" {
109+
// both gvt & gb-vendor set "branch" to "master" unless a different branch was requested.
110+
// so it's not realy a constraint unless it's a different branch
105111
contstraintHint = pkg.Branch
106112
}
107113

internal/importers/gvt/importer_test.go

+17-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ func TestGvtConfig_Convert(t *testing.T) {
5454
},
5555
},
5656
},
57+
"package with HEAD branch": {
58+
importertest.TestCase{
59+
WantConstraint: "*",
60+
WantRevision: importertest.V1Rev,
61+
WantVersion: importertest.V1Tag,
62+
},
63+
gvtManifest{
64+
Deps: []gvtPkg{
65+
{
66+
ImportPath: importertest.Project,
67+
Revision: importertest.V1Rev,
68+
Branch: "HEAD",
69+
},
70+
},
71+
},
72+
},
5773
"missing package name": {
5874
importertest.TestCase{
5975
WantConvertErr: true,
@@ -151,7 +167,7 @@ func TestGvtConfig_JsonLoad(t *testing.T) {
151167
{
152168
ImportPath: "github.com/sdboyer/deptest",
153169
Revision: "3f4c3bea144e112a69bbe5d8d01c1b09a544253f",
154-
Branch: "master",
170+
Branch: "HEAD",
155171
},
156172
{
157173
ImportPath: "github.com/sdboyer/deptestdos",

internal/importers/gvt/testdata/golden.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Detected gvt configuration files...
1+
Detected gb/gvt configuration files...
22
Converting from vendor/manifest ...
3-
Using ^0.8.1 as initial constraint for imported dep github.com/sdboyer/deptest
3+
Using * as initial constraint for imported dep github.com/sdboyer/deptest
44
Trying v0.8.1 (3f4c3be) as initial lock for imported dep github.com/sdboyer/deptest
55
Using ^2.0.0 as initial constraint for imported dep github.com/sdboyer/deptestdos
66
Trying v2.0.0 (5c60720) as initial lock for imported dep github.com/sdboyer/deptestdos

internal/importers/gvt/testdata/manifest

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
"dependencies": [
33
{
44
"importpath": "github.com/sdboyer/deptest",
5-
"revision": "3f4c3bea144e112a69bbe5d8d01c1b09a544253f"
5+
"revision": "3f4c3bea144e112a69bbe5d8d01c1b09a544253f",
6+
"branch": "HEAD"
67
},
78
{
89
"importpath": "github.com/sdboyer/deptestdos",
9-
"revision": "5c607206be5decd28e6263ffffdcee067266015e"
10+
"revision": "5c607206be5decd28e6263ffffdcee067266015e",
11+
"branch": "master"
1012
},
1113
{
1214
"importpath": "github.com/carolynvs/deptest-importers",

0 commit comments

Comments
 (0)