diff --git a/.gitignore b/.gitignore index 2bd0e515..9210b998 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ glide.exe dist/ .DS_Store .idea +*.sw[po] diff --git a/glide.lock b/glide.lock index 430edf9d..8d589396 100644 --- a/glide.lock +++ b/glide.lock @@ -1,12 +1,13 @@ -hash: 1f13d16b2759f4c698bf1fa66a55ef06a42ba86859153c478f903e60502a1273 -updated: 2017-10-04T10:27:41.570512797-04:00 +hash: f0323666f16ae33bf7a84e9c69919d8ee27bfb1e873bdbf826b03ddecb734e49 +updated: 2017-12-25T18:38:31.670159745-08:00 imports: - name: github.com/codegangsta/cli version: cfb38830724cc34fedffe9a2a29fb54fa9169cd1 - name: github.com/Masterminds/semver version: 15d8430ab86497c5c0da827b748823945e1cf1e1 - name: github.com/Masterminds/vcs - version: 6f1c6d150500e452704e9863f68c2559f58616bf + version: 89ac364c7b6b44926d8c59d8c352affd0b959871 + repo: https://github.com/jaekwon/vcs.git - name: github.com/mitchellh/go-homedir version: b8bc1bf767474819792c23f32d8286a45736f1c6 - name: gopkg.in/yaml.v2 diff --git a/glide.yaml b/glide.yaml index 5b6c0790..b5901abd 100644 --- a/glide.yaml +++ b/glide.yaml @@ -11,7 +11,8 @@ owners: import: - package: gopkg.in/yaml.v2 - package: github.com/Masterminds/vcs - version: ^1.12.0 + repo: https://github.com/jaekwon/vcs.git + branch: master - package: github.com/codegangsta/cli version: ^1.16.0 - package: github.com/Masterminds/semver diff --git a/vendor/github.com/Masterminds/vcs/git.go b/vendor/github.com/Masterminds/vcs/git.go index 4094e0d0..f07f2ace 100644 --- a/vendor/github.com/Masterminds/vcs/git.go +++ b/vendor/github.com/Masterminds/vcs/git.go @@ -148,7 +148,7 @@ func (s *GitRepo) Update() error { return nil } - out, err = s.RunFromDir("git", "pull") + out, err = s.RunFromDir("git", "reset", "--hard") if err != nil { return NewRemoteError("Unable to update repository", err, string(out)) } @@ -158,7 +158,19 @@ func (s *GitRepo) Update() error { // UpdateVersion sets the version of a package currently checked out via Git. func (s *GitRepo) UpdateVersion(version string) error { - out, err := s.RunFromDir("git", "checkout", version) + + // If version is a remote branch, prepend s.RemoteLocation (aka "origin") + branches, err := s.Branches() // Remote branches + if err != nil { + return NewLocalError("Unable to query for repo branches", err, "") + } + for _, branch := range branches { + if version == branch { + version = s.RemoteLocation + "/" + branch // e.g. "origin/develop" + } + } + + out, err := s.RunFromDir("git", "reset", "--hard", version) if err != nil { return NewLocalError("Unable to update checked out version", err, string(out)) } @@ -366,7 +378,7 @@ func (s *GitRepo) Ping() bool { // EscapePathSeparator escapes the path separator by replacing it with several. // Note: this is harmless on Unix, and needed on Windows. -func EscapePathSeparator(path string) (string) { +func EscapePathSeparator(path string) string { switch runtime.GOOS { case `windows`: // On Windows, triple all path separators. @@ -379,7 +391,7 @@ func EscapePathSeparator(path string) (string) { // used with --prefix, like this: --prefix=C:\foo\bar\ -> --prefix=C:\\\foo\\\bar\\\ return strings.Replace(path, string(os.PathSeparator), - string(os.PathSeparator) + string(os.PathSeparator) + string(os.PathSeparator), + string(os.PathSeparator)+string(os.PathSeparator)+string(os.PathSeparator), -1) default: return path @@ -404,7 +416,7 @@ func (s *GitRepo) ExportDir(dir string) error { return NewLocalError("Unable to create directory", err, "") } - path = EscapePathSeparator( dir ) + path = EscapePathSeparator(dir) out, err := s.RunFromDir("git", "checkout-index", "-f", "-a", "--prefix="+path) s.log(out) if err != nil { @@ -412,7 +424,7 @@ func (s *GitRepo) ExportDir(dir string) error { } // and now, the horror of submodules - path = EscapePathSeparator( dir + "$path" + string(os.PathSeparator) ) + path = EscapePathSeparator(dir + "$path" + string(os.PathSeparator)) out, err = s.RunFromDir("git", "submodule", "foreach", "--recursive", "git checkout-index -f -a --prefix="+path) s.log(out) if err != nil {