Update other-tool integration w/new cfg structs
diff --git a/gb/gb.go b/gb/gb.go
index ea64258..2f5612b 100644
--- a/gb/gb.go
+++ b/gb/gb.go
@@ -9,6 +9,7 @@
"github.com/Masterminds/glide/msg"
gpath "github.com/Masterminds/glide/path"
"github.com/Masterminds/glide/util"
+ "github.com/sdboyer/gps"
)
// Has returns true if this dir has a GB-flavored manifest file.
@@ -44,26 +45,16 @@
seen := map[string]bool{}
for _, d := range man.Dependencies {
- pkg, sub := util.NormalizeName(d.Importpath)
- if _, ok := seen[pkg]; ok {
- if len(sub) == 0 {
- continue
- }
- for _, dep := range buf {
- if dep.Name == pkg {
- dep.Subpackages = append(dep.Subpackages, sub)
- }
- }
- } else {
+ // TODO(sdboyer) move to the corresponding SourceManager call...though
+ // that matters less once gps caches these results
+ pkg, _ := util.NormalizeName(d.Importpath)
+ if !seen[pkg] {
seen[pkg] = true
dep := &cfg.Dependency{
Name: pkg,
- Reference: d.Revision,
+ Constraint: cfg.DeduceConstraint(d.Revision),
Repository: d.Repository,
}
- if len(sub) > 0 {
- dep.Subpackages = []string{sub}
- }
buf = append(buf, dep)
}
}
@@ -94,16 +85,15 @@
for _, d := range man.Dependencies {
pkg, _ := util.NormalizeName(d.Importpath)
- if _, ok := seen[pkg]; ok {
+ if !seen[pkg] {
seen[pkg] = true
dep := &cfg.Dependency{
- Name: pkg,
- // TODO we have the branch info here - maybe we should use that
- Reference: "*",
+ Name: pkg,
+ Constraint: gps.Any(),
Repository: d.Repository,
}
m = append(m, dep)
- l.Imports = append(l.Imports, &cfg.Lock{Name: pkg, Version: d.Revision})
+ l.Imports = append(l.Imports, &cfg.Lock{Name: pkg, Revision: d.Revision})
}
}
return
diff --git a/godep/godep.go b/godep/godep.go
index 2b9ea41..82bc5e1 100644
--- a/godep/godep.go
+++ b/godep/godep.go
@@ -7,12 +7,12 @@
"encoding/json"
"os"
"path/filepath"
- "strings"
"github.com/Masterminds/glide/cfg"
"github.com/Masterminds/glide/msg"
gpath "github.com/Masterminds/glide/path"
"github.com/Masterminds/glide/util"
+ "github.com/sdboyer/gps"
)
// This file contains commands for working with Godep.
@@ -75,23 +75,10 @@
seen := map[string]bool{}
for _, d := range godeps.Deps {
- pkg, sub := util.NormalizeName(d.ImportPath)
- if _, ok := seen[pkg]; ok {
- if len(sub) == 0 {
- continue
- }
- // Modify existing dep with additional subpackages.
- for _, dep := range buf {
- if dep.Name == pkg {
- dep.Subpackages = append(dep.Subpackages, sub)
- }
- }
- } else {
+ pkg, _ := util.NormalizeName(d.ImportPath)
+ if !seen[pkg] {
seen[pkg] = true
- dep := &cfg.Dependency{Name: pkg, Reference: d.Rev}
- if sub != "" {
- dep.Subpackages = []string{sub}
- }
+ dep := &cfg.Dependency{Name: pkg, Constraint: gps.Revision(d.Rev)}
buf = append(buf, dep)
}
}
@@ -134,8 +121,8 @@
// This approach does make for an uncomfortably wide possibility
// space where deps aren't getting what they expect, but that's
// better than just having the solver give up completely.
- m = append(m, &cfg.Dependency{Name: pkg, Reference: "*"})
- l.Imports = append(l.Imports, &cfg.Lock{Name: pkg, Version: d.Rev})
+ m = append(m, &cfg.Dependency{Name: pkg, Constraint: gps.Any()})
+ l.Imports = append(l.Imports, &cfg.Lock{Name: pkg, Revision: d.Rev})
// TODO this fails to differentiate between dev and non-dev imports;
// need static analysis for that
@@ -144,29 +131,3 @@
return m, l, nil
}
-
-// RemoveGodepSubpackages strips subpackages from a cfg.Config dependencies that
-// contain "Godeps/_workspace/src" as part of the path.
-func RemoveGodepSubpackages(c *cfg.Config) *cfg.Config {
- for _, d := range c.Imports {
- n := []string{}
- for _, v := range d.Subpackages {
- if !strings.HasPrefix(v, "Godeps/_workspace/src") {
- n = append(n, v)
- }
- }
- d.Subpackages = n
- }
-
- for _, d := range c.DevImports {
- n := []string{}
- for _, v := range d.Subpackages {
- if !strings.HasPrefix(v, "Godeps/_workspace/src") {
- n = append(n, v)
- }
- }
- d.Subpackages = n
- }
-
- return c
-}
diff --git a/gom/gom.go b/gom/gom.go
index 05785e6..46f27d2 100644
--- a/gom/gom.go
+++ b/gom/gom.go
@@ -56,33 +56,21 @@
}
}
- pkg, sub := util.NormalizeName(gom.name)
+ pkg, _ := util.NormalizeName(gom.name)
dep := &cfg.Dependency{
Name: pkg,
}
- if len(sub) > 0 {
- dep.Subpackages = []string{sub}
- }
-
// Check for a specific revision
if val, ok := gom.options["commit"]; ok {
- dep.Reference = val.(string)
+ dep.Constraint = gps.Revision(val.(string))
}
if val, ok := gom.options["tag"]; ok {
- dep.Reference = val.(string)
+ dep.Constraint = gps.NewVersion(val.(string))
}
if val, ok := gom.options["branch"]; ok {
- dep.Reference = val.(string)
- }
-
- // Parse goos and goarch
- if val, ok := gom.options["goos"]; ok {
- dep.Os = toStringSlice(val)
- }
- if val, ok := gom.options["goarch"]; ok {
- dep.Arch = toStringSlice(val)
+ dep.Constraint = gps.NewBranch(val.(string))
}
buf = append(buf, dep)
diff --git a/gpm/gpm.go b/gpm/gpm.go
index 00ca864..0f6c8ef 100644
--- a/gpm/gpm.go
+++ b/gpm/gpm.go
@@ -13,6 +13,7 @@
"github.com/Masterminds/glide/cfg"
"github.com/Masterminds/glide/msg"
gpath "github.com/Masterminds/glide/path"
+ "github.com/sdboyer/gps"
)
// Has indicates whether a Godeps file exists.
@@ -46,7 +47,7 @@
if ok {
dep := &cfg.Dependency{Name: parts[0]}
if len(parts) > 1 {
- dep.Reference = parts[1]
+ dep.Constraint = cfg.DeduceConstraint(parts[1])
}
buf = append(buf, dep)
}
@@ -84,7 +85,7 @@
if len(parts) > 1 {
l.Imports = append(l.Imports, &cfg.Lock{Name: parts[0], Version: parts[1]})
}
- m = append(m, &cfg.Dependency{Name: parts[0], Reference: "*"})
+ m = append(m, &cfg.Dependency{Name: parts[0], Constraint: gps.Any()})
}
}
if err := scanner.Err(); err != nil {