}
func (r *codeRepo) Versions(prefix string) ([]string, error) {
+ // Special case: gopkg.in/macaroon-bakery.v2-unstable
+ // does not use the v2 tags (those are for macaroon-bakery.v2).
+ // It has no possible tags at all.
+ if strings.HasPrefix(r.modPath, "gopkg.in/") && strings.HasSuffix(r.modPath, "-unstable") {
+ return nil, nil
+ }
+
p := prefix
if r.codeDir != "" {
p = r.codeDir + "/" + p
if major == "" {
major = "v0"
}
+ major = strings.TrimSuffix(major, "-unstable") // make gopkg.in/macaroon-bakery.v2-unstable use "v2"
segment := fmt.Sprintf("%s-%s", t.UTC().Format("20060102150405"), rev)
build := semver.Build(older)
older = semver.Canonical(older)
}
}
if _, _, ok := SplitPathVersion(path); !ok {
- return fmt.Errorf("malformed module path %q: invalid version %s", path, path[strings.LastIndex(path, "/")+1:])
+ return fmt.Errorf("malformed module path %q: invalid version", path)
}
return nil
}
return path, "", false
}
i := len(path)
+ if strings.HasSuffix(path, "-unstable") {
+ i -= len("-unstable")
+ }
for i > 0 && ('0' <= path[i-1] && path[i-1] <= '9') {
i--
}
// MatchPathMajor reports whether the semantic version v
// matches the path major version pathMajor.
func MatchPathMajor(v, pathMajor string) bool {
+ if strings.HasPrefix(pathMajor, ".v") && strings.HasSuffix(pathMajor, "-unstable") {
+ pathMajor = strings.TrimSuffix(pathMajor, "-unstable")
+ }
if strings.HasPrefix(v, "v0.0.0-") && pathMajor == ".v1" {
// Allow old bug in pseudo-versions that generated v0.0.0- pseudoversion for gopkg .v1.
// For example, gopkg.in/yaml.v2@v2.2.1's go.mod requires gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405.
encPath := strings.Replace(name[:i], "_", "/", -1)
path, err := module.DecodePath(encPath)
if err != nil {
- fmt.Fprintf(os.Stderr, "go proxy_test: %v", err)
+ fmt.Fprintf(os.Stderr, "go proxy_test: %v\n", err)
continue
}
encVers := name[i+1:]
vers, err := module.DecodeVersion(encVers)
if err != nil {
- fmt.Fprintf(os.Stderr, "go proxy_test: %v", err)
+ fmt.Fprintf(os.Stderr, "go proxy_test: %v\n", err)
continue
}
modList = append(modList, module.Version{Path: path, Version: vers})
encVers, ext := file[:i], file[i+1:]
vers, err := module.DecodeVersion(encVers)
if err != nil {
- fmt.Fprintf(os.Stderr, "go proxy_test: %v", err)
+ fmt.Fprintf(os.Stderr, "go proxy_test: %v\n", err)
http.NotFound(w, r)
return
}
--- /dev/null
+gopkg.in/dummy.v2-unstable v2.0.0
+written by hand
+
+-- .mod --
+module gopkg.in/dummy.v2-unstable
+-- .info --
+{"Version":"v2.0.0"}
+-- dummy.go --
+package dummy
--- /dev/null
+env GO111MODULE=on
+
+cp go.mod.empty go.mod
+go get -d gopkg.in/dummy.v2-unstable
+
+cp x.go.txt x.go
+cp go.mod.empty go.mod
+go list
+
+[!net] skip
+
+env GOPROXY=
+go get gopkg.in/macaroon-bakery.v2-unstable/bakery
+go list -m all
+stdout 'gopkg.in/macaroon-bakery.v2-unstable v2.0.0-[0-9]+-[0-9a-f]+$'
+
+-- go.mod.empty --
+module m
+
+-- x.go.txt --
+package x
+import _ "gopkg.in/dummy.v2-unstable"