Codebase list golang-glide / 464b237
New upstream release. Vincent Bernat 6 years ago
28 changed file(s) with 473 addition(s) and 148 deletion(s). Raw diff Collapse all Expand all
00 language: go
11
2 # The feature/go15 branch uses new features in go15. Only testing this branch
3 # against tip which has the features.
42 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
88 - tip
99
1010 # Setting sudo access to false will let Travis CI use containers rather than
1717 # in the vendor directory. We don't need to test all dependent packages.
1818 # Only testing this project.
1919 script:
20 - GO15VENDOREXPERIMENT=1 make test integration-test
20 - GO15VENDOREXPERIMENT=1 make test integration-test verify-version
2121
2222 notifications:
2323 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
041 # Release 0.12.3 (2016-10-03)
142
243 ## Fixed
00 GLIDE_GO_EXECUTABLE ?= go
1 VERSION := $(shell git describe --tags)
21 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)
35
46 build:
57 ${GLIDE_GO_EXECUTABLE} build -o glide -ldflags "-X main.version=${VERSION}" glide.go
2224 rm -rf ./dist
2325
2426 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
2928
3029 build-all:
3130 gox -verbose \
3231 -ldflags "-X main.version=${VERSION}" \
3332 -os="linux darwin windows freebsd openbsd netbsd" \
34 -arch="amd64 386 armv5 armv6 armv7 arm64" \
33 -arch="amd64 386 armv5 armv6 armv7 arm64 s390x" \
3534 -osarch="!darwin/arm64" \
3635 -output="dist/{{.OS}}-{{.Arch}}/{{.Dir}}" .
3736
4342 $(DIST_DIRS) zip -r glide-${VERSION}-{}.zip {} \; && \
4443 cd ..
4544
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
4656
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
1111 installed by a tool (e.g. glide), similar to `go get` or they can be vendored and
1212 distributed with the package.
1313
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.
1531
1632 ### Features
1733
5672 will install the versions listed in the `glide.lock` file, skipping scanning,
5773 unless the `glide.lock` file is not found in which case it will perform an update.
5874
59 A projects is structured like this:
75 A project is structured like this:
6076
6177 ```
6278 - $GOPATH/src/myProject (Your project)
96112 $ brew install glide
97113 ```
98114
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:
100116
101117 ```
102118 sudo add-apt-repository ppa:masterminds/glide && sudo apt-get update
103119 sudo apt-get install glide
104120 ```
105121
122 On Ubuntu Zesty (17.04) the package is called `golang-glide`.
123
106124 [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`.
107127
108128 To build from source you can:
109129
203203 vstr := ver.String()
204204 msg.Info("The package %s appears to use semantic versions (http://semver.org).", d.Name)
205205 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")
209211 msg.Info("Minor (M), Patch (P), or Skip Ranges (S)?")
212
210213 res, err := msg.PromptUntil([]string{"minor", "m", "patch", "p", "skip ranges", "s"})
211214 if err != nil {
212215 msg.Die("Error processing response: %s", err)
66 // Debug sets the debugging flags across components.
77 func Debug(on bool) {
88 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
189 }
1910
2011 // Quiet sets the quiet flags across components.
11
22 import (
33 "os"
4 "runtime"
45 "testing"
56
67 "github.com/Masterminds/glide/msg"
1011 wd, _ := os.Getwd()
1112 os.Chdir("../testdata/plugin")
1213 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 }
1423 args := []string{"a", "b"}
1524 // FIXME: Trapping the panic is the nice thing to do.
1625 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
514514 if strings.HasPrefix(errStr, "no buildable Go source") {
515515 msg.Debug("No subpackages declared. Skipping %s.", dep)
516516 continue
517 } else if os.IsNotExist(err) && !foundErr && !foundQ {
517 } else if osDirNotFound(err, r.Handler.PkgPath(dep)) && !foundErr && !foundQ {
518518 // If the location doesn't exist, there hasn't already been an
519519 // error, it's not already been in the Q then try to fetch it.
520520 // When there's an error or it's already in the Q (it should be
11411141
11421142 return
11431143 }
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 }
2020 }
2121
2222 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"),
2727 }
2828
2929 for _, p := range expect {
7676 t.Errorf("Expected 1 dep, got %d: %s", len(l), l[0])
7777 }
7878
79 if !strings.HasSuffix("github.com/codegangsta/cli", l[0]) {
79 if !strings.HasSuffix(filepath.FromSlash("github.com/codegangsta/cli"), l[0]) {
8080 t.Errorf("Unexpected package name: %s", l[0])
8181 }
8282 }
00 # Commands
11
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.
33
44 ## glide create (aliased to init)
55
134134
135135 The mirrors are stored in an `mirrors.yaml` file in your `GLIDE_HOME`.
136136
137 The three commands to manager mirrors are `list`, `set`, and `remove`.
137 The three commands to manage mirrors are `list`, `set`, and `remove`.
138138
139139 Use `set` in the form:
140140
146146
147147 for example,
148148
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
150150
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
152154
153155 Use `remove` in the form:
154156
155 glide mirror remove [original]
157 glide mirror remove [original]
156158
157159 for example,
158160
159 glide mirror remove https://github.com/example/foo
161 glide mirror remove https://github.com/example/foo
2929
3030 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:
3131
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.
3333 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).
3434
3535 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.
2222 repo: git@github.com:Masterminds/vcs
2323 vcs: git
2424 - package: github.com/codegangsta/cli
25 version: f89effe81c1ece9c5b0fda359ebd9cf65f169a51
2526 - package: github.com/Masterminds/semver
2627 version: ^1.0.0
2728 testImport:
55
66 Some plugins exist today for Glide including:
77
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.
99 * [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.
1010 * [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.
1113
1214 _Note, to add plugins to this list please create a pull request._
1315
3537 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
3638 execute.
3739
38 A glide plugin must be in one of two locations:
40 A Glide plugin must be in one of two locations:
3941
4042 1. Somewhere on the PATH
4143 2. In the same directory as `glide.yaml`
1111 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.
1212 3. If the rules don't provide an answer a `go get` request occurs to try and lookup the information.
1313
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`.
1515
1616 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.
1717
00 // Glide is a command line utility that manages Go project dependencies.
11 //
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
33 // project. The yaml
44 //
55 // A glide.yaml file looks like:
3333 "os"
3434 )
3535
36 var version = "0.12.0-dev"
36 var version = "0.13.0-dev"
3737
3838 const usage = `Vendor Package Management for your Go projects.
3939
7171 Usage: "Quiet (no info or debug messages)",
7272 },
7373 cli.BoolFlag{
74 Name: "verbose",
75 Usage: "Print detailed informational messages",
76 Hidden: true,
77 },
78 cli.BoolFlag{
7974 Name: "debug",
8075 Usage: "Print debug verbose informational messages",
8176 },
110105 os.Exit(1)
111106 }
112107
113 // If there was a Error message exit non-zero.
108 // If there was an Error message exit non-zero.
114109 if msg.HasErrored() {
115110 m := msg.Color(msg.Red, "An Error has occurred")
116111 msg.Msg(m)
174169 and versions to fetch. If those are not available the dependent packages will
175170 be fetched as either a version specified elsewhere or the latest version.
176171
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
178173 the versions for the dependencies of this dependency (transitive ones). This
179174 will generate an updated glide.lock file with specific locked versions to use.
180175
190185 },
191186 cli.BoolFlag{
192187 Name: "insecure",
193 Usage: "Use http:// rather than https:// to retrieve pacakges.",
188 Usage: "Use http:// rather than https:// to retrieve packages.",
194189 },
195190 cli.BoolFlag{
196191 Name: "no-recursive, quick",
254249 msg.Warn("The --update-vendored flag is deprecated. This now works by default.")
255250 }
256251 if c.String("file") != "" {
257 msg.Warn("The --flag flag is deprecated.")
252 msg.Warn("The --file flag is deprecated.")
258253 }
259254 if c.Bool("cache") {
260255 msg.Warn("The --cache flag is deprecated. This now works by default.")
276271
277272 if c.Bool("resolve-current") {
278273 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.")
280275 }
281276
282277 inst := repo.NewInstaller()
427422 Name: "install",
428423 ShortName: "i",
429424 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
432427 be installed. When there is a glide.yaml file defining the dependencies but
433428 no lock file (glide.lock) the dependencies are installed using the "update"
434429 command and a glide.lock file is generated pinning all dependencies. If a
526521
527522 If a dependency has a glide.yaml file, update will read that file and
528523 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
530525 dependencies stored in 'vendor/'. This behavior can be disabled with
531526 '--no-recursive'. When this behavior is skipped a glide.lock file is not
532527 generated because the full dependency tree cannot be known.
537532
538533 The '--strip-vendor' flag will remove any nested 'vendor' folders and
539534 '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
541536 will be removed when most Godeps users have migrated to using the vendor
542537 folder.`,
543538 Flags: []cli.Flag{
747742 to have a cache for your continuous integration (CI) system or if you want to
748743 work on a dependency in a local location.
749744
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'.
753748
754749 Use 'set' in the form:
755750
809804 {
810805 Name: "remove",
811806 ShortName: "rm",
812 Usage: "Remove an mirror",
807 Usage: "Remove a mirror",
813808 Description: `Use 'remove' in the form:
814809
815810 glide mirror remove [original]
832827 // so it can be used by any Glide command.
833828 func startup(c *cli.Context) error {
834829 action.Debug(c.Bool("debug"))
835 action.Verbose(c.Bool("verbose"))
836830 action.NoColor(c.Bool("no-color"))
837831 action.Quiet(c.Bool("quiet"))
838832 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
22 imports:
33 - name: github.com/codegangsta/cli
4 version: 1efa31f08b9333f1bd4882d61f9d668a70cd902e
4 version: cfb38830724cc34fedffe9a2a29fb54fa9169cd1
55 - name: github.com/Masterminds/semver
6 version: 8d0431362b544d1a3536cca26684828866a7de09
6 version: 517734cc7d6470c0d07130e40fd40bdeb9bcd3fd
77 - name: github.com/Masterminds/vcs
8 version: fbe9fb6ad5b5f35b3e82a7c21123cfc526cbf895
8 version: 6f1c6d150500e452704e9863f68c2559f58616bf
9 - name: github.com/mitchellh/go-homedir
10 version: b8bc1bf767474819792c23f32d8286a45736f1c6
911 - name: gopkg.in/yaml.v2
10 version: e4d366fc3c7938e2958e662b4258c7a89e1f0e3e
12 version: a3f3340b5840cee44f372bddb5880fcbc419b46a
1113 testImports: []
1010 import:
1111 - package: gopkg.in/yaml.v2
1212 - package: github.com/Masterminds/vcs
13 version: ^1.8.0
13 version: ^1.12.0
1414 - package: github.com/codegangsta/cli
1515 version: ^1.16.0
1616 - package: github.com/Masterminds/semver
17 version: ^1.1.1
17 version: ^1.3.0
18 - package: github.com/mitchellh/go-homedir
2121 // IsDebugging, if true, shows Debug.
2222 IsDebugging bool
2323
24 // IsVerbose, if true, shows detailed informational messages.
25 IsVerbose bool
26
2724 // NoColor, if true, will not use color in the output.
2825 NoColor bool
2926
5148 m := &Messenger{
5249 Quiet: false,
5350 IsDebugging: false,
54 IsVerbose: false,
5551 NoColor: false,
5652 Stdout: os.Stdout,
5753 Stderr: os.Stderr,
9288 // Debug logs debug information using the Default Messenger
9389 func Debug(msg string, args ...interface{}) {
9490 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...)
10891 }
10992
11093 // Warn logs a warning
77 "fmt"
88 "io"
99 "os"
10 "os/user"
10 "os/exec"
1111 "path/filepath"
1212 "strings"
13
14 "github.com/mitchellh/go-homedir"
1315 )
1416
1517 // DefaultGlideFile is the default name for the glide.yaml file.
3537
3638 // LockFile is the default name for the lock file.
3739 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 }
3858
3959 // Home returns the Glide home directory ($GLIDE_HOME or ~/.glide, typically).
4060 //
4464 return homeDir
4565 }
4666
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")
5169 } else {
5270 cwd, err := os.Getwd()
5371 if err == nil {
145163 return GlideWD(base)
146164 }
147165
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
148172 // Gopath gets GOPATH from environment and return the most relevant path.
149173 //
150174 // A GOPATH can contain a colon-separated list of paths. This retrieves the
163187 // Gopaths retrieves the Gopath as a list when there is more than one path
164188 // listed in the Gopath.
165189 func Gopaths() []string {
166 p := os.Getenv("GOPATH")
167 p = strings.Trim(p, string(filepath.ListSeparator))
190 p := strings.Trim(gopaths, string(filepath.ListSeparator))
168191 return filepath.SplitList(p)
169192 }
170193
22 import (
33 "os"
44 "path/filepath"
5 "runtime"
56 "testing"
67 )
78
3435 }
3536 wd, _ := os.Getwd()
3637
37 os.Chdir(filepath.Join(td, "a/b/c"))
38 os.Chdir(filepath.Join(td, "a", "b", "c"))
3839 res, err := Vendor()
3940 if err != nil {
4041 t.Errorf("Failed to resolve vendor directory: %s", err)
4445 t.Errorf("Failed to find vendor: expected %s got %s", expect, res)
4546 }
4647
47 os.Chdir(filepath.Join(td, "x/y/z"))
48 os.Chdir(filepath.Join(td, "x", "y", "z"))
4849 res, err = Vendor()
4950 if err != nil {
5051 t.Errorf("Failed to resolve vendor directory: %s", err)
5152 }
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 }
5365 if res != expect {
5466 t.Errorf("Failed to find vendor: expected %s got %s", expect, res)
5567 }
7385 }
7486 os.Chdir(wd)
7587 }
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 }
2929 if _, err := os.Stat(path); err == nil {
3030 if info.IsDir() {
3131 msg.Info("Removing: %s", path)
32 return os.RemoveAll(path)
32 return CustomRemoveAll(path)
3333 }
3434
3535 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 }
353353 }
354354
355355 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())
357383 if err != nil {
358384 return err
359385 }
360386
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)
386390 }
387391
388392 return err
389393
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
390421 }
391422
392423 // List resolves the complete dependency tree and returns a list of dependencies.
2525 // If the dependency has already been pinned we can skip it. This is a
2626 // faster path so we don't need to resolve it again.
2727 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)
2929 return nil
3030 }
3131
3232 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)
3434 return nil
3535 }
3636 updated.Add(dep.Name)
4949
5050 // If destination doesn't exist we need to perform an initial checkout.
5151 if _, err := os.Stat(dest); os.IsNotExist(err) {
52 msg.Info("--> Fetching %s.", dep.Name)
52 msg.Info("--> Fetching %s", dep.Name)
5353 if err = VcsGet(dep); err != nil {
5454 msg.Warn("Unable to checkout %s\n", dep.Name)
5555 return err
5656 }
5757 } else {
5858 // 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)
6060
6161 // When the directory is not empty and has no VCS directory it's
6262 // a vendored files situation.
6666 }
6767 _, err = v.DetectVcsFromFS(dest)
6868 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)
7070 msg.Debug("Removing empty directory %s", dest)
7171 err := os.RemoveAll(dest)
7272 if err != nil {
129129 // branch it's a tag or commit id so we can skip
130130 // performing an update.
131131 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)
133133 return nil
134134 }
135135 }
150150 // If the dependency has already been pinned we can skip it. This is a
151151 // faster path so we don't need to resolve it again.
152152 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)
154154 return nil
155155 }
156156
231231 }
232232 }
233233 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)
235235 } else {
236236 msg.Warn("--> Unable to find semantic version for constraint %s %s", dep.Name, ver)
237237 }
0 @echo off
1 echo "Hello from the other glide"
2121 // other needs arise it may need to be re-written.
2222 var ResolveCurrent = false
2323
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
2428 func init() {
2529 // Precompile the regular expressions used to check VCS locations.
2630 for _, v := range vcsList {
2731 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 }
2842 }
2943 }
3044
271285 //
272286 // TODO: This should be moved to the `dependency` package.
273287 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
274293 buildContext := &BuildCtxt{build.Default}
275294
276295 // If we aren't resolving for the current system set to look at all
281300 buildContext.UseAllFiles = true
282301 }
283302
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
296304 return buildContext, nil
297305 }
298306