diff -Nru golang-github-masterminds-vcs-dev-1.9.0/bzr.go golang-github-masterminds-vcs-dev-1.10.0/bzr.go --- golang-github-masterminds-vcs-dev-1.9.0/bzr.go 2016-11-18 14:12:47.000000000 +0000 +++ golang-github-masterminds-vcs-dev-1.10.0/bzr.go 2017-01-09 17:39:47.000000000 +0000 @@ -39,7 +39,7 @@ // http://bazaar.launchpad.net/~mattfarina/govcstestbzrrepo/trunk/. Notice // the change from https to http and the path chance. // Here we set the remote to be the local one if none is passed in. - if err == nil && r.CheckLocal() == true && remote == "" { + if err == nil && r.CheckLocal() && remote == "" { c := exec.Command("bzr", "info") c.Dir = local c.Env = envForDir(c.Dir) @@ -226,11 +226,7 @@ // commit id or tag. func (s *BzrRepo) IsReference(r string) bool { _, err := s.RunFromDir("bzr", "revno", "-r", r) - if err == nil { - return true - } - - return false + return err == nil } // IsDirty returns if the checkout has been modified from the checked @@ -308,21 +304,14 @@ // an error is returned. Launchpad returns a 404 for a codebase that // does not exist. Otherwise it returns a JSON object describing it. _, er := get("https://api.launchpad.net/1.0/" + try) - if er == nil { - return true - } - return false + return er == nil } } // This is the same command that Go itself uses but it's not fast (or fast // enough by my standards). A faster method would be useful. _, err = s.run("bzr", "info", s.Remote()) - if err != nil { - return false - } - - return true + return err == nil } // ExportDir exports the current revision to the passed in directory. @@ -340,6 +329,7 @@ // https://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev/files/head:/po/ func (s *BzrRepo) isUnableToCreateDir(err error) bool { msg := err.Error() + if strings.HasPrefix(msg, fmt.Sprintf("Parent directory of %s does not exist.", s.LocalPath())) || strings.HasPrefix(msg, fmt.Sprintf("Nadřazený adresář %s neexistuje.", s.LocalPath())) || strings.HasPrefix(msg, fmt.Sprintf("El directorio padre de %s no existe.", s.LocalPath())) || diff -Nru golang-github-masterminds-vcs-dev-1.9.0/bzr_test.go golang-github-masterminds-vcs-dev-1.10.0/bzr_test.go --- golang-github-masterminds-vcs-dev-1.9.0/bzr_test.go 2016-11-18 14:12:47.000000000 +0000 +++ golang-github-masterminds-vcs-dev-1.10.0/bzr_test.go 2017-01-09 17:39:47.000000000 +0000 @@ -55,7 +55,7 @@ } // Verify Bzr repo is a Bzr repo - if repo.CheckLocal() == false { + if !repo.CheckLocal() { t.Error("Problem checking out repo or Bzr CheckLocal is not working") } @@ -75,7 +75,7 @@ t.Error(nrerr) } // Verify the right oject is returned. It will check the local repo type. - if nrepo.CheckLocal() == false { + if !nrepo.CheckLocal() { t.Error("Wrong version returned from NewRepo") } @@ -164,15 +164,15 @@ t.Error("Bzr is incorrectly returning branches") } - if repo.IsReference("1.0.0") != true { + if !repo.IsReference("1.0.0") { t.Error("Bzr is reporting a reference is not one") } - if repo.IsReference("foo") == true { - t.Error("Bzr is reporting a non-existant reference is one") + if repo.IsReference("foo") { + t.Error("Bzr is reporting a non-existent reference is one") } - if repo.IsDirty() == true { + if repo.IsDirty() { t.Error("Bzr incorrectly reporting dirty") } @@ -227,7 +227,7 @@ _, err = os.Stat(filepath.Join(exportDir, string(repo.Vcs()))) if err != nil { - if found := os.IsNotExist(err); found == false { + if found := os.IsNotExist(err); !found { t.Errorf("Error checking exported metadata in Bzr: %s", err) } } else { @@ -250,7 +250,7 @@ }() repo, _ := NewBzrRepo("", tempDir) - if repo.CheckLocal() == true { + if repo.CheckLocal() { t.Error("Bzr CheckLocal does not identify non-Bzr location") } diff -Nru golang-github-masterminds-vcs-dev-1.9.0/CHANGELOG.md golang-github-masterminds-vcs-dev-1.10.0/CHANGELOG.md --- golang-github-masterminds-vcs-dev-1.9.0/CHANGELOG.md 2016-11-18 14:12:47.000000000 +0000 +++ golang-github-masterminds-vcs-dev-1.10.0/CHANGELOG.md 2017-01-09 17:39:47.000000000 +0000 @@ -1,3 +1,9 @@ +# 1.10.0 (2017-01-09) + +## Added +- #60: Handle Git submodules (thanks @sdboyer) +- #61: Add gometalinter to testing + # 1.9.0 (2016-11-18) ## Added diff -Nru golang-github-masterminds-vcs-dev-1.9.0/debian/changelog golang-github-masterminds-vcs-dev-1.10.0/debian/changelog --- golang-github-masterminds-vcs-dev-1.9.0/debian/changelog 2016-12-05 07:23:01.000000000 +0000 +++ golang-github-masterminds-vcs-dev-1.10.0/debian/changelog 2017-01-16 16:13:05.000000000 +0000 @@ -1,3 +1,9 @@ +golang-github-masterminds-vcs-dev (1.10.0-1) unstable; urgency=medium + + * New upstream version. + + -- ChangZhuo Chen (陳昌倬) Tue, 17 Jan 2017 00:13:05 +0800 + golang-github-masterminds-vcs-dev (1.9.0-1) unstable; urgency=medium * New upstream version. diff -Nru golang-github-masterminds-vcs-dev-1.9.0/debian/.git-dpm golang-github-masterminds-vcs-dev-1.10.0/debian/.git-dpm --- golang-github-masterminds-vcs-dev-1.9.0/debian/.git-dpm 2016-12-05 07:22:51.000000000 +0000 +++ golang-github-masterminds-vcs-dev-1.10.0/debian/.git-dpm 2017-01-16 16:11:04.000000000 +0000 @@ -1,11 +1,11 @@ # see git-dpm(1) from git-dpm package -807e93e0f8c2400213842ea82e13f69af50618d7 -807e93e0f8c2400213842ea82e13f69af50618d7 -807e93e0f8c2400213842ea82e13f69af50618d7 -807e93e0f8c2400213842ea82e13f69af50618d7 -golang-github-masterminds-vcs-dev_1.9.0.orig.tar.gz -db59752ee3182986a77636d84d284d80a01f6190 -24683 +2752e433766b205918bb70b9273a9d19abfe9bf7 +2752e433766b205918bb70b9273a9d19abfe9bf7 +2752e433766b205918bb70b9273a9d19abfe9bf7 +2752e433766b205918bb70b9273a9d19abfe9bf7 +golang-github-masterminds-vcs-dev_1.10.0.orig.tar.gz +bc32bd54778e06cb446ab9fe8703aa03587bb9bb +26023 debianTag="debian/%e%v" patchedTag="patched/%e%v" upstreamTag="upstream/%e%u" diff -Nru golang-github-masterminds-vcs-dev-1.9.0/errors.go golang-github-masterminds-vcs-dev-1.10.0/errors.go --- golang-github-masterminds-vcs-dev-1.9.0/errors.go 2016-11-18 14:12:47.000000000 +0000 +++ golang-github-masterminds-vcs-dev-1.10.0/errors.go 2017-01-09 17:39:47.000000000 +0000 @@ -5,7 +5,7 @@ // The vcs package provides ways to work with errors that hide the underlying // implementation details but make them accessible if needed. For basic errors // that do not have underlying implementation specific details or the underlying -// details are likely not necessairy there are errors for comparison. +// details are not necessary there are errors for comparison. // // For example: // diff -Nru golang-github-masterminds-vcs-dev-1.9.0/git.go golang-github-masterminds-vcs-dev-1.10.0/git.go --- golang-github-masterminds-vcs-dev-1.9.0/git.go 2016-11-18 14:12:47.000000000 +0000 +++ golang-github-masterminds-vcs-dev-1.10.0/git.go 2017-01-09 17:39:47.000000000 +0000 @@ -33,7 +33,7 @@ // Make sure the local Git repo is configured the same as the remote when // A remote value was passed in. - if err == nil && r.CheckLocal() == true { + if err == nil && r.CheckLocal() { c := exec.Command("git", "config", "--get", "remote.origin.url") c.Dir = local c.Env = envForDir(c.Dir) @@ -70,7 +70,7 @@ // Get is used to perform an initial clone of a repository. func (s *GitRepo) Get() error { - out, err := s.run("git", "clone", s.Remote(), s.LocalPath()) + out, err := s.run("git", "clone", "--recursive", s.Remote(), s.LocalPath()) // There are some windows cases where Git cannot create the parent directory, // if it does not already exist, to the location it's trying to create the @@ -143,7 +143,7 @@ return NewLocalError("Unable to update repository", err, "") } - if detached == true { + if detached { return nil } @@ -151,7 +151,8 @@ if err != nil { return NewRemoteError("Unable to update repository", err, string(out)) } - return nil + + return s.defendAgainstSubmodules() } // UpdateVersion sets the version of a package currently checked out via Git. @@ -160,6 +161,30 @@ if err != nil { return NewLocalError("Unable to update checked out version", err, string(out)) } + + return s.defendAgainstSubmodules() +} + +// defendAgainstSubmodules tries to keep repo state sane in the event of +// submodules. Or nested submodules. What a great idea, submodules. +func (s *GitRepo) defendAgainstSubmodules() error { + // First, update them to whatever they should be, if there should happen to be any. + out, err := s.RunFromDir("git", "submodule", "update", "--init", "--recursive") + if err != nil { + return NewLocalError("Unexpected error while defensively updating submodules", err, string(out)) + } + // Now, do a special extra-aggressive clean in case changing versions caused + // one or more submodules to go away. + out, err = s.RunFromDir("git", "clean", "-x", "-d", "-f", "-f") + if err != nil { + return NewLocalError("Unexpected error while defensively cleaning up after possible derelict submodule directories", err, string(out)) + } + // Then, repeat just in case there are any nested submodules that went away. + out, err = s.RunFromDir("git", "submodule", "foreach", "--recursive", "git", "clean", "-x", "-d", "-f", "-f") + if err != nil { + return NewLocalError("Unexpected error while defensively cleaning up after possible derelict nested submodule directories", err, string(out)) + } + return nil } @@ -255,11 +280,7 @@ // not been checked out yet. This next step should pickup the other // possible references. _, err = s.RunFromDir("git", "show-ref", r) - if err == nil { - return true - } - - return false + return err == nil } // IsDirty returns if the checkout has been modified from the checked @@ -339,11 +360,7 @@ // remote needs to be different. c.Env = mergeEnvLists([]string{"GIT_TERMINAL_PROMPT=0"}, os.Environ()) _, err := c.CombinedOutput() - if err != nil { - return false - } - - return true + return err == nil } // ExportDir exports the current revision to the passed in directory. @@ -359,6 +376,12 @@ if err != nil { return NewLocalError("Unable to export source", err, string(out)) } + // and now, the horror of submodules + out, err = s.RunFromDir("git", "submodule", "foreach", "--recursive", "'git checkout-index -f -a --prefix=\""+filepath.Join(dir, "$path")+"\"'") + s.log(out) + if err != nil { + return NewLocalError("Error while exporting submodule sources", err, string(out)) + } return nil } diff -Nru golang-github-masterminds-vcs-dev-1.9.0/git_test.go golang-github-masterminds-vcs-dev-1.10.0/git_test.go --- golang-github-masterminds-vcs-dev-1.9.0/git_test.go 2016-11-18 14:12:47.000000000 +0000 +++ golang-github-masterminds-vcs-dev-1.10.0/git_test.go 2017-01-09 17:39:47.000000000 +0000 @@ -1,6 +1,7 @@ package vcs import ( + "fmt" "io/ioutil" "path/filepath" "time" @@ -53,7 +54,7 @@ } // Verify Git repo is a Git repo - if repo.CheckLocal() == false { + if !repo.CheckLocal() { t.Error("Problem checking out repo or Git CheckLocal is not working") } @@ -73,7 +74,7 @@ t.Error(nrerr) } // Verify the right oject is returned. It will check the local repo type. - if nrepo.CheckLocal() == false { + if !nrepo.CheckLocal() { t.Error("Wrong version returned from NewRepo") } @@ -197,15 +198,15 @@ t.Error("Git is incorrectly returning branches") } - if repo.IsReference("1.0.0") != true { + if !repo.IsReference("1.0.0") { t.Error("Git is reporting a reference is not one") } - if repo.IsReference("foo") == true { - t.Error("Git is reporting a non-existant reference is one") + if repo.IsReference("foo") { + t.Error("Git is reporting a non-existent reference is one") } - if repo.IsDirty() == true { + if repo.IsDirty() { t.Error("Git incorrectly reporting dirty") } @@ -260,7 +261,7 @@ _, err = os.Stat(filepath.Join(exportDir, string(repo.Vcs()))) if err != nil { - if found := os.IsNotExist(err); found == false { + if found := os.IsNotExist(err); !found { t.Errorf("Error checking exported metadata in Git: %s", err) } } else { @@ -283,7 +284,7 @@ }() repo, _ := NewGitRepo("", tempDir) - if repo.CheckLocal() == true { + if repo.CheckLocal() { t.Error("Git CheckLocal does not identify non-Git location") } @@ -356,3 +357,128 @@ t.Error(err) } } + +func TestGitSubmoduleHandling(t *testing.T) { + tempDir, err := ioutil.TempDir("", "go-vcs-git-submodule-tests") + if err != nil { + t.Fatal(err) + } + defer func() { + err = os.RemoveAll(tempDir) + if err != nil { + t.Error(err) + } + }() + + dumplocal := func(err error) string { + if terr, ok := err.(*LocalError); ok { + return fmt.Sprintf("msg: %s\norig: %s\nout: %s", terr.Error(), terr.Original(), terr.Out()) + } + return err.Error() + } + + subdirExists := func(dir ...string) bool { + _, err := os.Stat(filepath.Join(append([]string{tempDir}, dir...)...)) + return err == nil + } + + // Initial clone should get version with two submodules, each of which have + // their own submodule + repo, err := NewGitRepo("https://github.com/sdboyer/subm", tempDir) + if err != nil { + t.Fatal(dumplocal(err)) + } + err = repo.Get() + if err != nil { + t.Fatalf("unable to clone Git repo. Err was %s", dumplocal(err)) + } + + // Verify we are on the right version. + v, err := repo.Version() + if v != "18e3a5f6fc7f6d577e732e7a5ab2caf990efbf8f" { + t.Fatalf("did not start from expected rev, tests could fail - bailing out (got %s)", v) + } + if err != nil { + t.Fatal(dumplocal(err)) + } + + if !subdirExists("subm1", ".git") { + t.Fatal("subm1 submodule does not exist on initial clone/checkout") + } + if !subdirExists("subm1", "dep-test", ".git") { + t.Fatal("dep-test submodule nested under subm1 does not exist on initial clone/checkout") + } + + if !subdirExists("subm-again", ".git") { + t.Fatal("subm-again submodule does not exist on initial clone/checkout") + } + if !subdirExists("subm-again", "dep-test", ".git") { + t.Fatal("dep-test submodule nested under subm-again does not exist on initial clone/checkout") + } + + // Now switch to version with no submodules, make sure they all go away + err = repo.UpdateVersion("e677f82015f72ac1c8fafa66b5463163b3597af2") + if err != nil { + t.Fatalf("checking out needed version failed with err: %s", dumplocal(err)) + } + + if subdirExists("subm1") { + t.Fatal("checking out version without submodule did not clean up immediate submodules") + } + if subdirExists("subm1", "dep-test") { + t.Fatal("checking out version without submodule did not clean up nested submodules") + } + if subdirExists("subm-again") { + t.Fatal("checking out version without submodule did not clean up immediate submodules") + } + if subdirExists("subm-again", "dep-test") { + t.Fatal("checking out version without submodule did not clean up nested submodules") + } + + err = repo.UpdateVersion("aaf7aa1bc4c3c682cc530eca8f80417088ee8540") + if err != nil { + t.Fatalf("checking out needed version failed with err: %s", dumplocal(err)) + } + + if !subdirExists("subm1", ".git") { + t.Fatal("checking out version with immediate submodule did not set up git subrepo") + } + + err = repo.UpdateVersion("6cc4669af468f3b4f16e7e96275ad01ade5b522f") + if err != nil { + t.Fatalf("checking out needed version failed with err: %s", dumplocal(err)) + } + + if !subdirExists("subm1", "dep-test", ".git") { + t.Fatal("checking out version with nested submodule did not set up nested git subrepo") + } + + err = repo.UpdateVersion("aaf7aa1bc4c3c682cc530eca8f80417088ee8540") + if err != nil { + t.Fatalf("checking out needed version failed with err: %s", dumplocal(err)) + } + + if subdirExists("subm1", "dep-test") { + t.Fatal("rolling back to version without nested submodule did not clean up the nested submodule") + } + + err = repo.UpdateVersion("18e3a5f6fc7f6d577e732e7a5ab2caf990efbf8f") + if err != nil { + t.Fatalf("checking out needed version failed with err: %s", dumplocal(err)) + } + + if !subdirExists("subm1", ".git") { + t.Fatal("subm1 submodule does not exist after switch from other commit") + } + if !subdirExists("subm1", "dep-test", ".git") { + t.Fatal("dep-test submodule nested under subm1 does not exist after switch from other commit") + } + + if !subdirExists("subm-again", ".git") { + t.Fatal("subm-again submodule does not exist after switch from other commit") + } + if !subdirExists("subm-again", "dep-test", ".git") { + t.Fatal("dep-test submodule nested under subm-again does not exist after switch from other commit") + } + +} diff -Nru golang-github-masterminds-vcs-dev-1.9.0/hg.go golang-github-masterminds-vcs-dev-1.10.0/hg.go --- golang-github-masterminds-vcs-dev-1.9.0/hg.go 2016-11-18 14:12:47.000000000 +0000 +++ golang-github-masterminds-vcs-dev-1.10.0/hg.go 2017-01-09 17:39:47.000000000 +0000 @@ -32,7 +32,7 @@ // Make sure the local Hg repo is configured the same as the remote when // A remote value was passed in. - if err == nil && r.CheckLocal() == true { + if err == nil && r.CheckLocal() { // An Hg repo was found so test that the URL there matches // the repo passed in here. c := exec.Command("hg", "paths") @@ -207,11 +207,7 @@ // commit id, branch, or tag. func (s *HgRepo) IsReference(r string) bool { _, err := s.RunFromDir("hg", "log", "-r", r) - if err == nil { - return true - } - - return false + return err == nil } // IsDirty returns if the checkout has been modified from the checked @@ -305,11 +301,7 @@ // Ping returns if remote location is accessible. func (s *HgRepo) Ping() bool { _, err := s.run("hg", "identify", s.Remote()) - if err != nil { - return false - } - - return true + return err == nil } // ExportDir exports the current revision to the passed in directory. diff -Nru golang-github-masterminds-vcs-dev-1.9.0/hg_test.go golang-github-masterminds-vcs-dev-1.10.0/hg_test.go --- golang-github-masterminds-vcs-dev-1.9.0/hg_test.go 2016-11-18 14:12:47.000000000 +0000 +++ golang-github-masterminds-vcs-dev-1.10.0/hg_test.go 2017-01-09 17:39:47.000000000 +0000 @@ -55,7 +55,7 @@ } // Verify Hg repo is a Hg repo - if repo.CheckLocal() == false { + if !repo.CheckLocal() { t.Error("Problem checking out repo or Hg CheckLocal is not working") } @@ -75,7 +75,7 @@ t.Error(nrerr) } // Verify the right oject is returned. It will check the local repo type. - if nrepo.CheckLocal() == false { + if !nrepo.CheckLocal() { t.Error("Wrong version returned from NewRepo") } @@ -166,19 +166,19 @@ t.Error("Hg is incorrectly returning branches") } - if repo.IsReference("1.0.0") != true { + if !repo.IsReference("1.0.0") { t.Error("Hg is reporting a reference is not one") } - if repo.IsReference("test") != true { + if !repo.IsReference("test") { t.Error("Hg is reporting a reference is not one") } - if repo.IsReference("foo") == true { - t.Error("Hg is reporting a non-existant reference is one") + if repo.IsReference("foo") { + t.Error("Hg is reporting a non-existent reference is one") } - if repo.IsDirty() == true { + if repo.IsDirty() { t.Error("Hg incorrectly reporting dirty") } @@ -231,7 +231,7 @@ _, err = os.Stat(filepath.Join(exportDir, string(repo.Vcs()))) if err != nil { - if found := os.IsNotExist(err); found == false { + if found := os.IsNotExist(err); !found { t.Errorf("Error checking exported metadata in Hg: %s", err) } } else { @@ -254,7 +254,7 @@ }() repo, _ := NewHgRepo("", tempDir) - if repo.CheckLocal() == true { + if repo.CheckLocal() { t.Error("Hg CheckLocal does not identify non-Hg location") } diff -Nru golang-github-masterminds-vcs-dev-1.9.0/Makefile golang-github-masterminds-vcs-dev-1.10.0/Makefile --- golang-github-masterminds-vcs-dev-1.9.0/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ golang-github-masterminds-vcs-dev-1.10.0/Makefile 2017-01-09 17:39:47.000000000 +0000 @@ -0,0 +1,41 @@ +.PHONY: setup +setup: + go get -u gopkg.in/alecthomas/gometalinter.v1 + gometalinter.v1 --install + +.PHONY: test +test: validate lint + @echo "==> Running tests" + go test -v + +.PHONY: validate +validate: +# misspell finds the work adresář (used in bzr.go) as a mispelling of +# address. It finds adres. An issue has been filed at +# https://github.com/client9/misspell/issues/99. In the meantime adding +# adres to the ignore list. + @echo "==> Running static validations" + @gometalinter.v1 \ + --disable-all \ + --linter "misspell:misspell -i adres -j 1 {path}/*.go:PATH:LINE:COL:MESSAGE" \ + --enable deadcode \ + --severity deadcode:error \ + --enable gofmt \ + --enable gosimple \ + --enable ineffassign \ + --enable misspell \ + --enable vet \ + --tests \ + --vendor \ + --deadline 60s \ + ./... || exit_code=1 + +.PHONY: lint +lint: + @echo "==> Running linters" + @gometalinter.v1 \ + --disable-all \ + --enable golint \ + --vendor \ + --deadline 60s \ + ./... || : diff -Nru golang-github-masterminds-vcs-dev-1.9.0/repo_test.go golang-github-masterminds-vcs-dev-1.10.0/repo_test.go --- golang-github-masterminds-vcs-dev-1.9.0/repo_test.go 2016-11-18 14:12:47.000000000 +0000 +++ golang-github-masterminds-vcs-dev-1.10.0/repo_test.go 2017-01-09 17:39:47.000000000 +0000 @@ -63,12 +63,12 @@ func TestDepInstalled(t *testing.T) { i := depInstalled("git") - if i != true { + if !i { t.Error("depInstalled not finding installed dep.") } i = depInstalled("thisreallyisntinstalled") - if i != false { + if i { t.Error("depInstalled finding not installed dep.") } } diff -Nru golang-github-masterminds-vcs-dev-1.9.0/svn.go golang-github-masterminds-vcs-dev-1.10.0/svn.go --- golang-github-masterminds-vcs-dev-1.9.0/svn.go 2016-11-18 14:12:47.000000000 +0000 +++ golang-github-masterminds-vcs-dev-1.10.0/svn.go 2017-01-09 17:39:47.000000000 +0000 @@ -33,7 +33,7 @@ // Make sure the local SVN repo is configured the same as the remote when // A remote value was passed in. - if err == nil && r.CheckLocal() == true { + if err == nil && r.CheckLocal() { // An SVN repo was found so test that the URL there matches // the repo passed in here. out, err := exec.Command("svn", "info", local).CombinedOutput() @@ -139,6 +139,9 @@ } out, err := s.RunFromDir("svn", "info", "--xml") + if err != nil { + return "", NewLocalError("Unable to retrieve checked out version", err, string(out)) + } s.log(out) infos := &Info{} err = xml.Unmarshal(out, &infos) @@ -261,6 +264,9 @@ } out, err := s.RunFromDir("svn", "info", "-r", id, "--xml") + if err != nil { + return nil, NewLocalError("Unable to retrieve commit information", err, string(out)) + } infos := &Info{} err = xml.Unmarshal(out, &infos) if err != nil { @@ -323,11 +329,7 @@ // Ping returns if remote location is accessible. func (s *SvnRepo) Ping() bool { _, err := s.run("svn", "--non-interactive", "info", s.Remote()) - if err != nil { - return false - } - - return true + return err == nil } // ExportDir exports the current revision to the passed in directory. @@ -346,11 +348,7 @@ // where the parent directory of the VCS local path doesn't exist. func (s *SvnRepo) isUnableToCreateDir(err error) bool { msg := err.Error() - if strings.HasPrefix(msg, "E000002") { - return true - } - - return false + return strings.HasPrefix(msg, "E000002") } // detectRemoteFromInfoCommand finds the remote url from the `svn info` diff -Nru golang-github-masterminds-vcs-dev-1.9.0/svn_test.go golang-github-masterminds-vcs-dev-1.10.0/svn_test.go --- golang-github-masterminds-vcs-dev-1.9.0/svn_test.go 2016-11-18 14:12:47.000000000 +0000 +++ golang-github-masterminds-vcs-dev-1.10.0/svn_test.go 2017-01-09 17:39:47.000000000 +0000 @@ -54,7 +54,7 @@ } // Verify SVN repo is a SVN repo - if repo.CheckLocal() == false { + if !repo.CheckLocal() { t.Error("Problem checking out repo or SVN CheckLocal is not working") } @@ -167,15 +167,15 @@ t.Error("Svn is incorrectly returning branches") } - if repo.IsReference("r4") != true { + if !repo.IsReference("r4") { t.Error("Svn is reporting a reference is not one") } - if repo.IsReference("55") == true { - t.Error("Svn is reporting a non-existant reference is one") + if repo.IsReference("55") { + t.Error("Svn is reporting a non-existent reference is one") } - if repo.IsDirty() == true { + if repo.IsDirty() { t.Error("Svn incorrectly reporting dirty") } @@ -230,7 +230,7 @@ _, err = os.Stat(filepath.Join(exportDir, string(repo.Vcs()))) if err != nil { - if found := os.IsNotExist(err); found == false { + if found := os.IsNotExist(err); !found { t.Errorf("Error checking exported metadata in Svn: %s", err) } } else { @@ -253,7 +253,7 @@ }() repo, _ := NewSvnRepo("", tempDir) - if repo.CheckLocal() == true { + if repo.CheckLocal() { t.Error("SVN CheckLocal does not identify non-SVN location") } diff -Nru golang-github-masterminds-vcs-dev-1.9.0/.travis.yml golang-github-masterminds-vcs-dev-1.10.0/.travis.yml --- golang-github-masterminds-vcs-dev-1.9.0/.travis.yml 2016-11-18 14:12:47.000000000 +0000 +++ golang-github-masterminds-vcs-dev-1.10.0/.travis.yml 2017-01-09 17:39:47.000000000 +0000 @@ -1,8 +1,6 @@ language: go go: - - 1.3 - - 1.4 - 1.5 - 1.6 - 1.7 @@ -18,6 +16,10 @@ # - http://docs.travis-ci.com/user/workers/standard-infrastructure/ sudo: false +script: + - GO15VENDOREXPERIMENT=1 make setup + - GO15VENDOREXPERIMENT=1 make test + notifications: webhooks: urls: diff -Nru golang-github-masterminds-vcs-dev-1.9.0/vcs_local_lookup.go golang-github-masterminds-vcs-dev-1.10.0/vcs_local_lookup.go --- golang-github-masterminds-vcs-dev-1.9.0/vcs_local_lookup.go 2016-11-18 14:12:47.000000000 +0000 +++ golang-github-masterminds-vcs-dev-1.10.0/vcs_local_lookup.go 2017-01-09 17:39:47.000000000 +0000 @@ -15,20 +15,20 @@ return "", ErrCannotDetectVCS } - seperator := string(os.PathSeparator) + separator := string(os.PathSeparator) // Walk through each of the different VCS types to see if // one can be detected. Do this is order of guessed popularity. - if _, err := os.Stat(vcsPath + seperator + ".git"); err == nil { + if _, err := os.Stat(vcsPath + separator + ".git"); err == nil { return Git, nil } - if _, err := os.Stat(vcsPath + seperator + ".svn"); err == nil { + if _, err := os.Stat(vcsPath + separator + ".svn"); err == nil { return Svn, nil } - if _, err := os.Stat(vcsPath + seperator + ".hg"); err == nil { + if _, err := os.Stat(vcsPath + separator + ".hg"); err == nil { return Hg, nil } - if _, err := os.Stat(vcsPath + seperator + ".bzr"); err == nil { + if _, err := os.Stat(vcsPath + separator + ".bzr"); err == nil { return Bzr, nil } diff -Nru golang-github-masterminds-vcs-dev-1.9.0/vcs_remote_lookup.go golang-github-masterminds-vcs-dev-1.10.0/vcs_remote_lookup.go --- golang-github-masterminds-vcs-dev-1.9.0/vcs_remote_lookup.go 2016-11-18 14:12:47.000000000 +0000 +++ golang-github-masterminds-vcs-dev-1.10.0/vcs_remote_lookup.go 2017-01-09 17:39:47.000000000 +0000 @@ -266,37 +266,6 @@ } -// Google supports Git, Hg, and Svn. The SVN style is only -// supported through their legacy setup at .googlecode.com. -// I wonder if anyone is actually using SVN support. -func checkGoogle(i map[string]string, u *url.URL) (Type, error) { - - // To figure out which of the VCS types is used in Google Code you need - // to parse a web page and find it. Ugh. I mean... ugh. - var hack = regexp.MustCompile(`id="checkoutcmd">(hg|git|svn)`) - - d, err := get(expand(i, "https://code.google.com/p/{project}/source/checkout?repo={repo}")) - if err != nil { - return "", err - } - - if m := hack.FindSubmatch(d); m != nil { - if vcs := string(m[1]); vcs != "" { - if vcs == "svn" { - // While Google supports SVN it can only be used with the legacy - // urls of .googlecode.com. I considered creating a new - // error for this problem but Google Code is going away and there - // is support for the legacy structure. - return "", ErrCannotDetectVCS - } - - return Type(vcs), nil - } - } - - return "", ErrCannotDetectVCS -} - // Expect a type key on i with the exact type detected from the regex. func checkURL(i map[string]string, u *url.URL) (Type, error) { return Type(i["type"]), nil diff -Nru golang-github-masterminds-vcs-dev-1.9.0/vcs_remote_lookup_test.go golang-github-masterminds-vcs-dev-1.10.0/vcs_remote_lookup_test.go --- golang-github-masterminds-vcs-dev-1.9.0/vcs_remote_lookup_test.go 2016-11-18 14:12:47.000000000 +0000 +++ golang-github-masterminds-vcs-dev-1.10.0/vcs_remote_lookup_test.go 2017-01-09 17:39:47.000000000 +0000 @@ -49,15 +49,15 @@ for u, c := range urlList { ty, _, err := detectVcsFromRemote(u) - if err == nil && c.work == false { + if err == nil && !c.work { t.Errorf("Error detecting VCS from URL(%s)", u) } - if err == ErrCannotDetectVCS && c.work == true { + if err == ErrCannotDetectVCS && c.work { t.Errorf("Error detecting VCS from URL(%s)", u) } - if err != nil && c.work == true { + if err != nil && c.work { t.Errorf("Error detecting VCS from URL(%s): %s", u, err) } @@ -65,11 +65,11 @@ err != ErrCannotDetectVCS && !strings.HasSuffix(err.Error(), "Not Found") && !strings.HasSuffix(err.Error(), "Access Denied") && - c.work == false { + !c.work { t.Errorf("Unexpected error returned (%s): %s", u, err) } - if c.work == true && ty != c.t { + if c.work && ty != c.t { t.Errorf("Incorrect VCS type returned(%s)", u) } }