Merge pull request #365 from chancez/add_list_format
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 407578f..a76e7d3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,11 @@
+# Release 0.10.2 (2016-04-06)
+
+- Issue #362: Updated docs on how -update-vendored works to help avoid confusion.
+- Fixed #371: Warn when name/location mismatch.
+- Fixed #290: On windows Glide was sometimes pulls in current project (thanks tzneal).
+- Fixed #361: Handle relative imports (thanks tmm1).
+- Fixed #373: Go 1.7 context package import issues.
+
 # Release 0.10.1 (2016-03-25)
 
 - Fixed #354: Fixed a situation where a dependency could be fetched when
diff --git a/action/ensure.go b/action/ensure.go
index 8d45bdd..de729fe 100644
--- a/action/ensure.go
+++ b/action/ensure.go
@@ -5,11 +5,13 @@
 	"os"
 	"os/exec"
 	"path"
+	"path/filepath"
 	"strings"
 
 	"github.com/Masterminds/glide/cfg"
 	"github.com/Masterminds/glide/msg"
 	gpath "github.com/Masterminds/glide/path"
+	"github.com/Masterminds/glide/util"
 )
 
 // EnsureConfig loads and returns a config file.
@@ -33,6 +35,27 @@
 		msg.Die("Failed to parse %s: %s", yamlpath, err)
 	}
 
+	b := filepath.Dir(yamlpath)
+	buildContext, err := util.GetBuildContext()
+	if err != nil {
+		msg.Die("Failed to build an import context while ensuring config: %s", err)
+	}
+	cwd, err := os.Getwd()
+	if err != nil {
+		msg.Err("Unable to get the current working directory")
+	} else {
+		// Determining a package name requires a relative path
+		b, err = filepath.Rel(b, cwd)
+		if err == nil {
+			name := buildContext.PackageName(b)
+			if name != conf.Name {
+				msg.Warn("The name listed in the config file (%s) does not match the current location (%s)", conf.Name, name)
+			}
+		} else {
+			msg.Warn("Problem finding the config file path (%s) relative to the current directory (%s): %s", b, cwd, err)
+		}
+	}
+
 	return conf
 }
 
diff --git a/action/project_info.go b/action/project_info.go
new file mode 100644
index 0000000..5e0995e
--- /dev/null
+++ b/action/project_info.go
@@ -0,0 +1,39 @@
+package action
+
+import (
+	"bytes"
+
+	"github.com/Masterminds/glide/msg"
+)
+
+func Info(format string) {
+	conf := EnsureConfig()
+	var buffer bytes.Buffer
+	varInit := false
+	for _, var_format := range format {
+		if varInit {
+			switch var_format {
+			case 'n':
+				buffer.WriteString(conf.Name)
+			case 'd':
+				buffer.WriteString(conf.Description)
+			case 'h':
+				buffer.WriteString(conf.Home)
+			case 'l':
+				buffer.WriteString(conf.License)
+			default:
+				msg.Die("Invalid format %s", string(var_format))
+			}
+		} else {
+			switch var_format {
+			case '%':
+				varInit = true
+				continue
+			default:
+				buffer.WriteString(string(var_format))
+			}
+		}
+		varInit = false
+	}
+	msg.Puts(buffer.String())
+}
diff --git a/dependency/resolver.go b/dependency/resolver.go
index dc88f62..2b919b0 100644
--- a/dependency/resolver.go
+++ b/dependency/resolver.go
@@ -2,6 +2,7 @@
 
 import (
 	"container/list"
+	"runtime"
 	//"go/build"
 	"os"
 	"path/filepath"
@@ -9,6 +10,7 @@
 
 	"github.com/Masterminds/glide/cfg"
 	"github.com/Masterminds/glide/msg"
+	gpath "github.com/Masterminds/glide/path"
 	"github.com/Masterminds/glide/util"
 )
 
@@ -216,6 +218,14 @@
 	return r.resolveImports(l)
 }
 
+// dirHasPrefix tests whether the directory dir begins with prefix.
+func dirHasPrefix(dir, prefix string) bool {
+	if runtime.GOOS != "windows" {
+		return strings.HasPrefix(dir, prefix)
+	}
+	return len(dir) >= len(prefix) && strings.EqualFold(dir[:len(prefix)], prefix)
+}
+
 // ResolveLocal resolves dependencies for the current project.
 //
 // This begins with the project, builds up a list of external dependencies.
@@ -280,13 +290,17 @@
 			case LocUnknown, LocVendor:
 				l.PushBack(filepath.Join(r.VendorDir, filepath.FromSlash(imp))) // Do we need a path on this?
 			case LocGopath:
-				if !strings.HasPrefix(info.Path, r.basedir) {
+				if !dirHasPrefix(info.Path, r.basedir) {
 					// FIXME: This is a package outside of the project we're
 					// scanning. It should really be on vendor. But we don't
 					// want it to reference GOPATH. We want it to be detected
 					// and moved.
 					l.PushBack(filepath.Join(r.VendorDir, filepath.FromSlash(imp)))
 				}
+			case LocRelative:
+				if strings.HasPrefix(imp, "./"+gpath.VendorDir) {
+					msg.Warn("Go package resolving will resolve %s without the ./%s/ prefix", imp, gpath.VendorDir)
+				}
 			}
 		}
 
@@ -779,6 +793,8 @@
 	// Why does a Google product get a special case build mode with a local
 	// package?
 	LocAppengine
+	// LocRelative indicates the packge is a relative directory
+	LocRelative
 )
 
 // PkgInfo represents metadata about a package found by the resolver.
@@ -815,6 +831,12 @@
 		Name: name,
 	}
 
