diff --git a/Changelog.md b/Changelog.md index f9cdce5..e37b613 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +# v26 2015/11/05 + +* Better fix for the issue fixed in v25: All update paths are now path.Clean()'d + # v25 2015/11/05 * `godep update package/` == `godep update package`. Fixes #313 diff --git a/match_test.go b/match_test.go index 57c39af..42419f6 100644 --- a/match_test.go +++ b/match_test.go @@ -22,7 +22,6 @@ func TestMatchPattern(t *testing.T) { {"net/...", "net", true}, {"net/...", "net/http", true}, {"net/...", "not/http", false}, - {"net/", "net", true}, } for _, test := range cases { ok := matchPattern(test.pat)(test.path) diff --git a/update.go b/update.go index 611d842..9dcba2e 100644 --- a/update.go +++ b/update.go @@ -4,6 +4,7 @@ import ( "go/parser" "go/token" "log" + "path" "path/filepath" "regexp" "strconv" @@ -44,6 +45,7 @@ func update(args []string) error { return err } for _, arg := range args { + arg := path.Clean(arg) any := markMatches(arg, g.Deps) if !any { log.Println("not in manifest:", arg) @@ -136,10 +138,7 @@ func matchPattern(pattern string) func(name string) bool { re := regexp.QuoteMeta(pattern) re = strings.Replace(re, `\.\.\.`, `.*`, -1) // Special case: foo/... matches foo too. - switch { - case strings.HasSuffix(re, `/`): - re = re[:len(re)-len(`/`)] + `(/)?` - case strings.HasSuffix(re, `/.*`): + if strings.HasSuffix(re, `/.*`) { re = re[:len(re)-len(`/.*`)] + `(/.*)?` } reg := regexp.MustCompile(`^` + re + `$`) diff --git a/update_test.go b/update_test.go index 9df665e..92dfa6f 100644 --- a/update_test.go +++ b/update_test.go @@ -54,6 +54,41 @@ func TestUpdate(t *testing.T) { }, }, }, + { // simple case, update one dependency, trailing slash + cwd: "C", + args: []string{"D/"}, + start: []*node{ + { + "D", + "", + []*node{ + {"main.go", pkg("D") + decl("D1"), nil}, + {"+git", "D1", nil}, + {"main.go", pkg("D") + decl("D2"), nil}, + {"+git", "D2", nil}, + }, + }, + { + "C", + "", + []*node{ + {"main.go", pkg("main", "D"), nil}, + {"Godeps/Godeps.json", godeps("C", "D", "D1"), nil}, + {"Godeps/_workspace/src/D/main.go", pkg("D") + decl("D1"), nil}, + {"+git", "", nil}, + }, + }, + }, + want: []*node{ + {"C/Godeps/_workspace/src/D/main.go", pkg("D") + decl("D2"), nil}, + }, + wdep: Godeps{ + ImportPath: "C", + Deps: []Dependency{ + {ImportPath: "D", Comment: "D2"}, + }, + }, + }, { // update one dependency, keep other one, no rewrite cwd: "C", args: []string{"D"}, diff --git a/version.go b/version.go index 8fcfae3..0a4912d 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package main -const version = 25 +const version = 26