From 9101e324574892cfcd8d92e1978780d9ebcf4b96 Mon Sep 17 00:00:00 2001 From: Niranjan Godbole Date: Wed, 10 May 2017 19:37:16 +0530 Subject: [PATCH 1/8] dep init also checks for relative path --- cmd/dep/init.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/dep/init.go b/cmd/dep/init.go index 95eb01f0..9bffabae 100644 --- a/cmd/dep/init.go +++ b/cmd/dep/init.go @@ -69,6 +69,12 @@ func (cmd *initCommand) Run(ctx *dep.Ctx, args []string) error { root = ctx.WorkingDir } else { root = args[0] + if !filepath.IsAbs(args[0]) { + root = filepath.Join(ctx.WorkingDir, args[0]) + } + if err := os.MkdirAll(root, os.FileMode(0777)); err != nil { + return errors.Errorf("unable to create directory %s , err %v", root, err) + } } mf := filepath.Join(root, dep.ManifestName) From 358d80c5addd70e23ac1d5ecb84927297d87029f Mon Sep 17 00:00:00 2001 From: Niranjan Godbole Date: Sun, 14 May 2017 04:35:12 +0530 Subject: [PATCH 2/8] dep init adds test cases for relative path --- cmd/dep/integration_test.go | 72 +++++++++++++++++++ .../final/project_dir/Gopkg.lock | 12 ++++ .../final/project_dir/Gopkg.toml | 7 ++ .../initial/project_dir/foo/bar.go | 13 ++++ .../relative_path/initial/project_dir/main.go | 18 +++++ .../relative_path/testcase.json | 7 ++ internal/test/integration_testcase.go | 21 ++++++ internal/test/integration_testproj.go | 25 +++++++ 8 files changed, 175 insertions(+) create mode 100644 cmd/dep/testdata/init_path_tests/relative_path/final/project_dir/Gopkg.lock create mode 100644 cmd/dep/testdata/init_path_tests/relative_path/final/project_dir/Gopkg.toml create mode 100644 cmd/dep/testdata/init_path_tests/relative_path/initial/project_dir/foo/bar.go create mode 100644 cmd/dep/testdata/init_path_tests/relative_path/initial/project_dir/main.go create mode 100644 cmd/dep/testdata/init_path_tests/relative_path/testcase.json diff --git a/cmd/dep/integration_test.go b/cmd/dep/integration_test.go index b886596e..dccd4097 100644 --- a/cmd/dep/integration_test.go +++ b/cmd/dep/integration_test.go @@ -43,6 +43,30 @@ func TestIntegration(t *testing.T) { } return nil }) + + filepath.Walk(filepath.Join("testdata", "init_path_tests"), + func(path string, info os.FileInfo, err error) error { + if err != nil { + t.Fatal("error walking filepath") + } + + wd, err := os.Getwd() + if err != nil { + panic(err) + } + + if filepath.Base(path) == "testcase.json" { + parse := strings.Split(path, string(filepath.Separator)) + testName := strings.Join(parse[2:len(parse)-1], "/") + t.Run(testName, func(t *testing.T) { + t.Parallel() + + t.Run("external", testRelativePath(testName, wd, true, execCmd)) + t.Run("internal", testRelativePath(testName, wd, false, runMain)) + }) + } + return nil + }) } // execCmd is a test.RunFunc which runs the program in another process. @@ -128,3 +152,51 @@ func testIntegration(name, wd string, externalProc bool, run test.RunFunc) func( testCase.CompareVendorPaths(testProj.GetVendorPaths()) } } + +func testRelativePath(name, wd string, externalProc bool, run test.RunFunc) func(t *testing.T) { + return func(t *testing.T) { + t.Parallel() + + // Set up environment + testCase := test.NewTestCaseRelPath(t, name, wd) + defer testCase.Cleanup() + testProj := test.NewTestProjectRelPath(t, testCase.InitialPath(), testCase.InitPath, wd, externalProc, run) + defer testProj.Cleanup() + + // Create and checkout the vendor revisions + for ip, rev := range testCase.VendorInitial { + testProj.GetVendorGit(ip) + testProj.RunGit(testProj.VendorPath(ip), "checkout", rev) + } + + // Create and checkout the import revisions + for ip, rev := range testCase.GopathInitial { + testProj.RunGo("get", ip) + testProj.RunGit(testProj.Path("src", ip), "checkout", rev) + } + + // Run commands + testProj.RecordImportPaths() + + var err error + for i, args := range testCase.Commands { + err = testProj.DoRun(args) + if err != nil && i < len(testCase.Commands)-1 { + t.Fatalf("cmd %s raised an unexpected error: %s", args[0], err.Error()) + } + } + + // Check error raised in final command + testCase.CompareError(err, testProj.GetStderr()) + + // Check output + testCase.CompareOutput(testProj.GetStdout()) + + // Check final manifest and lock + testCase.CompareFile(dep.ManifestName, testProj.ProjPath(dep.ManifestName)) + testCase.CompareFile(dep.LockName, testProj.ProjPath(dep.LockName)) + + // Check vendor paths + testProj.CompareImportPaths() + } +} diff --git a/cmd/dep/testdata/init_path_tests/relative_path/final/project_dir/Gopkg.lock b/cmd/dep/testdata/init_path_tests/relative_path/final/project_dir/Gopkg.lock new file mode 100644 index 00000000..465f5950 --- /dev/null +++ b/cmd/dep/testdata/init_path_tests/relative_path/final/project_dir/Gopkg.lock @@ -0,0 +1,12 @@ +memo = "af9a783a5430dabcaaf44683c09e2b729e1c0d61f13bfdf6677c4fd0b41387ca" + +[[projects]] + branch = "master" + name = "github.com/sdboyer/deptest" + packages = ["."] + revision = "3f4c3bea144e112a69bbe5d8d01c1b09a544253f" + +[[projects]] + name = "github.com/sdboyer/deptestdos" + packages = ["."] + revision = "a0196baa11ea047dd65037287451d36b861b00ea" diff --git a/cmd/dep/testdata/init_path_tests/relative_path/final/project_dir/Gopkg.toml b/cmd/dep/testdata/init_path_tests/relative_path/final/project_dir/Gopkg.toml new file mode 100644 index 00000000..bccfadb8 --- /dev/null +++ b/cmd/dep/testdata/init_path_tests/relative_path/final/project_dir/Gopkg.toml @@ -0,0 +1,7 @@ + +[[dependencies]] + branch = "master" + name = "github.com/sdboyer/deptest" + +[[dependencies]] + name = "github.com/sdboyer/deptestdos" diff --git a/cmd/dep/testdata/init_path_tests/relative_path/initial/project_dir/foo/bar.go b/cmd/dep/testdata/init_path_tests/relative_path/initial/project_dir/foo/bar.go new file mode 100644 index 00000000..c1ed69fc --- /dev/null +++ b/cmd/dep/testdata/init_path_tests/relative_path/initial/project_dir/foo/bar.go @@ -0,0 +1,13 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package foo + +import "github.com/sdboyer/deptest" + +func Foo() deptest.Foo { + var y deptest.Foo + + return y +} diff --git a/cmd/dep/testdata/init_path_tests/relative_path/initial/project_dir/main.go b/cmd/dep/testdata/init_path_tests/relative_path/initial/project_dir/main.go new file mode 100644 index 00000000..150e0bd3 --- /dev/null +++ b/cmd/dep/testdata/init_path_tests/relative_path/initial/project_dir/main.go @@ -0,0 +1,18 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "fmt" + + "github.com/sdboyer/deptestdos" +) + +func main() { + var x deptestdos.Bar + y := foo.FooFunc() + + fmt.Println(x, y) +} diff --git a/cmd/dep/testdata/init_path_tests/relative_path/testcase.json b/cmd/dep/testdata/init_path_tests/relative_path/testcase.json new file mode 100644 index 00000000..e32eeb9e --- /dev/null +++ b/cmd/dep/testdata/init_path_tests/relative_path/testcase.json @@ -0,0 +1,7 @@ +{ + "commands": [ + ["init", "project_dir"] + ], + "init-path": "project_dir" + +} diff --git a/internal/test/integration_testcase.go b/internal/test/integration_testcase.go index 241612b0..ef614d19 100644 --- a/internal/test/integration_testcase.go +++ b/internal/test/integration_testcase.go @@ -33,6 +33,7 @@ type IntegrationTestCase struct { GopathInitial map[string]string `json:"gopath-initial"` VendorInitial map[string]string `json:"vendor-initial"` VendorFinal []string `json:"vendor-final"` + InitPath string `json:"init-path"` } func NewTestCase(t *testing.T, name, wd string) *IntegrationTestCase { @@ -55,6 +56,26 @@ func NewTestCase(t *testing.T, name, wd string) *IntegrationTestCase { return n } +func NewTestCaseRelPath(t *testing.T, name, wd string) *IntegrationTestCase { + rootPath := filepath.FromSlash(filepath.Join(wd, "testdata", "init_path_tests", name)) + n := &IntegrationTestCase{ + t: t, + name: name, + rootPath: rootPath, + initialPath: filepath.Join(rootPath, "initial"), + finalPath: filepath.Join(rootPath, "final"), + } + j, err := ioutil.ReadFile(filepath.Join(rootPath, "testcase.json")) + if err != nil { + panic(err) + } + err = json.Unmarshal(j, n) + if err != nil { + panic(err) + } + return n +} + var jsonNils *regexp.Regexp = regexp.MustCompile(`.*: null,.*\r?\n`) var jsonCmds *regexp.Regexp = regexp.MustCompile(`(?s) "commands": \[(.*) ],`) var jsonInds *regexp.Regexp = regexp.MustCompile(`(?s)\s*\n\s*`) diff --git a/internal/test/integration_testproj.go b/internal/test/integration_testproj.go index 85fbca8b..b0176c9d 100644 --- a/internal/test/integration_testproj.go +++ b/internal/test/integration_testproj.go @@ -64,6 +64,31 @@ func NewTestProject(t *testing.T, initPath, wd string, externalProc bool, run Ru return new } +func NewTestProjectRelPath(t *testing.T, initPath, wd, relativePath string, externalProc bool, run RunFunc) *IntegrationTestProject { + new := &IntegrationTestProject{ + t: t, + origWd: wd, + env: os.Environ(), + run: run, + } + new.makeRootTempDir() + new.TempDir(ProjectRoot, "vendor") + new.CopyTree(initPath) + + // Note that the Travis darwin platform, directories with certain roots such + // as /var are actually links to a dirtree under /private. Without the patch + // below the wd, and therefore the GOPATH, is recorded as "/var/..." but the + // actual process runs in "/private/var/..." and dies due to not being in the + // GOPATH because the roots don't line up. + if externalProc && runtime.GOOS == "darwin" && needsPrivateLeader(new.tempdir) { + new.Setenv("GOPATH", filepath.Join("/private", new.tempdir)) + } else { + new.Setenv("GOPATH", new.tempdir) + } + + return new +} + func (p *IntegrationTestProject) Cleanup() { os.RemoveAll(p.tempdir) } From ee9379e56b4a92bd421f73276ca493ed7d0af361 Mon Sep 17 00:00:00 2001 From: Aiden Scandella Date: Tue, 16 May 2017 13:09:35 -0700 Subject: [PATCH 3/8] Add support for -unstable gopkg.in imports --- internal/gps/deduce.go | 21 ++++++++++++++++----- internal/gps/maybe_source.go | 5 ++++- internal/gps/vcs_source.go | 13 +++++++++---- internal/gps/vcs_source_test.go | 18 ++++++++++++++---- 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/internal/gps/deduce.go b/internal/gps/deduce.go index a5c2dd0e..917b5856 100644 --- a/internal/gps/deduce.go +++ b/internal/gps/deduce.go @@ -27,6 +27,8 @@ var ( svnSchemes = []string{"https", "http", "svn", "svn+ssh"} ) +const gopkgUnstableSuffix = "-unstable" + func validateVCSScheme(scheme, typ string) bool { // everything allows plain ssh if scheme == "ssh" { @@ -276,10 +278,18 @@ func (m gopkginDeducer) deduceSource(p string, u *url.URL) (maybeSource, error) } else { u.Path = path.Join(v[2], v[3]) } - major, err := strconv.ParseUint(v[4][1:], 10, 64) + + unstable := false + majorStr := v[4] + + if strings.HasSuffix(majorStr, gopkgUnstableSuffix) { + unstable = true + majorStr = strings.TrimSuffix(majorStr, gopkgUnstableSuffix) + } + major, err := strconv.ParseUint(majorStr[1:], 10, 64) if err != nil { // this should only be reachable if there's an error in the regex - return nil, fmt.Errorf("could not parse %q as a gopkg.in major version", v[4][1:]) + return nil, fmt.Errorf("could not parse %q as a gopkg.in major version", majorStr[1:]) } mb := make(maybeSources, len(gitSchemes)) @@ -290,9 +300,10 @@ func (m gopkginDeducer) deduceSource(p string, u *url.URL) (maybeSource, error) } u2.Scheme = scheme mb[k] = maybeGopkginSource{ - opath: v[1], - url: &u2, - major: major, + opath: v[1], + url: &u2, + major: major, + unstable: unstable, } } diff --git a/internal/gps/maybe_source.go b/internal/gps/maybe_source.go index b892ae02..8803383d 100644 --- a/internal/gps/maybe_source.go +++ b/internal/gps/maybe_source.go @@ -131,6 +131,8 @@ type maybeGopkginSource struct { url *url.URL // the major version to apply for filtering major uint64 + // whether or not the source package is "unstable" + unstable bool } func (m maybeGopkginSource) try(ctx context.Context, cachedir string, c singleSourceCache, superv *supervisor) (source, sourceState, error) { @@ -151,7 +153,8 @@ func (m maybeGopkginSource) try(ctx context.Context, cachedir string, c singleSo repo: &gitRepo{r}, }, }, - major: m.major, + major: m.major, + unstable: m.unstable, } var vl []PairedVersion diff --git a/internal/gps/vcs_source.go b/internal/gps/vcs_source.go index 189f5d69..9df2a2ea 100644 --- a/internal/gps/vcs_source.go +++ b/internal/gps/vcs_source.go @@ -278,7 +278,8 @@ func (s *gitSource) listVersions(ctx context.Context) (vlist []PairedVersion, er // according to the input URL. type gopkginSource struct { gitSource - major uint64 + major uint64 + unstable bool } func (s *gopkginSource) listVersions(ctx context.Context) ([]PairedVersion, error) { @@ -304,9 +305,7 @@ func (s *gopkginSource) listVersions(ctx context.Context) ([]PairedVersion, erro case branchVersion: // The semver lib isn't exactly the same as gopkg.in's logic, but // it's close enough that it's probably fine to use. We can be more - // exact if real problems crop up. The most obvious vector for - // problems is that we totally ignore the "unstable" designation - // right now. + // exact if real problems crop up. sv, err := semver.NewVersion(tv.name) if err != nil || sv.Major() != s.major { // not a semver-shaped branch name at all, or not the same major @@ -314,6 +313,12 @@ func (s *gopkginSource) listVersions(ctx context.Context) ([]PairedVersion, erro continue } + // Gopkg.in has a special "-unstable" suffix which we need to handle + // separately. + if s.unstable && !strings.HasSuffix(tv.name, gopkgUnstableSuffix) { + continue + } + // Turn off the default branch marker unconditionally; we can't know // which one to mark as default until we've seen them all tv.isDefault = false diff --git a/internal/gps/vcs_source_test.go b/internal/gps/vcs_source_test.go index e671a28e..88fb9c24 100644 --- a/internal/gps/vcs_source_test.go +++ b/internal/gps/vcs_source_test.go @@ -10,6 +10,7 @@ import ( "net/url" "os/exec" "reflect" + "strings" "sync" "testing" ) @@ -152,10 +153,12 @@ func testGopkginSourceInteractions(t *testing.T) { t.Errorf("URL was bad, lolwut? errtext: %s", err) return } + unstable := strings.HasSuffix(opath, gopkgUnstableSuffix) mb := maybeGopkginSource{ - opath: opath, - url: u, - major: major, + opath: opath, + url: u, + major: major, + unstable: unstable, } ctx := context.Background() @@ -240,7 +243,7 @@ func testGopkginSourceInteractions(t *testing.T) { // simultaneously run for v1, v2, and v3 filters of the target repo wg := &sync.WaitGroup{} - wg.Add(3) + wg.Add(4) go func() { tfunc("gopkg.in/sdboyer/gpkt.v1", "github.com/sdboyer/gpkt", 1, []Version{ NewVersion("v1.1.0").Is(Revision("b2cb48dda625f6640b34d9ffb664533359ac8b91")), @@ -265,6 +268,13 @@ func testGopkginSourceInteractions(t *testing.T) { wg.Done() }() + go func() { + tfunc("gopkg.in/mgo.v2-unstable", "github.com/go-mgo/mgo", 2, []Version{ + newDefaultBranch("v2-unstable").Is(Revision("9a2573d4ae52a2bf9f5b7900a50e2f8bcceeb774")), + }) + wg.Done() + }() + wg.Wait() } From 331c9f6796c6ec11a378b4e1807d6aa7ca233223 Mon Sep 17 00:00:00 2001 From: Dave Cheney Date: Thu, 18 May 2017 12:51:48 +1000 Subject: [PATCH 4/8] appveyor.yml: fix failure to detect windows build errors Updates #542 Try another way to test all the packages in this project, sans vendor/, without accidentally swallowing the exit status. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index ffd4e082..b69fc971 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -34,4 +34,4 @@ deploy: false test_script: - go build github.com/golang/dep/cmd/dep - - for /f "" %%G in ('go list github.com/golang/dep/... ^| find /i /v "/vendor/"') do @go test %%G + - for /f "" %%G in ('go list github.com/golang/dep/... ^| find /i /v "/vendor/"') do ( go test %%G & IF ERRORLEVEL == 1 EXIT 1) From 87d96cf3e49ddceffd33f1ffde37e1d4ec093fe4 Mon Sep 17 00:00:00 2001 From: Aiden Scandella Date: Thu, 18 May 2017 13:40:58 -0700 Subject: [PATCH 5/8] Handle both cases --- internal/gps/vcs_source.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/gps/vcs_source.go b/internal/gps/vcs_source.go index 9df2a2ea..a8a06496 100644 --- a/internal/gps/vcs_source.go +++ b/internal/gps/vcs_source.go @@ -315,7 +315,7 @@ func (s *gopkginSource) listVersions(ctx context.Context) ([]PairedVersion, erro // Gopkg.in has a special "-unstable" suffix which we need to handle // separately. - if s.unstable && !strings.HasSuffix(tv.name, gopkgUnstableSuffix) { + if s.unstable != strings.HasSuffix(tv.name, gopkgUnstableSuffix) { continue } From d8abdbf5a99cce95678b4447d2da5c45977ad773 Mon Sep 17 00:00:00 2001 From: Niranjan Godbole Date: Sat, 20 May 2017 15:00:04 +0530 Subject: [PATCH 6/8] dep init refactor tests --- cmd/dep/integration_test.go | 7 +++---- cmd/dep/remove_test.go | 2 +- internal/test/integration_testcase.go | 24 ++---------------------- internal/test/integration_testproj.go | 25 ------------------------- 4 files changed, 6 insertions(+), 52 deletions(-) diff --git a/cmd/dep/integration_test.go b/cmd/dep/integration_test.go index dccd4097..8e7ce144 100644 --- a/cmd/dep/integration_test.go +++ b/cmd/dep/integration_test.go @@ -109,7 +109,7 @@ func testIntegration(name, wd string, externalProc bool, run test.RunFunc) func( t.Parallel() // Set up environment - testCase := test.NewTestCase(t, name, wd) + testCase := test.NewTestCase(t, name, "harness_tests", wd) defer testCase.Cleanup() testProj := test.NewTestProject(t, testCase.InitialPath(), wd, externalProc, run) defer testProj.Cleanup() @@ -158,9 +158,9 @@ func testRelativePath(name, wd string, externalProc bool, run test.RunFunc) func t.Parallel() // Set up environment - testCase := test.NewTestCaseRelPath(t, name, wd) + testCase := test.NewTestCase(t, name, "init_path_tests", wd) defer testCase.Cleanup() - testProj := test.NewTestProjectRelPath(t, testCase.InitialPath(), testCase.InitPath, wd, externalProc, run) + testProj := test.NewTestProject(t, testCase.InitialPath(), wd, externalProc, run) defer testProj.Cleanup() // Create and checkout the vendor revisions @@ -196,7 +196,6 @@ func testRelativePath(name, wd string, externalProc bool, run test.RunFunc) func testCase.CompareFile(dep.ManifestName, testProj.ProjPath(dep.ManifestName)) testCase.CompareFile(dep.LockName, testProj.ProjPath(dep.LockName)) - // Check vendor paths testProj.CompareImportPaths() } } diff --git a/cmd/dep/remove_test.go b/cmd/dep/remove_test.go index 881ccd94..d82e7866 100644 --- a/cmd/dep/remove_test.go +++ b/cmd/dep/remove_test.go @@ -27,7 +27,7 @@ func TestRemoveErrors(t *testing.T) { func removeErrors(name, wd string, externalProc bool, run test.RunFunc) func(*testing.T) { return func(t *testing.T) { - testCase := test.NewTestCase(t, name, wd) + testCase := test.NewTestCase(t, name, "harness_tests", wd) testProj := test.NewTestProject(t, testCase.InitialPath(), wd, externalProc, run) defer testProj.Cleanup() diff --git a/internal/test/integration_testcase.go b/internal/test/integration_testcase.go index ef614d19..f894d156 100644 --- a/internal/test/integration_testcase.go +++ b/internal/test/integration_testcase.go @@ -36,28 +36,8 @@ type IntegrationTestCase struct { InitPath string `json:"init-path"` } -func NewTestCase(t *testing.T, name, wd string) *IntegrationTestCase { - rootPath := filepath.FromSlash(filepath.Join(wd, "testdata", "harness_tests", name)) - n := &IntegrationTestCase{ - t: t, - name: name, - rootPath: rootPath, - initialPath: filepath.Join(rootPath, "initial"), - finalPath: filepath.Join(rootPath, "final"), - } - j, err := ioutil.ReadFile(filepath.Join(rootPath, "testcase.json")) - if err != nil { - panic(err) - } - err = json.Unmarshal(j, n) - if err != nil { - panic(err) - } - return n -} - -func NewTestCaseRelPath(t *testing.T, name, wd string) *IntegrationTestCase { - rootPath := filepath.FromSlash(filepath.Join(wd, "testdata", "init_path_tests", name)) +func NewTestCase(t *testing.T, name, test_dir, wd string) *IntegrationTestCase { + rootPath := filepath.FromSlash(filepath.Join(wd, "testdata", test_dir, name)) n := &IntegrationTestCase{ t: t, name: name, diff --git a/internal/test/integration_testproj.go b/internal/test/integration_testproj.go index b0176c9d..85fbca8b 100644 --- a/internal/test/integration_testproj.go +++ b/internal/test/integration_testproj.go @@ -64,31 +64,6 @@ func NewTestProject(t *testing.T, initPath, wd string, externalProc bool, run Ru return new } -func NewTestProjectRelPath(t *testing.T, initPath, wd, relativePath string, externalProc bool, run RunFunc) *IntegrationTestProject { - new := &IntegrationTestProject{ - t: t, - origWd: wd, - env: os.Environ(), - run: run, - } - new.makeRootTempDir() - new.TempDir(ProjectRoot, "vendor") - new.CopyTree(initPath) - - // Note that the Travis darwin platform, directories with certain roots such - // as /var are actually links to a dirtree under /private. Without the patch - // below the wd, and therefore the GOPATH, is recorded as "/var/..." but the - // actual process runs in "/private/var/..." and dies due to not being in the - // GOPATH because the roots don't line up. - if externalProc && runtime.GOOS == "darwin" && needsPrivateLeader(new.tempdir) { - new.Setenv("GOPATH", filepath.Join("/private", new.tempdir)) - } else { - new.Setenv("GOPATH", new.tempdir) - } - - return new -} - func (p *IntegrationTestProject) Cleanup() { os.RemoveAll(p.tempdir) } From 98250d43333e14696eb6e2ad1e8a04eeb3bc3ff4 Mon Sep 17 00:00:00 2001 From: Jonathan Stacks Date: Sat, 20 May 2017 10:22:09 -0500 Subject: [PATCH 7/8] Add a leading underscore to vendor backup --- project.go | 5 ++++- project_test.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/project.go b/project.go index 8b374d5b..ce0cd8f1 100644 --- a/project.go +++ b/project.go @@ -75,7 +75,10 @@ func BackupVendor(vpath, suffix string) (string, error) { return "", err } if vendorExists { - vendorbak := vpath + "-" + suffix + // vpath is a full filepath. We need to split it to prefix the backup dir + // with an "_" + vpathDir, name := filepath.Split(vpath) + vendorbak := filepath.Join(vpathDir, "_"+name+"-"+suffix) // Check if a directory with same name exists if _, err = os.Stat(vendorbak); os.IsNotExist(err) { // Rename existing vendor to vendor-{suffix} diff --git a/project_test.go b/project_test.go index 6a93a6b4..c857daa2 100644 --- a/project_test.go +++ b/project_test.go @@ -120,7 +120,7 @@ func TestBackupVendor(t *testing.T) { } // Create a backup - wantName := "vendor-sfx" + wantName := "_vendor-sfx" vendorbak, err := BackupVendor("vendor", "sfx") if err != nil { t.Fatal(err) From c4e1427f70bed5433dc818972dca37f3085c196d Mon Sep 17 00:00:00 2001 From: Aiden Scandella Date: Sun, 21 May 2017 10:45:31 -0700 Subject: [PATCH 8/8] Update tests and ignore unstable semver tags --- internal/gps/vcs_source.go | 2 +- internal/gps/vcs_source_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/gps/vcs_source.go b/internal/gps/vcs_source.go index a8a06496..d91d8054 100644 --- a/internal/gps/vcs_source.go +++ b/internal/gps/vcs_source.go @@ -298,7 +298,7 @@ func (s *gopkginSource) listVersions(ctx context.Context) ([]PairedVersion, erro pv := v.(versionPair) switch tv := pv.v.(type) { case semVersion: - if tv.sv.Major() == s.major { + if tv.sv.Major() == s.major && !s.unstable { vlist[k] = v k++ } diff --git a/internal/gps/vcs_source_test.go b/internal/gps/vcs_source_test.go index 88fb9c24..8fff2d78 100644 --- a/internal/gps/vcs_source_test.go +++ b/internal/gps/vcs_source_test.go @@ -269,8 +269,8 @@ func testGopkginSourceInteractions(t *testing.T) { }() go func() { - tfunc("gopkg.in/mgo.v2-unstable", "github.com/go-mgo/mgo", 2, []Version{ - newDefaultBranch("v2-unstable").Is(Revision("9a2573d4ae52a2bf9f5b7900a50e2f8bcceeb774")), + tfunc("github.com/sdboyer/gpkt2.v1-unstable", "github.com/sdboyer/gpkt2", 1, []Version{ + newDefaultBranch("v1-unstable").Is(Revision("24de0be8f4a0b8a44321562117749b257bfcef69")), }) wg.Done() }()