New upstream release.
Vincent Bernat
6 years ago
0 | 0 | language: go |
1 | 1 | |
2 | # The feature/go15 branch uses new features in go15. Only testing this branch | |
3 | # against tip which has the features. | |
4 | 2 | go: |
5 | - 1.5 | |
6 | - 1.6 | |
7 | - 1.7 | |
3 | - 1.5.x | |
4 | - 1.6.x | |
5 | - 1.7.x | |
6 | - 1.8.x | |
7 | - 1.9.x | |
8 | 8 | - tip |
9 | 9 | |
10 | 10 | # Setting sudo access to false will let Travis CI use containers rather than |
17 | 17 | # in the vendor directory. We don't need to test all dependent packages. |
18 | 18 | # Only testing this project. |
19 | 19 | script: |
20 | - GO15VENDOREXPERIMENT=1 make test integration-test | |
20 | - GO15VENDOREXPERIMENT=1 make test integration-test verify-version | |
21 | 21 | |
22 | 22 | notifications: |
23 | 23 | webhooks: |
0 | # Release 0.13.0 (2017-09-28) | |
1 | ||
2 | ## Added | |
3 | ||
4 | - #631: Verify version during build in automation (thanks @breerly) | |
5 | - #711: Added a commit hash example to the docs (thanks @mh-cbon) | |
6 | - #771: Handling default GOPATH for Go 1.8 | |
7 | - #814: Adding install instructions for Ubuntu 17.04 (thanks @HaraldNordgren) | |
8 | - #870: Added support for s390x architecture (thanks @Nayana-ibm) | |
9 | ||
10 | ## Changed | |
11 | ||
12 | - #582: Removed verbose flag as it was not being used (thanks @kelcecil) | |
13 | - #697: Preserve vendor/.git, if it exists. (thanks @sdboyer) | |
14 | - #686: Make ending dots in output more consistent (thanks @stevenroose) | |
15 | - #748: Updated tests to work windows and add windows CI testing | |
16 | - #717: Cache GOROOT at init time for performance (thanks @heyitsanthony) | |
17 | - #797, #821, #908: Updating to the latest version of the dependencies | |
18 | - #800: Allow VERSION of glide to be passed in with build script (thanks @BlackYoup) | |
19 | - #774: Add docs on using go get to install glide (thanks @philoserf) | |
20 | - #907: Updated Travis CI language versions of Go to test against (thanks @dvrkps) | |
21 | - #916: Update gox to version managed by Masterminds for builds | |
22 | ||
23 | ## Fixed | |
24 | ||
25 | - #736: Find home dir without using cgo (thanks @krancour) | |
26 | - #603: Fixed where, in some cases not importing dependencies config | |
27 | - #620: Fixed grammar usage on projects (thanks @server-monitor) | |
28 | - #623: Fixed typos in help and (thanks @jonboulle) | |
29 | - #628: Fixed typos (thanks @philoserf) | |
30 | - #733: Fixed documentation issues (thanks @matiasanaya) | |
31 | - #747: Fixed issue with glide home directory (thanks @agatan) | |
32 | - #759: More spelling fixes (thanks @jbirch) | |
33 | - #775: Even more doc typo fixes (thanks @cristiangreco) | |
34 | - #811: Fixed issue with windows git submodules | |
35 | - #819: Fixed more typos (thanks @zoofood) | |
36 | - #829: Fixed preservation of .git files correctly (@RaduBerinde) | |
37 | - #778: Fixed removing and moving large sets of files fails on Windows | |
38 | - #910: Fixed issue due to go/build.ImportDir change response on not found dir | |
39 | - #906: Fixed CustomRemoveAll() to handle spaces in paths, and also file not found (thanks @jpz) | |
40 | ||
0 | 41 | # Release 0.12.3 (2016-10-03) |
1 | 42 | |
2 | 43 | ## Fixed |
0 | 0 | GLIDE_GO_EXECUTABLE ?= go |
1 | VERSION := $(shell git describe --tags) | |
2 | 1 | DIST_DIRS := find * -type d -exec |
2 | VERSION ?= $(shell git describe --tags) | |
3 | VERSION_INCODE = $(shell perl -ne '/^var version.*"([^"]+)".*$$/ && print "v$$1\n"' glide.go) | |
4 | VERSION_INCHANGELOG = $(shell perl -ne '/^\# Release (\d+(\.\d+)+) / && print "$$1\n"' CHANGELOG.md | head -n1) | |
3 | 5 | |
4 | 6 | build: |
5 | 7 | ${GLIDE_GO_EXECUTABLE} build -o glide -ldflags "-X main.version=${VERSION}" glide.go |
22 | 24 | rm -rf ./dist |
23 | 25 | |
24 | 26 | bootstrap-dist: |
25 | ${GLIDE_GO_EXECUTABLE} get -u github.com/franciscocpg/gox | |
26 | cd ${GOPATH}/src/github.com/franciscocpg/gox && git checkout dc50315fc7992f4fa34a4ee4bb3d60052eeb038e | |
27 | cd ${GOPATH}/src/github.com/franciscocpg/gox && ${GLIDE_GO_EXECUTABLE} install | |
28 | ||
27 | ${GLIDE_GO_EXECUTABLE} get -u github.com/Masterminds/gox | |
29 | 28 | |
30 | 29 | build-all: |
31 | 30 | gox -verbose \ |
32 | 31 | -ldflags "-X main.version=${VERSION}" \ |
33 | 32 | -os="linux darwin windows freebsd openbsd netbsd" \ |
34 | -arch="amd64 386 armv5 armv6 armv7 arm64" \ | |
33 | -arch="amd64 386 armv5 armv6 armv7 arm64 s390x" \ | |
35 | 34 | -osarch="!darwin/arm64" \ |
36 | 35 | -output="dist/{{.OS}}-{{.Arch}}/{{.Dir}}" . |
37 | 36 | |
43 | 42 | $(DIST_DIRS) zip -r glide-${VERSION}-{}.zip {} \; && \ |
44 | 43 | cd .. |
45 | 44 | |
45 | verify-version: | |
46 | @if [ "$(VERSION_INCODE)" = "v$(VERSION_INCHANGELOG)" ]; then \ | |
47 | echo "glide: $(VERSION_INCHANGELOG)"; \ | |
48 | elif [ "$(VERSION_INCODE)" = "v$(VERSION_INCHANGELOG)-dev" ]; then \ | |
49 | echo "glide (development): $(VERSION_INCHANGELOG)"; \ | |
50 | else \ | |
51 | echo "Version number in glide.go does not match CHANGELOG.md"; \ | |
52 | echo "glide.go: $(VERSION_INCODE)"; \ | |
53 | echo "CHANGELOG : $(VERSION_INCHANGELOG)"; \ | |
54 | exit 1; \ | |
55 | fi | |
46 | 56 | |
47 | .PHONY: build test install clean bootstrap-dist build-all dist integration-test | |
57 | .PHONY: build test install clean bootstrap-dist build-all dist integration-test verify-version |
11 | 11 | installed by a tool (e.g. glide), similar to `go get` or they can be vendored and |
12 | 12 | distributed with the package. |
13 | 13 | |
14 | [![Build Status](https://travis-ci.org/Masterminds/glide.svg)](https://travis-ci.org/Masterminds/glide) [![Go Report Card](https://goreportcard.com/badge/github.com/Masterminds/glide)](https://goreportcard.com/report/github.com/Masterminds/glide) [![GoDoc](https://godoc.org/github.com/Masterminds/glide?status.svg)](https://godoc.org/github.com/Masterminds/glide) [![Documentation Status](https://readthedocs.org/projects/glide/badge/?version=stable)](http://glide.readthedocs.org/en/stable/?badge=stable) [![Documentation Status](https://readthedocs.org/projects/glide/badge/?version=latest)](http://glide.readthedocs.org/en/latest/?badge=latest) [![Join the chat at https://gitter.im/Masterminds/glide](https://badges.gitter.im/Masterminds/glide.svg)](https://gitter.im/Masterminds/glide?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | |
14 | [![Build Status](https://travis-ci.org/Masterminds/glide.svg)](https://travis-ci.org/Masterminds/glide) | |
15 | [![Build status](https://ci.appveyor.com/api/projects/status/3pl4ytgdlfj852li?svg=true&passingText=windows%20build%20passing&failingText=windows%20build%20failing)](https://ci.appveyor.com/project/mattfarina/glide-a8xtg) | |
16 | [![Go Report Card](https://goreportcard.com/badge/github.com/Masterminds/glide)](https://goreportcard.com/report/github.com/Masterminds/glide) [![GoDoc](https://godoc.org/github.com/Masterminds/glide?status.svg)](https://godoc.org/github.com/Masterminds/glide) [![Documentation Status](https://readthedocs.org/projects/glide/badge/?version=stable)](http://glide.readthedocs.org/en/stable/?badge=stable) [![Documentation Status](https://readthedocs.org/projects/glide/badge/?version=latest)](http://glide.readthedocs.org/en/latest/?badge=latest) [![Join the chat at https://gitter.im/Masterminds/glide](https://badges.gitter.im/Masterminds/glide.svg)](https://gitter.im/Masterminds/glide?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | |
17 | ||
18 | ### Golang Dep | |
19 | ||
20 | An [official package manager](https://github.com/golang/dep) has been started for | |
21 | the Go community. We view this as a good thing to bring everyone together around | |
22 | one solution. It's currently pre-alpha so it's not ready for prime time usage. | |
23 | ||
24 | If you start to poke it you'll see it has a similar style to Glide. While commands | |
25 | may have different names there are many of the same features such as semantic versions | |
26 | and ranges. | |
27 | ||
28 | Our view is that Glide will be around until an official package manager is ready | |
29 | for production use by the masses. We support the common tool and look forward to | |
30 | the day it is capable of replacing Glide. | |
15 | 31 | |
16 | 32 | ### Features |
17 | 33 | |
56 | 72 | will install the versions listed in the `glide.lock` file, skipping scanning, |
57 | 73 | unless the `glide.lock` file is not found in which case it will perform an update. |
58 | 74 | |
59 | A projects is structured like this: | |
75 | A project is structured like this: | |
60 | 76 | |
61 | 77 | ``` |
62 | 78 | - $GOPATH/src/myProject (Your project) |
96 | 112 | $ brew install glide |
97 | 113 | ``` |
98 | 114 | |
99 | On Ubuntu Precise(12.04), Trusty (14.04), Wily (15.10) or Xenial (16.04) you can install from our PPA: | |
115 | On Ubuntu Precise (12.04), Trusty (14.04), Wily (15.10) or Xenial (16.04) you can install from our PPA: | |
100 | 116 | |
101 | 117 | ``` |
102 | 118 | sudo add-apt-repository ppa:masterminds/glide && sudo apt-get update |
103 | 119 | sudo apt-get install glide |
104 | 120 | ``` |
105 | 121 | |
122 | On Ubuntu Zesty (17.04) the package is called `golang-glide`. | |
123 | ||
106 | 124 | [Binary packages](https://github.com/Masterminds/glide/releases) are available for Mac, Linux and Windows. |
125 | ||
126 | For a development version it is also possible to `go get github.com/Masterminds/glide`. | |
107 | 127 | |
108 | 128 | To build from source you can: |
109 | 129 |
203 | 203 | vstr := ver.String() |
204 | 204 | msg.Info("The package %s appears to use semantic versions (http://semver.org).", d.Name) |
205 | 205 | msg.Info("Would you like to track the latest minor or patch releases (major.minor.patch)?") |
206 | msg.Info("Tracking minor version releases would use '>= %s, < %d.0.0' ('^%s'). Tracking patch version", vstr, ver.Major()+1, vstr) | |
207 | msg.Info("releases would use '>= %s, < %d.%d.0' ('~%s'). For more information on Glide versions", vstr, ver.Major(), ver.Minor()+1, vstr) | |
208 | msg.Info("and ranges see https://glide.sh/docs/versions") | |
206 | msg.Info("The choices are:") | |
207 | msg.Info(" - Tracking minor version releases would use '>= %s, < %d.0.0' ('^%s')", vstr, ver.Major()+1, vstr) | |
208 | msg.Info(" - Tracking patch version releases would use '>= %s, < %d.%d.0' ('~%s')", vstr, ver.Major(), ver.Minor()+1, vstr) | |
209 | msg.Info(" - Skip using ranges\n") | |
210 | msg.Info("For more information on Glide versions and ranges see https://glide.sh/docs/versions") | |
209 | 211 | msg.Info("Minor (M), Patch (P), or Skip Ranges (S)?") |
212 | ||
210 | 213 | res, err := msg.PromptUntil([]string{"minor", "m", "patch", "p", "skip ranges", "s"}) |
211 | 214 | if err != nil { |
212 | 215 | msg.Die("Error processing response: %s", err) |
6 | 6 | // Debug sets the debugging flags across components. |
7 | 7 | func Debug(on bool) { |
8 | 8 | msg.Default.IsDebugging = on |
9 | ||
10 | if on == true { | |
11 | msg.Default.IsVerbose = on | |
12 | } | |
13 | } | |
14 | ||
15 | // Verbose sets the verbose flags across components. | |
16 | func Verbose(on bool) { | |
17 | msg.Default.IsVerbose = on | |
18 | 9 | } |
19 | 10 | |
20 | 11 | // Quiet sets the quiet flags across components. |
1 | 1 | |
2 | 2 | import ( |
3 | 3 | "os" |
4 | "runtime" | |
4 | 5 | "testing" |
5 | 6 | |
6 | 7 | "github.com/Masterminds/glide/msg" |
10 | 11 | wd, _ := os.Getwd() |
11 | 12 | os.Chdir("../testdata/plugin") |
12 | 13 | msg.Default.PanicOnDie = true |
13 | cmd := "hello" | |
14 | var cmd string | |
15 | ||
16 | // Windows scripts for testing (batch) are different from shells scripts. | |
17 | // Making sure the plugin works in both bases. | |
18 | if runtime.GOOS == "windows" { | |
19 | cmd = "hello-win" | |
20 | } else { | |
21 | cmd = "hello" | |
22 | } | |
14 | 23 | args := []string{"a", "b"} |
15 | 24 | // FIXME: Trapping the panic is the nice thing to do. |
16 | 25 | Plugin(cmd, args) |
0 | ||
1 | version: build-{build}.{branch} | |
2 | ||
3 | clone_folder: C:\gopath\src\github.com\Masterminds\glide | |
4 | shallow_clone: true | |
5 | ||
6 | environment: | |
7 | GOPATH: C:\gopath | |
8 | ||
9 | platform: | |
10 | - x64 | |
11 | ||
12 | build: off | |
13 | ||
14 | install: | |
15 | - go version | |
16 | - go env | |
17 | ||
18 | test_script: | |
19 | - go test -v . ./gb ./path ./action ./tree ./util ./godep ./godep/strip ./gpm ./cfg ./dependency ./importer ./msg ./repo ./mirrors | |
20 | ||
21 | deploy: off |
514 | 514 | if strings.HasPrefix(errStr, "no buildable Go source") { |
515 | 515 | msg.Debug("No subpackages declared. Skipping %s.", dep) |
516 | 516 | continue |
517 | } else if os.IsNotExist(err) && !foundErr && !foundQ { | |
517 | } else if osDirNotFound(err, r.Handler.PkgPath(dep)) && !foundErr && !foundQ { | |
518 | 518 | // If the location doesn't exist, there hasn't already been an |
519 | 519 | // error, it's not already been in the Q then try to fetch it. |
520 | 520 | // When there's an error or it's already in the Q (it should be |
1141 | 1141 | |
1142 | 1142 | return |
1143 | 1143 | } |
1144 | ||
1145 | // In Go 1.9 go/build.ImportDir changed so that a missing dir | |
1146 | // no longer responses with os.IsNotExist. Instead the error changed | |
1147 | // one in the form of fmt.Errorf("cannot find package %q in:\n\t%s", path, p.Dir) | |
1148 | // which is similar to other go/build.ImportDir errors. This function | |
1149 | // attempts to detect when ImportDir thinks something is not found | |
1150 | func osDirNotFound(err error, p string) bool { | |
1151 | ||
1152 | if os.IsNotExist(err) { | |
1153 | return true | |
1154 | } | |
1155 | ||
1156 | // Since there are multiple errors that start like this we need to make | |
1157 | // sure the directory is not present | |
1158 | if strings.HasPrefix(err.Error(), "cannot find package ") { | |
1159 | _, nferr := os.Stat(p) | |
1160 | if os.IsNotExist(nferr) { | |
1161 | return true | |
1162 | } | |
1163 | } | |
1164 | ||
1165 | return false | |
1166 | } |
20 | 20 | } |
21 | 21 | |
22 | 22 | expect := []string{ |
23 | "github.com/Masterminds/semver", | |
24 | "github.com/Masterminds/vcs", | |
25 | "gopkg.in/yaml.v2", | |
26 | "github.com/codegangsta/cli", | |
23 | filepath.FromSlash("github.com/Masterminds/semver"), | |
24 | filepath.FromSlash("github.com/Masterminds/vcs"), | |
25 | filepath.FromSlash("gopkg.in/yaml.v2"), | |
26 | filepath.FromSlash("github.com/codegangsta/cli"), | |
27 | 27 | } |
28 | 28 | |
29 | 29 | for _, p := range expect { |
76 | 76 | t.Errorf("Expected 1 dep, got %d: %s", len(l), l[0]) |
77 | 77 | } |
78 | 78 | |
79 | if !strings.HasSuffix("github.com/codegangsta/cli", l[0]) { | |
79 | if !strings.HasSuffix(filepath.FromSlash("github.com/codegangsta/cli"), l[0]) { | |
80 | 80 | t.Errorf("Unexpected package name: %s", l[0]) |
81 | 81 | } |
82 | 82 | } |
0 | 0 | # Commands |
1 | 1 | |
2 | The following are the Glide commands, most of which are to help yoy manage your workspace. | |
2 | The following are the Glide commands, most of which are to help you manage your workspace. | |
3 | 3 | |
4 | 4 | ## glide create (aliased to init) |
5 | 5 | |
134 | 134 | |
135 | 135 | The mirrors are stored in an `mirrors.yaml` file in your `GLIDE_HOME`. |
136 | 136 | |
137 | The three commands to manager mirrors are `list`, `set`, and `remove`. | |
137 | The three commands to manage mirrors are `list`, `set`, and `remove`. | |
138 | 138 | |
139 | 139 | Use `set` in the form: |
140 | 140 | |
146 | 146 | |
147 | 147 | for example, |
148 | 148 | |
149 | glide mirror set https://github.com/example/foo https://git.example.com/example/foo.git | |
149 | glide mirror set https://github.com/example/foo https://git.example.com/example/foo.git | |
150 | 150 | |
151 | glide mirror set https://github.com/example/foo file:///path/to/local/repo --vcs git | |
151 | or | |
152 | ||
153 | glide mirror set https://github.com/example/foo file:///path/to/local/repo --vcs git | |
152 | 154 | |
153 | 155 | Use `remove` in the form: |
154 | 156 | |
155 | glide mirror remove [original] | |
157 | glide mirror remove [original] | |
156 | 158 | |
157 | 159 | for example, |
158 | 160 | |
159 | glide mirror remove https://github.com/example/foo | |
161 | glide mirror remove https://github.com/example/foo |
29 | 29 | |
30 | 30 | 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: |
31 | 31 | |
32 | 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. | |
32 | 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 three times. This can quickly lead to binary bloat. | |
33 | 33 | 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). |
34 | 34 | |
35 | 35 | If a dependency has a `vendor/` directory of its own Glide does not remove it by default. The resolution in the `go` toolchain will use these nested versions if they are present. To remove them use the `--strip-vendor` or `-v` flag on the `up` or `install` commands. |
22 | 22 | repo: git@github.com:Masterminds/vcs |
23 | 23 | vcs: git |
24 | 24 | - package: github.com/codegangsta/cli |
25 | version: f89effe81c1ece9c5b0fda359ebd9cf65f169a51 | |
25 | 26 | - package: github.com/Masterminds/semver |
26 | 27 | version: ^1.0.0 |
27 | 28 | testImport: |
5 | 5 | |
6 | 6 | Some plugins exist today for Glide including: |
7 | 7 | |
8 | * [glide-vc](https://github.com/sgotti/glide-vc) - The vendor cleaner allows you to strip files files not needed for building your application from the `vendor/` directory. | |
8 | * [glide-vc](https://github.com/sgotti/glide-vc) - The vendor cleaner allows you to strip files not needed for building your application from the `vendor/` directory. | |
9 | 9 | * [glide-brew](https://github.com/heewa/glide-brew) - Convert Go deps managed by glide to Homebrew resources to help you make brew formulas for you Go programs. |
10 | 10 | * [glide-hash](https://github.com/mattfarina/glide-hash) - Generates a hash of the `glide.yaml` file compatible with Glides internal hash. |
11 | * [glide-cleanup](https://github.com/ngdinhtoan/glide-cleanup) - Removing unused packages from the `glide.yaml` file. | |
12 | * [glide-pin](https://github.com/multiplay/glide-pin) - Take all dependencies from the `glide.lock` and pin them explicitly in the `glide.yaml` file. | |
11 | 13 | |
12 | 14 | _Note, to add plugins to this list please create a pull request._ |
13 | 15 | |
35 | 37 | A Glide plugin can be written in any language you wish, provided that it can be executed from the command line as a subprocess of Glide. The example included with Glide is a simple Bash script. We could just as easily write Go, Python, Perl, or even Java code (with a wrapper) to |
36 | 38 | execute. |
37 | 39 | |
38 | A glide plugin must be in one of two locations: | |
40 | A Glide plugin must be in one of two locations: | |
39 | 41 | |
40 | 42 | 1. Somewhere on the PATH |
41 | 43 | 2. In the same directory as `glide.yaml` |
11 | 11 | 2. If the package associated with the repo ends in `.git`, `.hg`, `.bzr`, or `.svn` this is used to determine the root and the type of version control system. |
12 | 12 | 3. If the rules don't provide an answer a `go get` request occurs to try and lookup the information. |
13 | 13 | |
14 | Again, this is the same way `go` trying to determine an external location when you use `go get`. | |
14 | Again, this is the same way `go` tries to determine an external location when you use `go get`. | |
15 | 15 | |
16 | 16 | If the project has dependency configuration stored in a Godep, GPM, Gom, or GB file that information will be used to populate the version within the `glide.yaml` file. |
17 | 17 |
0 | 0 | // Glide is a command line utility that manages Go project dependencies. |
1 | 1 | // |
2 | // Configureation of where to start is managed via a glide.yaml in the root of a | |
2 | // Configuration of where to start is managed via a glide.yaml in the root of a | |
3 | 3 | // project. The yaml |
4 | 4 | // |
5 | 5 | // A glide.yaml file looks like: |
33 | 33 | "os" |
34 | 34 | ) |
35 | 35 | |
36 | var version = "0.12.0-dev" | |
36 | var version = "0.13.0-dev" | |
37 | 37 | |
38 | 38 | const usage = `Vendor Package Management for your Go projects. |
39 | 39 | |
71 | 71 | Usage: "Quiet (no info or debug messages)", |
72 | 72 | }, |
73 | 73 | cli.BoolFlag{ |
74 | Name: "verbose", | |
75 | Usage: "Print detailed informational messages", | |
76 | Hidden: true, | |
77 | }, | |
78 | cli.BoolFlag{ | |
79 | 74 | Name: "debug", |
80 | 75 | Usage: "Print debug verbose informational messages", |
81 | 76 | }, |
110 | 105 | os.Exit(1) |
111 | 106 | } |
112 | 107 | |
113 | // If there was a Error message exit non-zero. | |
108 | // If there was an Error message exit non-zero. | |
114 | 109 | if msg.HasErrored() { |
115 | 110 | m := msg.Color(msg.Red, "An Error has occurred") |
116 | 111 | msg.Msg(m) |
174 | 169 | and versions to fetch. If those are not available the dependent packages will |
175 | 170 | be fetched as either a version specified elsewhere or the latest version. |
176 | 171 | |
177 | When adding a new dependency Glide will perform an update to work out the | |
172 | When adding a new dependency Glide will perform an update to work out | |
178 | 173 | the versions for the dependencies of this dependency (transitive ones). This |
179 | 174 | will generate an updated glide.lock file with specific locked versions to use. |
180 | 175 | |
190 | 185 | }, |
191 | 186 | cli.BoolFlag{ |
192 | 187 | Name: "insecure", |
193 | Usage: "Use http:// rather than https:// to retrieve pacakges.", | |
188 | Usage: "Use http:// rather than https:// to retrieve packages.", | |
194 | 189 | }, |
195 | 190 | cli.BoolFlag{ |
196 | 191 | Name: "no-recursive, quick", |
254 | 249 | msg.Warn("The --update-vendored flag is deprecated. This now works by default.") |
255 | 250 | } |
256 | 251 | if c.String("file") != "" { |
257 | msg.Warn("The --flag flag is deprecated.") | |
252 | msg.Warn("The --file flag is deprecated.") | |
258 | 253 | } |
259 | 254 | if c.Bool("cache") { |
260 | 255 | msg.Warn("The --cache flag is deprecated. This now works by default.") |
276 | 271 | |
277 | 272 | if c.Bool("resolve-current") { |
278 | 273 | util.ResolveCurrent = true |
279 | msg.Warn("Only resolving dependencies for the current OS/Arch") | |
274 | msg.Warn("Only resolving dependencies for the current OS/Arch.") | |
280 | 275 | } |
281 | 276 | |
282 | 277 | inst := repo.NewInstaller() |
427 | 422 | Name: "install", |
428 | 423 | ShortName: "i", |
429 | 424 | Usage: "Install a project's dependencies", |
430 | Description: `This uses the native VCS of each packages to install | |
431 | the appropriate version. There are two ways a projects dependencies can | |
425 | Description: `This uses the native VCS of each package to install | |
426 | the appropriate version. There are two ways a project's dependencies can | |
432 | 427 | be installed. When there is a glide.yaml file defining the dependencies but |
433 | 428 | no lock file (glide.lock) the dependencies are installed using the "update" |
434 | 429 | command and a glide.lock file is generated pinning all dependencies. If a |
526 | 521 | |
527 | 522 | If a dependency has a glide.yaml file, update will read that file and |
528 | 523 | use the information contained there. Those dependencies are maintained in |
529 | a the top level 'vendor/' directory. 'vendor/foo/bar' will have its | |
524 | the top level 'vendor/' directory. 'vendor/foo/bar' will have its | |
530 | 525 | dependencies stored in 'vendor/'. This behavior can be disabled with |
531 | 526 | '--no-recursive'. When this behavior is skipped a glide.lock file is not |
532 | 527 | generated because the full dependency tree cannot be known. |
537 | 532 | |
538 | 533 | The '--strip-vendor' flag will remove any nested 'vendor' folders and |
539 | 534 | 'Godeps/_workspace' folders after an update (along with undoing any Godep |
540 | import rewriting). Note, The Godeps specific functionality is deprecated and | |
535 | import rewriting). Note, the Godeps specific functionality is deprecated and | |
541 | 536 | will be removed when most Godeps users have migrated to using the vendor |
542 | 537 | folder.`, |
543 | 538 | Flags: []cli.Flag{ |
747 | 742 | to have a cache for your continuous integration (CI) system or if you want to |
748 | 743 | work on a dependency in a local location. |
749 | 744 | |
750 | The mirrors are stored in an mirrors.yaml file in your GLIDE_HOME. | |
751 | ||
752 | The three commands to manager mirrors are 'list', 'set', and 'remove'. | |
745 | The mirrors are stored in a mirrors.yaml file in your GLIDE_HOME. | |
746 | ||
747 | The three commands to manage mirrors are 'list', 'set', and 'remove'. | |
753 | 748 | |
754 | 749 | Use 'set' in the form: |
755 | 750 | |
809 | 804 | { |
810 | 805 | Name: "remove", |
811 | 806 | ShortName: "rm", |
812 | Usage: "Remove an mirror", | |
807 | Usage: "Remove a mirror", | |
813 | 808 | Description: `Use 'remove' in the form: |
814 | 809 | |
815 | 810 | glide mirror remove [original] |
832 | 827 | // so it can be used by any Glide command. |
833 | 828 | func startup(c *cli.Context) error { |
834 | 829 | action.Debug(c.Bool("debug")) |
835 | action.Verbose(c.Bool("verbose")) | |
836 | 830 | action.NoColor(c.Bool("no-color")) |
837 | 831 | action.Quiet(c.Bool("quiet")) |
838 | 832 | action.Init(c.String("yaml"), c.String("home")) |
0 | hash: 67c5571c33bfcb663d32d2b40b9ce1f2a05a3fa2e9f442077277c2782195729c | |
1 | updated: 2016-08-11T14:22:17.773372627-04:00 | |
0 | hash: 9678e016890de949db9cfcae386b5ae1a4c2149ccd602aad33ac90d7c19d117e | |
1 | updated: 2017-09-14T16:18:17.322889284-04:00 | |
2 | 2 | imports: |
3 | 3 | - name: github.com/codegangsta/cli |
4 | version: 1efa31f08b9333f1bd4882d61f9d668a70cd902e | |
4 | version: cfb38830724cc34fedffe9a2a29fb54fa9169cd1 | |
5 | 5 | - name: github.com/Masterminds/semver |
6 | version: 8d0431362b544d1a3536cca26684828866a7de09 | |
6 | version: 517734cc7d6470c0d07130e40fd40bdeb9bcd3fd | |
7 | 7 | - name: github.com/Masterminds/vcs |
8 | version: fbe9fb6ad5b5f35b3e82a7c21123cfc526cbf895 | |
8 | version: 6f1c6d150500e452704e9863f68c2559f58616bf | |
9 | - name: github.com/mitchellh/go-homedir | |
10 | version: b8bc1bf767474819792c23f32d8286a45736f1c6 | |
9 | 11 | - name: gopkg.in/yaml.v2 |
10 | version: e4d366fc3c7938e2958e662b4258c7a89e1f0e3e | |
12 | version: a3f3340b5840cee44f372bddb5880fcbc419b46a | |
11 | 13 | testImports: [] |
10 | 10 | import: |
11 | 11 | - package: gopkg.in/yaml.v2 |
12 | 12 | - package: github.com/Masterminds/vcs |
13 | version: ^1.8.0 | |
13 | version: ^1.12.0 | |
14 | 14 | - package: github.com/codegangsta/cli |
15 | 15 | version: ^1.16.0 |
16 | 16 | - package: github.com/Masterminds/semver |
17 | version: ^1.1.1 | |
17 | version: ^1.3.0 | |
18 | - package: github.com/mitchellh/go-homedir |
21 | 21 | // IsDebugging, if true, shows Debug. |
22 | 22 | IsDebugging bool |
23 | 23 | |
24 | // IsVerbose, if true, shows detailed informational messages. | |
25 | IsVerbose bool | |
26 | ||
27 | 24 | // NoColor, if true, will not use color in the output. |
28 | 25 | NoColor bool |
29 | 26 | |
51 | 48 | m := &Messenger{ |
52 | 49 | Quiet: false, |
53 | 50 | IsDebugging: false, |
54 | IsVerbose: false, | |
55 | 51 | NoColor: false, |
56 | 52 | Stdout: os.Stdout, |
57 | 53 | Stderr: os.Stderr, |
92 | 88 | // Debug logs debug information using the Default Messenger |
93 | 89 | func Debug(msg string, args ...interface{}) { |
94 | 90 | Default.Debug(msg, args...) |
95 | } | |
96 | ||
97 | // Verbose logs detailed information | |
98 | func (m *Messenger) Verbose(msg string, args ...interface{}) { | |
99 | if m.Quiet || !m.IsVerbose { | |
100 | return | |
101 | } | |
102 | m.Info(msg, args...) | |
103 | } | |
104 | ||
105 | // Verbose detailed information using the Default Messenger | |
106 | func Verbose(msg string, args ...interface{}) { | |
107 | Default.Verbose(msg, args...) | |
108 | 91 | } |
109 | 92 | |
110 | 93 | // Warn logs a warning |
7 | 7 | "fmt" |
8 | 8 | "io" |
9 | 9 | "os" |
10 | "os/user" | |
10 | "os/exec" | |
11 | 11 | "path/filepath" |
12 | 12 | "strings" |
13 | ||
14 | "github.com/mitchellh/go-homedir" | |
13 | 15 | ) |
14 | 16 | |
15 | 17 | // DefaultGlideFile is the default name for the glide.yaml file. |
35 | 37 | |
36 | 38 | // LockFile is the default name for the lock file. |
37 | 39 | const LockFile = "glide.lock" |
40 | ||
41 | func init() { | |
42 | ||
43 | // As of Go 1.8 the GOPATH is no longer required to be set. Instead there | |
44 | // is a default value. If there is no GOPATH check for the default value. | |
45 | // Note, checking the GOPATH first to avoid invoking the go toolchain if | |
46 | // possible. | |
47 | if gopaths = os.Getenv("GOPATH"); len(gopaths) == 0 { | |
48 | goExecutable := os.Getenv("GLIDE_GO_EXECUTABLE") | |
49 | if len(goExecutable) <= 0 { | |
50 | goExecutable = "go" | |
51 | } | |
52 | out, err := exec.Command(goExecutable, "env", "GOPATH").Output() | |
53 | if err == nil { | |
54 | gopaths = strings.TrimSpace(string(out)) | |
55 | } | |
56 | } | |
57 | } | |
38 | 58 | |
39 | 59 | // Home returns the Glide home directory ($GLIDE_HOME or ~/.glide, typically). |
40 | 60 | // |
44 | 64 | return homeDir |
45 | 65 | } |
46 | 66 | |
47 | // Initialize the default user. | |
48 | u, err := user.Current() | |
49 | if err == nil && u.HomeDir != "" { | |
50 | homeDir = filepath.Join(u.HomeDir, ".glide") | |
67 | if h, err := homedir.Dir(); err == nil { | |
68 | homeDir = filepath.Join(h, ".glide") | |
51 | 69 | } else { |
52 | 70 | cwd, err := os.Getwd() |
53 | 71 | if err == nil { |
145 | 163 | return GlideWD(base) |
146 | 164 | } |
147 | 165 | |
166 | // Stores the gopaths so they do not get repeatedly looked up. This is especially | |
167 | // true when the default value needs to be retrieved from `go env GOPATH`. | |
168 | // TODO(mattfarina): Instead of a singleton an application context would be a | |
169 | // better place to store things like this. | |
170 | var gopaths string | |
171 | ||
148 | 172 | // Gopath gets GOPATH from environment and return the most relevant path. |
149 | 173 | // |
150 | 174 | // A GOPATH can contain a colon-separated list of paths. This retrieves the |
163 | 187 | // Gopaths retrieves the Gopath as a list when there is more than one path |
164 | 188 | // listed in the Gopath. |
165 | 189 | func Gopaths() []string { |
166 | p := os.Getenv("GOPATH") | |
167 | p = strings.Trim(p, string(filepath.ListSeparator)) | |
190 | p := strings.Trim(gopaths, string(filepath.ListSeparator)) | |
168 | 191 | return filepath.SplitList(p) |
169 | 192 | } |
170 | 193 |
2 | 2 | import ( |
3 | 3 | "os" |
4 | 4 | "path/filepath" |
5 | "runtime" | |
5 | 6 | "testing" |
6 | 7 | ) |
7 | 8 | |
34 | 35 | } |
35 | 36 | wd, _ := os.Getwd() |
36 | 37 | |
37 | os.Chdir(filepath.Join(td, "a/b/c")) | |
38 | os.Chdir(filepath.Join(td, "a", "b", "c")) | |
38 | 39 | res, err := Vendor() |
39 | 40 | if err != nil { |
40 | 41 | t.Errorf("Failed to resolve vendor directory: %s", err) |
44 | 45 | t.Errorf("Failed to find vendor: expected %s got %s", expect, res) |
45 | 46 | } |
46 | 47 | |
47 | os.Chdir(filepath.Join(td, "x/y/z")) | |
48 | os.Chdir(filepath.Join(td, "x", "y", "z")) | |
48 | 49 | res, err = Vendor() |
49 | 50 | if err != nil { |
50 | 51 | t.Errorf("Failed to resolve vendor directory: %s", err) |
51 | 52 | } |
52 | expect = filepath.Join(td, "x", "symlinked_vendor") | |
53 | ||
54 | // Windows symlinks are different than *nix and they can be inconsistent. | |
55 | // The current testing only works for *nix testing and windows doesn't follow | |
56 | // the symlinks. If this is a vendor.lnk file in windows this won't work for | |
57 | // the go toolchain. If this is a windows link you need access to create one | |
58 | // which isn't consistent. | |
59 | // If there is a better way would love to know. | |
60 | if runtime.GOOS == "windows" { | |
61 | expect = filepath.Join(td, "x", "vendor") | |
62 | } else { | |
63 | expect = filepath.Join(td, "x", "symlinked_vendor") | |
64 | } | |
53 | 65 | if res != expect { |
54 | 66 | t.Errorf("Failed to find vendor: expected %s got %s", expect, res) |
55 | 67 | } |
73 | 85 | } |
74 | 86 | os.Chdir(wd) |
75 | 87 | } |
88 | ||
89 | func TestCustomRemoveAll(t *testing.T) { | |
90 | td, err := filepath.Abs(testdata) | |
91 | if err != nil { | |
92 | t.Fatal(err) | |
93 | } | |
94 | // test that deleting a non-existent directory does not throw an error | |
95 | err = CustomRemoveAll(filepath.Join(td, "directory/doesnt/exist")) | |
96 | if err != nil { | |
97 | t.Errorf("Failed when removing non-existent directory %s", err) | |
98 | } | |
99 | // test that deleting a path with spaces does not throw an error | |
100 | spaceyPath := filepath.Join(td, "10942384 12341234 12343214 324134132323") | |
101 | err = os.MkdirAll(spaceyPath, 0777) | |
102 | if err != nil { | |
103 | t.Fatalf("Failed to make test directory %s", err) | |
104 | } | |
105 | err = CustomRemoveAll(spaceyPath) | |
106 | if err != nil { | |
107 | t.Errorf("Errored incorrectly when deleting a path with spaces %s", err) | |
108 | } | |
109 | if _, err = os.Stat(spaceyPath); !os.IsNotExist(err) { | |
110 | t.Errorf("Failed to successfully delete a path with spaces") | |
111 | } | |
112 | } |
29 | 29 | if _, err := os.Stat(path); err == nil { |
30 | 30 | if info.IsDir() { |
31 | 31 | msg.Info("Removing: %s", path) |
32 | return os.RemoveAll(path) | |
32 | return CustomRemoveAll(path) | |
33 | 33 | } |
34 | 34 | |
35 | 35 | msg.Debug("%s is not a directory. Skipping removal", path) |
0 | package path | |
1 | ||
2 | import ( | |
3 | "fmt" | |
4 | "os" | |
5 | "os/exec" | |
6 | "runtime" | |
7 | "syscall" | |
8 | ||
9 | "bytes" | |
10 | "io/ioutil" | |
11 | ||
12 | "github.com/Masterminds/glide/msg" | |
13 | ) | |
14 | ||
15 | // extract the exit code from an os.exec error | |
16 | func getExitCode(err error) int { | |
17 | if err != nil { | |
18 | if exitError, ok := err.(*exec.ExitError); ok { | |
19 | waitStatus := exitError.Sys().(syscall.WaitStatus) | |
20 | return waitStatus.ExitStatus() | |
21 | } | |
22 | } | |
23 | return 0 | |
24 | } | |
25 | ||
26 | // Hard to track down these codes - they are from windows.h and documented here: | |
27 | // https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx | |
28 | const ( | |
29 | winErrorFileNotFound = 2 | |
30 | winErrorPathNotFound = 3 | |
31 | ) | |
32 | ||
33 | // This file and its contents are to handle a Windows bug where large sets of | |
34 | // files fail when using the `os` package. This has been seen in Windows 10 | |
35 | // including the Windows Linux Subsystem. | |
36 | // Tracking the issue in https://github.com/golang/go/issues/20841. Once the | |
37 | // upstream issue is fixed this change can be reverted. | |
38 | ||
39 | // CustomRemoveAll is similar to os.RemoveAll but deals with the bug outlined | |
40 | // at https://github.com/golang/go/issues/20841. | |
41 | func CustomRemoveAll(p string) error { | |
42 | ||
43 | // Handle the windows case first | |
44 | if runtime.GOOS == "windows" { | |
45 | msg.Debug("Detected Windows. Removing files using windows command") | |
46 | cmd := exec.Command("cmd.exe", "/c", "rd", "/s", "/q", p) | |
47 | output, err := cmd.CombinedOutput() | |
48 | if err != nil { | |
49 | exitCode := getExitCode(err) | |
50 | if exitCode != winErrorFileNotFound && exitCode != winErrorPathNotFound { | |
51 | return fmt.Errorf("Error removing files: %s. output: %s", err, output) | |
52 | } | |
53 | } | |
54 | return nil | |
55 | } else if detectWsl() { | |
56 | cmd := exec.Command("rm", "-rf", p) | |
57 | output, err2 := cmd.CombinedOutput() | |
58 | msg.Debug("Detected Windows Subsystem for Linux. Removing files using subsystem command") | |
59 | if err2 != nil { | |
60 | return fmt.Errorf("Error removing files: %s. output: %s", err2, output) | |
61 | } | |
62 | return nil | |
63 | } | |
64 | return os.RemoveAll(p) | |
65 | } | |
66 | ||
67 | // CustomRename is similar to os.Rename but deals with the bug outlined | |
68 | // at https://github.com/golang/go/issues/20841. | |
69 | func CustomRename(o, n string) error { | |
70 | ||
71 | // Handking windows cases first | |
72 | if runtime.GOOS == "windows" { | |
73 | msg.Debug("Detected Windows. Moving files using windows command") | |
74 | cmd := exec.Command("cmd.exe", "/c", "move", o, n) | |
75 | output, err := cmd.CombinedOutput() | |
76 | if err != nil { | |
77 | return fmt.Errorf("Error moving files: %s. output: %s", err, output) | |
78 | } | |
79 | ||
80 | return nil | |
81 | } else if detectWsl() { | |
82 | cmd := exec.Command("mv", o, n) | |
83 | output, err2 := cmd.CombinedOutput() | |
84 | msg.Debug("Detected Windows Subsystem for Linux. Removing files using subsystem command") | |
85 | if err2 != nil { | |
86 | return fmt.Errorf("Error moving files: %s. output: %s", err2, output) | |
87 | } | |
88 | ||
89 | return nil | |
90 | } | |
91 | ||
92 | return os.Rename(o, n) | |
93 | } | |
94 | ||
95 | var procIsWin bool | |
96 | var procDet bool | |
97 | ||
98 | func detectWsl() bool { | |
99 | ||
100 | if !procDet { | |
101 | procDet = true | |
102 | _, err := os.Stat("/proc/version") | |
103 | if err == nil { | |
104 | b, err := ioutil.ReadFile("/proc/version") | |
105 | if err != nil { | |
106 | msg.Warn("Unable to read /proc/version that was detected. May incorrectly detect WSL") | |
107 | msg.Debug("Windows Subsystem for Linux detection error: %s", err) | |
108 | return false | |
109 | } | |
110 | ||
111 | if bytes.Contains(b, []byte("Microsoft")) { | |
112 | msg.Debug("Windows Subsystem for Linux detected") | |
113 | procIsWin = true | |
114 | } | |
115 | } | |
116 | } | |
117 | ||
118 | return procIsWin | |
119 | } |
353 | 353 | } |
354 | 354 | |
355 | 355 | msg.Info("Replacing existing vendor dependencies") |
356 | err = os.RemoveAll(i.VendorPath()) | |
356 | ||
357 | // Check if a .git directory exists under the old vendor dir. If it does, | |
358 | // move it over to the newly-generated vendor dir - the user is probably | |
359 | // submoduling, and it's easy enough not to break their setup. | |
360 | ivg := filepath.Join(i.VendorPath(), ".git") | |
361 | gitInfo, err := os.Stat(ivg) | |
362 | if err == nil { | |
363 | msg.Info("Preserving existing vendor/.git") | |
364 | vpg := filepath.Join(vp, ".git") | |
365 | err = os.Rename(ivg, vpg) | |
366 | ||
367 | if terr, ok := err.(*os.LinkError); ok { | |
368 | if gitInfo.IsDir() { | |
369 | err = fixcle(ivg, vpg, terr) | |
370 | } else { | |
371 | // When this is a submodule, .git is just a file. Don't try to copy | |
372 | // it as a directory in this case (see #828). | |
373 | err = gpath.CopyFile(ivg, vpg) | |
374 | } | |
375 | ||
376 | if err != nil { | |
377 | msg.Warn("Failed to preserve existing vendor/.git") | |
378 | } | |
379 | } | |
380 | } | |
381 | ||
382 | err = gpath.CustomRemoveAll(i.VendorPath()) | |
357 | 383 | if err != nil { |
358 | 384 | return err |
359 | 385 | } |
360 | 386 | |
361 | err = os.Rename(vp, i.VendorPath()) | |
362 | ||
363 | if err != nil { | |
364 | // When there are different physical devices we cannot rename cross device. | |
365 | // Instead we copy. | |
366 | switch terr := err.(type) { | |
367 | case *os.LinkError: | |
368 | // syscall.EXDEV is the common name for the cross device link error | |
369 | // which has varying output text across different operating systems. | |
370 | if terr.Err == syscall.EXDEV { | |
371 | msg.Debug("Cross link err, trying manual copy: %s", err) | |
372 | return gpath.CopyDir(vp, i.VendorPath()) | |
373 | } else if runtime.GOOS == "windows" { | |
374 | // In windows it can drop down to an operating system call that | |
375 | // returns an operating system error with a different number and | |
376 | // message. Checking for that as a fall back. | |
377 | noerr, ok := terr.Err.(syscall.Errno) | |
378 | // 0x11 (ERROR_NOT_SAME_DEVICE) is the windows error. | |
379 | // See https://msdn.microsoft.com/en-us/library/cc231199.aspx | |
380 | if ok && noerr == 0x11 { | |
381 | msg.Debug("Cross link err on Windows, trying manual copy: %s", err) | |
382 | return gpath.CopyDir(vp, i.VendorPath()) | |
383 | } | |
384 | } | |
385 | } | |
387 | err = gpath.CustomRename(vp, i.VendorPath()) | |
388 | if terr, ok := err.(*os.LinkError); ok { | |
389 | return fixcle(vp, i.VendorPath(), terr) | |
386 | 390 | } |
387 | 391 | |
388 | 392 | return err |
389 | 393 | |
394 | } | |
395 | ||
396 | // fixcle is a helper function that tries to recover from cross-device rename | |
397 | // errors by falling back to copying. | |
398 | func fixcle(from, to string, terr *os.LinkError) error { | |
399 | // When there are different physical devices we cannot rename cross device. | |
400 | // Instead we copy. | |
401 | ||
402 | // syscall.EXDEV is the common name for the cross device link error | |
403 | // which has varying output text across different operating systems. | |
404 | if terr.Err == syscall.EXDEV { | |
405 | msg.Debug("Cross link err, trying manual copy: %s", terr) | |
406 | return gpath.CopyDir(from, to) | |
407 | } else if runtime.GOOS == "windows" { | |
408 | // In windows it can drop down to an operating system call that | |
409 | // returns an operating system error with a different number and | |
410 | // message. Checking for that as a fall back. | |
411 | noerr, ok := terr.Err.(syscall.Errno) | |
412 | // 0x11 (ERROR_NOT_SAME_DEVICE) is the windows error. | |
413 | // See https://msdn.microsoft.com/en-us/library/cc231199.aspx | |
414 | if ok && noerr == 0x11 { | |
415 | msg.Debug("Cross link err on Windows, trying manual copy: %s", terr) | |
416 | return gpath.CopyDir(from, to) | |
417 | } | |
418 | } | |
419 | ||
420 | return terr | |
390 | 421 | } |
391 | 422 | |
392 | 423 | // List resolves the complete dependency tree and returns a list of dependencies. |
25 | 25 | // If the dependency has already been pinned we can skip it. This is a |
26 | 26 | // faster path so we don't need to resolve it again. |
27 | 27 | if dep.Pin != "" { |
28 | msg.Debug("Dependency %s has already been pinned. Fetching updates skipped.", dep.Name) | |
28 | msg.Debug("Dependency %s has already been pinned. Fetching updates skipped", dep.Name) | |
29 | 29 | return nil |
30 | 30 | } |
31 | 31 | |
32 | 32 | if updated.Check(dep.Name) { |
33 | msg.Debug("%s was already updated, skipping.", dep.Name) | |
33 | msg.Debug("%s was already updated, skipping", dep.Name) | |
34 | 34 | return nil |
35 | 35 | } |
36 | 36 | updated.Add(dep.Name) |
49 | 49 | |
50 | 50 | // If destination doesn't exist we need to perform an initial checkout. |
51 | 51 | if _, err := os.Stat(dest); os.IsNotExist(err) { |
52 | msg.Info("--> Fetching %s.", dep.Name) | |
52 | msg.Info("--> Fetching %s", dep.Name) | |
53 | 53 | if err = VcsGet(dep); err != nil { |
54 | 54 | msg.Warn("Unable to checkout %s\n", dep.Name) |
55 | 55 | return err |
56 | 56 | } |
57 | 57 | } else { |
58 | 58 | // At this point we have a directory for the package. |
59 | msg.Info("--> Fetching updates for %s.", dep.Name) | |
59 | msg.Info("--> Fetching updates for %s", dep.Name) | |
60 | 60 | |
61 | 61 | // When the directory is not empty and has no VCS directory it's |
62 | 62 | // a vendored files situation. |
66 | 66 | } |
67 | 67 | _, err = v.DetectVcsFromFS(dest) |
68 | 68 | if empty == true && err == v.ErrCannotDetectVCS { |
69 | msg.Warn("Cached version of %s is an empty directory. Fetching a new copy of the dependency.", dep.Name) | |
69 | msg.Warn("Cached version of %s is an empty directory. Fetching a new copy of the dependency", dep.Name) | |
70 | 70 | msg.Debug("Removing empty directory %s", dest) |
71 | 71 | err := os.RemoveAll(dest) |
72 | 72 | if err != nil { |
129 | 129 | // branch it's a tag or commit id so we can skip |
130 | 130 | // performing an update. |
131 | 131 | if version == ver && !ib { |
132 | msg.Debug("%s is already set to version %s. Skipping update.", dep.Name, dep.Reference) | |
132 | msg.Debug("%s is already set to version %s. Skipping update", dep.Name, dep.Reference) | |
133 | 133 | return nil |
134 | 134 | } |
135 | 135 | } |
150 | 150 | // If the dependency has already been pinned we can skip it. This is a |
151 | 151 | // faster path so we don't need to resolve it again. |
152 | 152 | if dep.Pin != "" { |
153 | msg.Debug("Dependency %s has already been pinned. Setting version skipped.", dep.Name) | |
153 | msg.Debug("Dependency %s has already been pinned. Setting version skipped", dep.Name) | |
154 | 154 | return nil |
155 | 155 | } |
156 | 156 | |
231 | 231 | } |
232 | 232 | } |
233 | 233 | if found { |
234 | msg.Info("--> Detected semantic version. Setting version for %s to %s.", dep.Name, ver) | |
234 | msg.Info("--> Detected semantic version. Setting version for %s to %s", dep.Name, ver) | |
235 | 235 | } else { |
236 | 236 | msg.Warn("--> Unable to find semantic version for constraint %s %s", dep.Name, ver) |
237 | 237 | } |
21 | 21 | // other needs arise it may need to be re-written. |
22 | 22 | var ResolveCurrent = false |
23 | 23 | |
24 | // goRoot caches the GOROOT variable for build contexts. If $GOROOT is not set in | |
25 | // the user's environment, then the context's root path is 'go env GOROOT'. | |
26 | var goRoot string | |
27 | ||
24 | 28 | func init() { |
25 | 29 | // Precompile the regular expressions used to check VCS locations. |
26 | 30 | for _, v := range vcsList { |
27 | 31 | v.regex = regexp.MustCompile(v.pattern) |
32 | } | |
33 | if goRoot = os.Getenv("GOROOT"); len(goRoot) == 0 { | |
34 | goExecutable := os.Getenv("GLIDE_GO_EXECUTABLE") | |
35 | if len(goExecutable) <= 0 { | |
36 | goExecutable = "go" | |
37 | } | |
38 | out, err := exec.Command(goExecutable, "env", "GOROOT").Output() | |
39 | if err == nil { | |
40 | goRoot = strings.TrimSpace(string(out)) | |
41 | } | |
28 | 42 | } |
29 | 43 | } |
30 | 44 | |
271 | 285 | // |
272 | 286 | // TODO: This should be moved to the `dependency` package. |
273 | 287 | func GetBuildContext() (*BuildCtxt, error) { |
288 | if len(goRoot) == 0 { | |
289 | return nil, fmt.Errorf("GOROOT value not found. Please set the GOROOT " + | |
290 | "environment variable to use this command") | |
291 | } | |
292 | ||
274 | 293 | buildContext := &BuildCtxt{build.Default} |
275 | 294 | |
276 | 295 | // If we aren't resolving for the current system set to look at all |
281 | 300 | buildContext.UseAllFiles = true |
282 | 301 | } |
283 | 302 | |
284 | if goRoot := os.Getenv("GOROOT"); len(goRoot) == 0 { | |
285 | goExecutable := os.Getenv("GLIDE_GO_EXECUTABLE") | |
286 | if len(goExecutable) <= 0 { | |
287 | goExecutable = "go" | |
288 | } | |
289 | out, err := exec.Command(goExecutable, "env", "GOROOT").Output() | |
290 | if goRoot = strings.TrimSpace(string(out)); len(goRoot) == 0 || err != nil { | |
291 | return nil, fmt.Errorf("Please set the $GOROOT environment " + | |
292 | "variable to use this command\n") | |
293 | } | |
294 | buildContext.GOROOT = goRoot | |
295 | } | |
303 | buildContext.GOROOT = goRoot | |
296 | 304 | return buildContext, nil |
297 | 305 | } |
298 | 306 |