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

Commit

Permalink
gvt importer imports gb-vendor too
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-go committed Sep 16, 2017
1 parent 5a0c5f9 commit a7eff3c
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/dep/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ specified, use the current directory.
When configuration for another dependency management tool is detected, it is
imported into the initial manifest and lock. Use the -skip-tools flag to
disable this behavior. The following external tools are supported:
glide, godep, vndr, govend, gvt.
glide, godep, vndr, govend, gb, gvt.
Any dependencies that are not constrained by external configuration use the
GOPATH analysis below.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"importpath": "github.com/sdboyer/deptest",
"repository": "https://github.com/sdboyer/deptest",
"revision": "3f4c3bea144e112a69bbe5d8d01c1b09a544253f",
"branch": "master"
"branch": "HEAD"
},
{
"importpath": "github.com/sdboyer/deptestdos",
Expand Down
2 changes: 1 addition & 1 deletion docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ about what's going on.
During `dep init` configuration from other dependency managers is detected
and imported, unless `-skip-tools` is specified.

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

See [#186](https://github.com/golang/dep/issues/186#issuecomment-306363441) for
how to add support for another tool.
Expand Down
10 changes: 8 additions & 2 deletions internal/importers/gvt/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (g *Importer) Import(dir string, pr gps.ProjectRoot) (*dep.Manifest, *dep.L
}

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

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

Expand Down
18 changes: 17 additions & 1 deletion internal/importers/gvt/importer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ func TestGvtConfig_Convert(t *testing.T) {
},
},
},
"package with HEAD branch": {
importertest.TestCase{
WantConstraint: "*",
WantRevision: importertest.V1Rev,
WantVersion: importertest.V1Tag,
},
gvtManifest{
Deps: []gvtPkg{
{
ImportPath: importertest.Project,
Revision: importertest.V1Rev,
Branch: "HEAD",
},
},
},
},
"missing package name": {
importertest.TestCase{
WantConvertErr: true,
Expand Down Expand Up @@ -151,7 +167,7 @@ func TestGvtConfig_JsonLoad(t *testing.T) {
{
ImportPath: "github.com/sdboyer/deptest",
Revision: "3f4c3bea144e112a69bbe5d8d01c1b09a544253f",
Branch: "master",
Branch: "HEAD",
},
{
ImportPath: "github.com/sdboyer/deptestdos",
Expand Down
4 changes: 2 additions & 2 deletions internal/importers/gvt/testdata/golden.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Detected gvt configuration files...
Detected gb/gvt configuration files...
Converting from vendor/manifest ...
Using ^0.8.1 as initial constraint for imported dep github.com/sdboyer/deptest
Using * as initial constraint for imported dep github.com/sdboyer/deptest
Trying v0.8.1 (3f4c3be) as initial lock for imported dep github.com/sdboyer/deptest
Using ^2.0.0 as initial constraint for imported dep github.com/sdboyer/deptestdos
Trying v2.0.0 (5c60720) as initial lock for imported dep github.com/sdboyer/deptestdos
Expand Down
6 changes: 4 additions & 2 deletions internal/importers/gvt/testdata/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
"dependencies": [
{
"importpath": "github.com/sdboyer/deptest",
"revision": "3f4c3bea144e112a69bbe5d8d01c1b09a544253f"
"revision": "3f4c3bea144e112a69bbe5d8d01c1b09a544253f",
"branch": "HEAD"
},
{
"importpath": "github.com/sdboyer/deptestdos",
"revision": "5c607206be5decd28e6263ffffdcee067266015e"
"revision": "5c607206be5decd28e6263ffffdcee067266015e",
"branch": "master"
},
{
"importpath": "github.com/carolynvs/deptest-importers",
Expand Down

0 comments on commit a7eff3c

Please sign in to comment.