Merge pull request #240 from Masterminds/feat/resolve-imports
Resolve the imports being used
diff --git a/LICENSE b/LICENSE
index 5af85b0..f342051 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
Glide
The Masterminds
-Copyright (C) 2014-2015, Matt Butcher and Matt Farina
+Copyright (C) 2014-2016, Matt Butcher and Matt Farina
Copyright (C) 2015, Google
Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/action/create.go b/action/create.go
index d08857d..5a8d6c4 100644
--- a/action/create.go
+++ b/action/create.go
@@ -121,30 +121,22 @@
for _, pa := range sortable {
n := strings.TrimPrefix(pa, vpath)
- root := util.GetRootFromPackage(n)
+ root, subpkg := util.NormalizeName(n)
if !config.HasDependency(root) {
msg.Info("Found reference to %s\n", n)
d := &cfg.Dependency{
Name: root,
}
- subpkg := strings.TrimPrefix(n, root)
- if len(subpkg) > 0 && subpkg != "/" {
+ if len(subpkg) > 0 {
d.Subpackages = []string{subpkg}
}
config.Imports = append(config.Imports, d)
} else {
- subpkg := strings.TrimPrefix(n, root)
- if len(subpkg) > 0 && subpkg != "/" {
+ if len(subpkg) > 0 {
subpkg = strings.TrimPrefix(subpkg, "/")
d := config.Imports.Get(root)
- f := false
- for _, v := range d.Subpackages {
- if v == subpkg {
- f = true
- }
- }
- if !f {
+ if !d.HasSubpackage(subpkg) {
msg.Info("Adding sub-package %s to %s\n", subpkg, root)
d.Subpackages = append(d.Subpackages, subpkg)
}
diff --git a/action/get.go b/action/get.go
index ce20e84..38e6547 100644
--- a/action/get.go
+++ b/action/get.go
@@ -108,7 +108,7 @@
version = parts[1]
}
- root := util.GetRootFromPackage(name)
+ root, subpkg := util.NormalizeName(name)
if len(root) == 0 {
return fmt.Errorf("Package name is required for %q.", name)
}
@@ -116,18 +116,9 @@
if conf.HasDependency(root) {
// Check if the subpackage is present.
- subpkg := strings.TrimPrefix(name, root)
- subpkg = strings.TrimPrefix(subpkg, "/")
if subpkg != "" {
- found := false
dep := conf.Imports.Get(root)
- for _, s := range dep.Subpackages {
- if s == subpkg {
- found = true
- break
- }
- }
- if found {
+ if dep.HasSubpackage(subpkg) {
msg.Warn("Package %q is already in glide.yaml. Skipping", name)
} else {
dep.Subpackages = append(dep.Subpackages, subpkg)
@@ -158,9 +149,8 @@
dep.Repository = "http://" + root
}
- subpkg := strings.TrimPrefix(name, root)
- if len(subpkg) > 0 && subpkg != "/" {
- dep.Subpackages = []string{strings.TrimPrefix(subpkg, "/")}
+ if len(subpkg) > 0 {
+ dep.Subpackages = []string{subpkg}
}
if dep.Reference != "" {
diff --git a/action/import_godep.go b/action/import_godep.go
index 0c626d3..aafacbb 100644
--- a/action/import_godep.go
+++ b/action/import_godep.go
@@ -5,7 +5,7 @@
"github.com/Masterminds/glide/msg"
)
-// ImportGodep imports a GPM file.
+// ImportGodep imports a Godep file.
func ImportGodep(dest string) {
base := "."
config := EnsureConfig()
diff --git a/cfg/cfg.go b/cfg/cfg.go
index 52874d2..b491b49 100644
--- a/cfg/cfg.go
+++ b/cfg/cfg.go
@@ -1,2 +1,59 @@
// Package cfg handles working with the Glide configuration files.
+//
+// The cfg package contains the ability to parse (unmarshal) and write (marshal)
+// glide.yaml and glide.lock files. These files contains the details about
+// projects managed by Glide.
+//
+// To convert yaml into a cfg.Config instance use the cfg.ConfigFromYaml function.
+// The yaml, typically in a glide.yaml file, has the following structure.
+//
+// package: github.com/Masterminds/glide
+// homepage: https://masterminds.github.io/glide
+// license: MIT
+// owners:
+// - name: Matt Butcher
+// email: technosophos@gmail.com
+// homepage: http://technosophos.com
+// - name: Matt Farina
+// email: matt@mattfarina.com
+// homepage: https://www.mattfarina.com
+// ignore:
+// - appengine
+// import:
+// - package: gopkg.in/yaml.v2
+// - package: github.com/Masterminds/vcs
+// version: ^1.2.0
+// repo: git@github.com:Masterminds/vcs
+// vcs: git
+// - package: github.com/codegangsta/cli
+// - package: github.com/Masterminds/semver
+// version: ^1.0.0
+//
+// These elements are:
+//
+// - package: The top level package is the location in the GOPATH. This is used
+// for things such as making sure an import isn't also importing the top level
+// package.
+// - homepage: To find the place where you can find details about the package or
+// applications. For example, http://k8s.io
+// - license: The license is either an SPDX license string or the filepath to the
+// license. This allows automation and consumers to easily identify the license.
+// - owners: The owners is a list of one or more owners for the project. This
+// can be a person or organization and is useful for things like notifying the
+// owners of a security issue without filing a public bug.
+// - ignore: A list of packages for Glide to ignore importing. These are package
+// names to ignore rather than directories.
+// - import: A list of packages to import. Each package can include:
+// - package: The name of the package to import and the only non-optional item.
+// - version: A semantic version, semantic version range, branch, tag, or
+// commit id to use.
+// - repo: If the package name isn't the repo location or this is a private
+// repository it can go here. The package will be checked out from the
+// repo and put where the package name specifies. This allows using forks.
+// - vcs: A VCS to use such as git, hg, bzr, or svn. This is only needed
+// when the type cannot be detected from the name. For example, a repo
+// ending in .git or on GitHub can be detected to be Git. For a repo on
+// Bitbucket we can contact the API to discover the type.
+// - devImport: A list of development packages. Each package has the same details
+// as those lised under import.
package cfg
diff --git a/cfg/config.go b/cfg/config.go
index cca4072..de189eb 100644
--- a/cfg/config.go
+++ b/cfg/config.go
@@ -14,18 +14,52 @@
// Config is the top-level configuration object.
type Config struct {
- Name string `yaml:"package"`
- Ignore []string `yaml:"ignore,omitempty"`
- Imports Dependencies `yaml:"import"`
+
+ // Name is the name of the package or application.
+ Name string `yaml:"package"`
+
+ // Description is a short description for a package, application, or library.
+ // This description is similar but different to a Go package description as
+ // it is for marketing and presentation purposes rather than technical ones.
+ Description string `json:"description,omitempty"`
+
+ // Home is a url to a website for the package.
+ Home string `yaml:"homepage,omitempty"`
+
+ // License provides either a SPDX license or a path to a file containing
+ // the license. For more information on SPDX see http://spdx.org/licenses/.
+ // When more than one license an SPDX expression can be used.
+ License string `yaml:"license,omitempty"`
+
+ // Owners is an array of owners for a project. See the Owner type for
+ // more detail. These can be one or more people, companies, or other
+ // organizations.
+ Owners Owners `yaml:"owners,omitempty"`
+
+ // Ignore contains a list of packages to ignore fetching. This is useful
+ // when walking the package tree (including packages of packages) to list
+ // those to skip.
+ Ignore []string `yaml:"ignore,omitempty"`
+
+ // Imports contains a list of all non-development imports for a project. For
+ // more detail on how these are captured see the Dependency type.
+ Imports Dependencies `yaml:"import"`
+
+ // DevImports contains the test or other development imports for a project.
+ // See the Dependency type for more details on how this is recorded.
DevImports Dependencies `yaml:"devimport,omitempty"`
}
// A transitive representation of a dependency for importing and exporting to yaml.
type cf struct {
- Name string `yaml:"package"`
- Ignore []string `yaml:"ignore,omitempty"`
- Imports Dependencies `yaml:"import"`
- DevImports Dependencies `yaml:"devimport,omitempty"`
+ Name string `yaml:"package"`
+ Description string `yaml:"description,omitempty"`
+ Home string `yaml:"homepage,omitempty"`
+ License string `yaml:"license,omitempty"`
+ Owners Owners `yaml:"owners,omitempty"`
+ Ignore []string `yaml:"ignore,omitempty"`
+ Imports Dependencies `yaml:"import"`
+ DevImports Dependencies `yaml:"devimport,omitempty"`
}
// ConfigFromYaml returns an instance of Config from YAML
@@ -51,6 +85,10 @@
return err
}
c.Name = newConfig.Name
+ c.Description = newConfig.Description
+ c.Home = newConfig.Home
+ c.License = newConfig.License
+ c.Owners = newConfig.Owners
c.Ignore = newConfig.Ignore
c.Imports = newConfig.Imports
c.DevImports = newConfig.DevImports
@@ -64,8 +102,12 @@
// MarshalYAML is a hook for gopkg.in/yaml.v2 in the marshaling process
func (c *Config) MarshalYAML() (interface{}, error) {
newConfig := &cf{
- Name: c.Name,
- Ignore: c.Ignore,
+ Name: c.Name,
+ Description: c.Description,
+ Home: c.Home,
+ License: c.License,
+ Owners: c.Owners,
+ Ignore: c.Ignore,
}
i, err := c.Imports.Clone().DeDupe()
if err != nil {
@@ -116,6 +158,10 @@
func (c *Config) Clone() *Config {
n := &Config{}
n.Name = c.Name
+ n.Description = c.Description
+ n.Home = c.Home
+ n.License = c.License
+ n.Owners = c.Owners.Clone()
n.Ignore = c.Ignore
n.Imports = c.Imports.Clone()
n.DevImports = c.DevImports.Clone()
@@ -320,11 +366,10 @@
d.VcsType = filterVcsType(d.VcsType)
// Get the root name for the package
- o := d.Name
- d.Name = util.GetRootFromPackage(d.Name)
- subpkg := strings.TrimPrefix(o, d.Name)
- if len(subpkg) > 0 && subpkg != "/" {
- d.Subpackages = append(d.Subpackages, strings.TrimPrefix(subpkg, "/"))
+ tn, subpkg := util.NormalizeName(d.Name)
+ d.Name = tn
+ if subpkg != "" {
+ d.Subpackages = append(d.Subpackages, subpkg)
}
return nil
@@ -408,6 +453,42 @@
return false
}
+// Owners is a list of owners for a project.
+type Owners []*Owner
+
+// Clone performs a deep clone of Owners
+func (o Owners) Clone() Owners {
+ n := make(Owners, 0, 1)
+ for _, v := range o {
+ n = append(n, v.Clone())
+ }
+ return n
+}
+
+// Owner describes an owner of a package. This can be a person, company, or
+// other organization. This is useful if someone needs to contact the
+// owner of a package to address things like a security issue.
+type Owner struct {
+
+ // Name describes the name of an organization.
+ Name string `yaml:"name,omitempty"`
+
+ // Email is an email address to reach the owner at.
+ Email string `yaml:"email,omitempty"`
+
+ // Home is a url to a website for the owner.
+ Home string `yaml:"homepage,omitempty"`
+}
+
+// Clone creates a clone of a Dependency
+func (o *Owner) Clone() *Owner {
+ return &Owner{
+ Name: o.Name,
+ Email: o.Email,
+ Home: o.Home,
+ }
+}
+
func stringArrayDeDupe(s []string, items ...string) []string {
for _, item := range items {
exists := false
diff --git a/cfg/config_test.go b/cfg/config_test.go
index 03ba08e..06ade6d 100644
--- a/cfg/config_test.go
+++ b/cfg/config_test.go
@@ -8,6 +8,13 @@
var yml = `
package: fake/testing
+description: foo bar baz
+homepage: https://example.com
+license: MIT
+owners:
+- name: foo
+ email: bar@example.com
+ homepage: https://example.com
import:
- package: github.com/kylelemons/go-gypsy
subpackages:
@@ -45,6 +52,18 @@
t.Errorf("Inaccurate name found %s", cfg.Name)
}
+ if cfg.Description != "foo bar baz" {
+ t.Errorf("Inaccurate description found %s", cfg.Description)
+ }
+
+ if cfg.Home != "https://example.com" {
+ t.Errorf("Inaccurate homepage found %s", cfg.Home)
+ }
+
+ if cfg.License != "MIT" {
+ t.Errorf("Inaccurate license found %s", cfg.License)
+ }
+
found := false
found2 := false
for _, i := range cfg.Imports {
@@ -82,6 +101,9 @@
if cfg2.Name != "fake/testing" {
t.Error("Config cloning failed")
}
+ if cfg2.License != "MIT" {
+ t.Error("Config cloning failed to copy License")
+ }
cfg.Name = "foo"
if cfg.Name == cfg2.Name {
@@ -114,3 +136,43 @@
t.Error("HasDependency picking up dependency it shouldn't")
}
}
+
+func TestOwners(t *testing.T) {
+ o := new(Owner)
+ o.Name = "foo"
+ o.Email = "foo@example.com"
+ o.Home = "https://foo.example.com"
+
+ o2 := o.Clone()
+ if o2.Name != o.Name || o2.Email != o.Email || o2.Home != o.Home {
+ t.Error("Unable to clone Owner")
+ }
+
+ o.Name = "Bar"
+ if o.Name == o2.Name {
+ t.Error("Owner clone is a pointer instead of a clone")
+ }
+
+ s := make(Owners, 0, 1)
+ s = append(s, o)
+ s2 := s.Clone()
+ o3 := s2[0]
+
+ o3.Name = "Qux"
+
+ if o3.Name == o.Name {
+ t.Error("Owners cloning isn't deep")
+ }
+
+ cfg := &Config{}
+ err := yaml.Unmarshal([]byte(yml), &cfg)
+ if err != nil {
+ t.Errorf("Unable to Unmarshal config yaml")
+ }
+
+ if cfg.Owners[0].Name != "foo" ||
+ cfg.Owners[0].Email != "bar@example.com" ||
+ cfg.Owners[0].Home != "https://example.com" {
+ t.Error("Unable to parse owners from yaml")
+ }
+}
diff --git a/docs/getting-started.md b/docs/getting-started.md
new file mode 100644
index 0000000..6626ffa
--- /dev/null
+++ b/docs/getting-started.md
@@ -0,0 +1,57 @@
+# Getting Started With Glide
+
+This is a quick start guide to using Glide once you have it installed.
+
+## Initially Detecting Project Dependencies
+
+Glide can detect the dependencies in use on a project and create an initial `glide.yaml` file for you. This detection can import the configuration from Godep, GPM, and GB. To do this change into the top level directory for the project and run:
+
+ $ glide init
+
+When this is complete you'll have a `glide.yaml` file populated with the projects being used. You can open up this file and even edit it to add information such as versions.
+
+## Updating Dependencies
+
+To fetch the dependencies and set them to any versions specified in the `glide.yaml` file use the following command:
+
+ $ glide up
+
+The `up` is short for `update`. This will fetch any dependencies specified in the `glide.yaml` file, walk the dependency tree to make sure any dependencies of the dependencies are fetched, and set them to the proper version. While walking the tree it will make sure versions are set and configuration from Godep, GPM, and GB is imported.
+
+The fetched dependencies are all placed in the `vendor/` folder at the root of the project. The `go` toolchain will use the dependencies here prior to looking in the `GOPATH` or `GOROOT` if you are using Go 1.6+ or Go 1.5 with the Go 1.5 Vendor Experiment enabled.
+
+Glide will then create a `glide.lock` file. This file contains the entire dependency tree pinned to specific commit ids. This file, as we'll see in a moment, can be used to recreate the exact dependency tree and versions used.
+
+### Dependency Flattening
+
+All of the dependencies Glide fetches are into the top level `vendor/` folder for a project. Go provides the ability for each package to have a `vendor/` folder. Glide only uses a top level folder for two reasons:
+
+1. Each import location will be compiled into the binary. If the same dependency is imported into three `vendor/` folders it will be in the compiled binary tree times. This can quickly lead to binary bloat.
+2. Instances of types created in a dependency in one `vendor/` folder are not compatible with the same dependency in other locations. Even if they are the same version. Go sees them as different packages because they are in different locations. This is a problem for database drivers, loggers, and many other things. If you [try to pass an instance created from one location of a package to another you'll encounter errors](https://github.com/mattfarina/golang-broken-vendor).
+
+## Installing Dependencies
+
+If you want to install the dependencies needed by a project use the `install` command like so:
+
+ $ glide install
+
+This command does one of two things:
+
+* If a `glide.lock` file is present it retrieves, if missing from the `vendor/` folder, the dependency and sets it to the exact version in the `glide.lock` file. The dependencies are fetched and versions set concurrently so this operation is fairly quick.
+* If there is no `glide.lock` file then an `update` will be performed.
+
+If you're not managing the dependency versions for a project but need to install the dependencies you should use the `install` command.
+
+## Adding More Dependencies
+
+Glide can help you add more dependencies to the `glide.yaml` file with the `get` command.
+
+ $ glide get github.com/Masterminds/semver
+
+The `get` command is similar to `go get` but instead fetches dependencies into the `vendor/` folder and adds them to the `glide.yaml` file. This command can take one or more dependencies to fetch.
+
+The `get` command can also work with versions.
+
+ $ glide get github.com/Masterminds/semver#~1.2.0
+
+The `#` is used as a separator between the dependency name and a version to use. The version can be a semantic version, version range, branch, tag, or commit id.
diff --git a/docs/index.md b/docs/index.md
new file mode 100644
index 0000000..b7449db
--- /dev/null
+++ b/docs/index.md
@@ -0,0 +1,21 @@
+# Glide: Vendor Package Management for Go
+
+Glide is a package manager for [Go](https://golang.org) that is conceptually similar to package managers for other languages such as Cargo for Rust, NPM for Node.js, Pip for Python, Bundler for Ruby, and so forth.
+
+Glide provides the following functionality:
+
+* Records dependency information in a `glide.yaml` file. This includes a name, version or version range, version control information for private repos or when the type cannot be detected, and more.
+* Tracks the specific revision each package is locked to in a `glide.lock` file. This enables reproducibly featching the dependency tree.
+* Works with Semantic Versions and Semantic Version ranges.
+* Supports Git, Bzr, HG, and SVN. These are the same version control systems supported by `go get`.
+* Utilizes `vendor/` directories, known as the Vendor Experiment, so that different projects can have differing versions of the same dependencies.
+* Allows for aliasing packages which is useful for working with forks.
+* Import configuration from Godep, GPM, and GB.
+
+## Installing Glide
+
+There are a few ways to install Glide.
+
+1. Download a [versioned release](https://github.com/Masterminds/glide/releases). Glide releases are semantically versioned.
+2. Use a system package manager to install Glide. For example, using `brew install glide` can be used if you're using [Homebrew](http://brew.sh) on Mac.
+3. The latest development snapshot can be installed with `go get`. For example, `go get -u github.com/Masterminds/glide`. This is not a release version.
diff --git a/glide.go b/glide.go
index ade25c9..714da14 100644
--- a/glide.go
+++ b/glide.go
@@ -40,6 +40,7 @@
"path/filepath"
"github.com/Masterminds/glide/action"
+ "github.com/Masterminds/glide/msg"
gpath "github.com/Masterminds/glide/path"
"github.com/Masterminds/glide/repo"
@@ -111,7 +112,18 @@
app.Before = startup
app.Commands = commands()
- app.Run(os.Args)
+ // Detect errors from the Before and After calls and exit on them.
+ if err := app.Run(os.Args); err != nil {
+ msg.Error(err.Error())
+ os.Exit(1)
+ }
+
+ // If there was a Error message exit non-zero.
+ if msg.HasErrored() {
+ m := msg.Color(msg.Red, "An Error has occured")
+ msg.Msg(m)
+ os.Exit(2)
+ }
}
func commands() []cli.Command {
diff --git a/glide.lock b/glide.lock
index 3ff76ad..ef461c7 100644
--- a/glide.lock
+++ b/glide.lock
@@ -1,12 +1,12 @@
-hash: 4cf59f8e61ae7034d3296c0c7528aaf8784800008814fb02410cbb3ea9b34175
-updated: 2016-01-21T11:19:37.465408253-05:00
+hash: 1d4d06656329894abc78c0ac256169337c947260b784fee7ed02a0e405c0f63b
+updated: 2016-01-28T11:15:09.190330904-05:00
imports:
- name: github.com/codegangsta/cli
version: c31a7975863e7810c92e2e288a9ab074f9a88f29
- name: github.com/Masterminds/semver
version: 513f3dcb3ecfb1248831fb5cb06a23a3cd5935dc
- name: github.com/Masterminds/vcs
- version: eaee272c8fa4514e1572e182faecff5be20e792a
+ version: 4e0f9d754b04dbb4fc9a62aa5ef6bf22ee0937a8
- name: gopkg.in/yaml.v2
version: f7716cbe52baa25d2e9b0d0da546fcf909fc16b4
devImports: []
diff --git a/glide.yaml b/glide.yaml
index 611d71c..09401c9 100644
--- a/glide.yaml
+++ b/glide.yaml
@@ -1,4 +1,13 @@
package: github.com/Masterminds/glide
+homepage: https://github.com/Masterminds/glide
+license: MIT
+owners:
+- name: Matt Butcher
+ email: technosophos@gmail.com
+ homepage: http://technosophos.com/
+- name: Matt Farina
+ email: matt@mattfarina.com
+ homepage: https://www.mattfarina.com/
import:
- package: gopkg.in/yaml.v2
- package: github.com/Masterminds/vcs
diff --git a/godep/godep.go b/godep/godep.go
index b39deca..6785a0d 100644
--- a/godep/godep.go
+++ b/godep/godep.go
@@ -8,7 +8,6 @@
"encoding/json"
"os"
"path/filepath"
- "strings"
"github.com/Masterminds/glide/cfg"
"github.com/Masterminds/glide/msg"
@@ -74,9 +73,7 @@
seen := map[string]bool{}
for _, d := range godeps.Deps {
- pkg := util.GetRootFromPackage(d.ImportPath)
- sub := strings.TrimPrefix(d.ImportPath, pkg)
- sub = strings.TrimPrefix(sub, "/")
+ pkg, sub := util.NormalizeName(d.ImportPath)
if _, ok := seen[pkg]; ok {
if len(sub) == 0 {
continue
@@ -90,7 +87,7 @@
} else {
seen[pkg] = true
dep := &cfg.Dependency{Name: pkg, Reference: d.Rev}
- if len(sub) > 0 {
+ if sub != "" {
dep.Subpackages = []string{sub}
}
buf = append(buf, dep)
diff --git a/mkdocs.yml b/mkdocs.yml
new file mode 100644
index 0000000..5b994bb
--- /dev/null
+++ b/mkdocs.yml
@@ -0,0 +1,5 @@
+site_name: Glide Documentation
+pages:
+- Home: index.md
+- Getting Started: getting-started.md
+theme: readthedocs
diff --git a/msg/msg.go b/msg/msg.go
index 880afb5..7c9f705 100644
--- a/msg/msg.go
+++ b/msg/msg.go
@@ -33,6 +33,9 @@
// The default exit code to use when dyping
ecode int
+
+ // If an error was been sent.
+ hasErrored bool
}
// NewMessanger creates a default Messanger to display output.
@@ -96,6 +99,7 @@
func (m *Messanger) Error(msg string, args ...interface{}) {
prefix := m.Color(Red, "[ERROR] ")
m.Msg(prefix+msg, args...)
+ m.hasErrored = true
}
// Error logs and error using the Default Messanger
@@ -212,3 +216,25 @@
func Print(msg string) {
Default.Print(msg)
}
+
+// HasErrored returns if Error has been called.
+//
+// This is useful if you want to known if Error was called to exit with a
+// non-zero exit code.
+func (m *Messanger) HasErrored() bool {
+ return m.hasErrored
+}
+
+// HasErrored returns if Error has been called on the Default Messanger.
+//
+// This is useful if you want to known if Error was called to exit with a
+// non-zero exit code.
+func HasErrored() bool {
+ return Default.HasErrored()
+}
+
+// Color returns a string in a certain color if colors are enabled and
+// available on that platform.
+func Color(code, msg string) string {
+ return Default.Color(code, msg)
+}
diff --git a/repo/installer.go b/repo/installer.go
index e7b37da..305f870 100644
--- a/repo/installer.go
+++ b/repo/installer.go
@@ -468,14 +468,16 @@
} else if v.Reference != "" && dep.Reference != "" && v.Reference != dep.Reference {
dest := filepath.Join(d.Destination, filepath.FromSlash(v.Name))
dep = determineDependency(v, dep, dest)
+ } else {
+ dep = v
}
+ } else if v != nil {
+ dep = v
} else if dep != nil {
// We've got an imported dependency to use and don't already have a
// record of it. Append it to the Imports.
d.Config.Imports = append(d.Config.Imports, dep)
- } else if v != nil {
- dep = v
} else {
// If we've gotten here we don't have any depenency objects.
r, sp := util.NormalizeName(pkg)
diff --git a/repo/vcs.go b/repo/vcs.go
index d2a5d5d..6a3421c 100644
--- a/repo/vcs.go
+++ b/repo/vcs.go
@@ -268,6 +268,7 @@
}
// Having found a repo we copy it to vendor and update it.
+ msg.Info("Copying package %s from the GOPATH.", dep.Name)
msg.Debug("Found %s in GOPATH at %s. Copying to %s", dep.Name, d, dest)
err = gpath.CopyDir(d, dest)
if err != nil {
diff --git a/util/util.go b/util/util.go
index bf949c1..409d400 100644
--- a/util/util.go
+++ b/util/util.go
@@ -283,10 +283,11 @@
if err == nil {
p := filepath.Join(b.GOROOT, "src", name)
if _, err := os.Stat(p); err == nil {
- return name, ""
+ return filepath.ToSlash(name), ""
}
}
+ name = filepath.ToSlash(name)
root := GetRootFromPackage(name)
extra := strings.TrimPrefix(name, root)
if len(extra) > 0 && extra != "/" {