+	if strings.HasPrefix(name, "./") || strings.HasPrefix(name, "../") {
+		info.Loc = LocRelative
+		r.findCache[name] = info
+		return info
+	}
+
 	// Check _only_ if this dep is in the current vendor directory.
 	p = filepath.Join(r.VendorDir, filepath.FromSlash(name))
 	if pkgExists(p) {
@@ -872,6 +894,12 @@
 		// https://blog.golang.org/the-app-engine-sdk-and-workspaces-gopath
 		info.Loc = LocAppengine
 		r.findCache[name] = info
+	} else if name == "context" {
+		// context is a package being added to the Go 1.7 standard library. Some
+		// packages, such as golang.org/x/net are importing it with build flags
+		// in files for go1.7. Need to detect this and handle it.
+		info.Loc = LocGoroot
+		r.findCache[name] = info
 	}
 
 	return info
diff --git a/docs/commands.md b/docs/commands.md
index f18c03e..3b233db 100644
--- a/docs/commands.md
+++ b/docs/commands.md
@@ -51,7 +51,7 @@
 
 If you want to use `glide up` to help you managed dependencies that are checked into your version control consider the flags:
 
-* `--update-vendored` (aliased to `-u`) to update the vendored dependencies.
+* `--update-vendored` (aliased to `-u`) to update the vendored dependencies. If Glide detects a vendored dependency it will update it and leave it in a vendored state. Note, any tertiary dependencies will not be automatically vendored with this flag.
 * `--strip-vcs` (aliased to `-s`) to strip VCS metadata (e.g., `.git` directories) from the `vendor` folder.
 * `--strip-vendor` (aliased to `-v`) to strip nested `vendor/` directories.
 
diff --git a/glide.go b/glide.go
index 0b9bd4b..f0647e4 100644
--- a/glide.go
+++ b/glide.go
@@ -485,6 +485,11 @@
 	will be removed when most Godeps users have migrated to using the vendor
 	folder.
 
+	Note, Glide detects vendored dependencies. With the '--update-vendored' flag
+	Glide will update vendored dependencies leaving them in a vendored state.
+	Tertiary dependencies will not be vendored automatically unless the
+	'--strip-vcs' flag is used along with it.
+
 	By default, packages that are discovered are considered transient, and are
 	not stored in the glide.yaml file. The --file=NAME.yaml flag allows you
 	to save the discovered dependencies to a YAML file.
@@ -598,6 +603,48 @@
 			},
 		},
 		{
+			Name:  "info",
+			Usage: "Info prints information about this project",
+			Flags: []cli.Flag{
+				cli.StringFlag{
+					Name:  "format, f",
+					Usage: `Format of the information wanted (required).`,
+				},
+			},
+			Description: `A format containing the text with replacement variables
+   has to be passed in. Those variables are:
+
+       %n - name
+       %d - description
+       %h - homepage
+       %l - license
+
+   For example, given a project with the following glide.yaml:
+
+       package: foo
+       homepage: https://example.com
+       license: MIT
+       description: Some example description
+
+   Then running the following commands:
+
+       glide info -f %n
+          prints 'foo'
+
+       glide info -f "License: %l"
+          prints 'License: MIT'
+
+       glide info -f "%n - %d - %h - %l"
+          prints 'foo - Some example description - https://example.com - MIT'`,
+			Action: func(c *cli.Context) {
+				if c.IsSet("format") {
+					action.Info(c.String("format"))
+				} else {
+					cli.ShowCommandHelp(c, c.Command.Name)
+				}
+			},
+		},
+		{
 			Name:  "about",
 			Usage: "Learn about Glide",
 			Action: func(c *cli.Context) {
diff --git a/repo/installer.go b/repo/installer.go
index 13d4696..e8e4bf6 100644
--- a/repo/installer.go
+++ b/repo/installer.go
@@ -555,7 +555,7 @@
 
 	err := VcsVersion(dep, d.Destination)
 	if err != nil {
-		msg.Warn("Unable to set verion on %s to %s. Err: %s", root, dep.Reference, err)
+		msg.Warn("Unable to set version on %s to %s. Err: %s", root, dep.Reference, err)
 		e = err
 	}
 
diff --git a/tree/tree.go b/tree/tree.go
index 8f0a0b5..1d9def2 100644
--- a/tree/tree.go
+++ b/tree/tree.go
@@ -103,6 +103,11 @@
 		Name: name,
 	}
 
+	if strings.HasPrefix(name, "./") || strings.HasPrefix(name, "../") {
+		info.Loc = dependency.LocRelative
+		return info
+	}
+
 	// Recurse backward to scan other vendor/ directories
 	// If the cwd isn't an absolute path walking upwards looking for vendor/
 	// folders can get into an infinate loop.
@@ -167,6 +172,11 @@
 		// where Google products are playing with each other.
 		// https://blog.golang.org/the-app-engine-sdk-and-workspaces-gopath
 		info.Loc = dependency.LocAppengine
+	} else if name == "context" {
+		// context is a package being added to the Go 1.7 standard library. Some
+		// packages, such as golang.org/x/net are importing it with build flags
+		// in files for go1.7. Need to detect this and handle it.
+		info.Loc = dependency.LocGoroot
 	}
 
 	return info
diff --git a/util/util.go b/util/util.go
index 5cdc0f4..ab67610 100644
--- a/util/util.go
+++ b/util/util.go
@@ -254,7 +254,7 @@
 		// There may not be any top level Go source files but the project may
 		// still be within the GOPATH.
 		if strings.HasPrefix(base, b.GOPATH) {
-			p := strings.TrimPrefix(base, b.GOPATH)
+			p := strings.TrimPrefix(base, filepath.Join(b.GOPATH, "src"))
 			return strings.Trim(p, string(os.PathSeparator))
 		}
 	}