]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1] cmd/go: new tag selection logic
authorAndrew Gerrand <adg@golang.org>
Thu, 26 Apr 2012 18:36:07 +0000 (11:36 -0700)
committerAndrew Gerrand <adg@golang.org>
Thu, 26 Apr 2012 18:36:07 +0000 (11:36 -0700)
««« CL 6112060 / bcd5635a53b0
cmd/go: new tag selection logic

The new logic is "use go1 if it's there, otherwise no tag."
Nothing needs to say "I require go1.0.1", and I want to
preserve some flexibility in defining what tags mean.

Right now (before go1.0.1) there is only one possible tag,
"go1", and I'd like to keep it that way.

R=golang-dev, bradfitz, r, adg
CC=golang-dev
https://golang.org/cl/6112060
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/6116059

src/cmd/go/get.go
src/cmd/go/tag_test.go

index 97a6d8dc746147062dbb8a0736ed5e86a547ba0e..fe45697e28d05abb044ce2755ed8f805b367518b 100644 (file)
@@ -335,56 +335,32 @@ var goTag = regexp.MustCompile(
 // Version "goX" (or "goX.Y" or "goX.Y.Z") matches tags of the same form.
 // Version "release.rN" matches tags of the form "go.rN" (N being a floating-point number).
 // Version "weekly.YYYY-MM-DD" matches tags like "go.weekly.YYYY-MM-DD".
+//
+// NOTE(rsc): Eventually we will need to decide on some logic here.
+// For now, there is only "go1".  This matches the docs in go help get.
 func selectTag(goVersion string, tags []string) (match string) {
-       const rPrefix = "release.r"
-       if strings.HasPrefix(goVersion, rPrefix) {
-               p := "go.r"
-               v, err := strconv.ParseFloat(goVersion[len(rPrefix):], 64)
-               if err != nil {
-                       return ""
-               }
-               var matchf float64
-               for _, t := range tags {
-                       if !strings.HasPrefix(t, p) {
-                               continue
-                       }
-                       tf, err := strconv.ParseFloat(t[len(p):], 64)
-                       if err != nil {
-                               continue
-                       }
-                       if matchf < tf && tf <= v {
-                               match, matchf = t, tf
-                       }
+       for _, t := range tags {
+               if t == "go1" {
+                       return "go1"
                }
        }
-
-       const wPrefix = "weekly."
-       if strings.HasPrefix(goVersion, wPrefix) {
-               p := "go.weekly."
-               v := goVersion[len(wPrefix):]
-               for _, t := range tags {
-                       if !strings.HasPrefix(t, p) {
-                               continue
-                       }
-                       if match < t && t[len(p):] <= v {
-                               match = t
-                       }
-               }
-       }
-
-       if goTag.MatchString(goVersion) {
-               v := goVersion
-               for _, t := range tags {
-                       if !goTag.MatchString(t) {
-                               continue
-                       }
-                       if cmpGoVersion(match, t) < 0 && cmpGoVersion(t, v) <= 0 {
-                               match = t
+       return ""
+
+       /*
+               if goTag.MatchString(goVersion) {
+                       v := goVersion
+                       for _, t := range tags {
+                               if !goTag.MatchString(t) {
+                                       continue
+                               }
+                               if cmpGoVersion(match, t) < 0 && cmpGoVersion(t, v) <= 0 {
+                                       match = t
+                               }
                        }
                }
-       }
 
-       return match
+               return match
+       */
 }
 
 // cmpGoVersion returns -1, 0, +1 reporting whether
index 556a84a8e42ce5fb1246c59e116a609925c45d31..ffe218c7b6d5d77154e2428c12837f08b8871dc2 100644 (file)
@@ -50,41 +50,44 @@ var selectTagTests = []struct {
        version  string
        selected string
 }{
-       {"release.r57", ""},
-       {"release.r58.2", "go.r58.1"},
-       {"release.r59", "go.r59"},
-       {"release.r59.1", "go.r59.1"},
-       {"release.r60", "go.r59.1"},
-       {"release.r60.1", "go.r59.1"},
-       {"release.r61", "go.r61"},
-       {"release.r66", "go.r61.1"},
-       {"weekly.2010-01-01", ""},
-       {"weekly.2010-01-02", "go.weekly.2010-01-02"},
-       {"weekly.2010-01-02.1", "go.weekly.2010-01-02"},
-       {"weekly.2010-01-03", "go.weekly.2010-01-02"},
-       {"weekly.2011-10-12", "go.weekly.2011-10-12"},
-       {"weekly.2011-10-12.1", "go.weekly.2011-10-12.1"},
-       {"weekly.2011-10-13", "go.weekly.2011-10-12.1"},
-       {"weekly.2011-10-14", "go.weekly.2011-10-14"},
-       {"weekly.2011-10-14.1", "go.weekly.2011-10-14"},
-       {"weekly.2011-11-01", "go.weekly.2011-11-01"},
-       {"weekly.2014-01-01", "go.weekly.2011-11-01"},
-       {"weekly.3000-01-01", "go.weekly.2011-11-01"},
-       {"go1", "go1"},
-       {"go1.1", "go1.0.1"},
-       {"go1.998", "go1.9.2"},
-       {"go1.1000", "go1.999"},
-       {"go6", "go5"},
+       /*
+               {"release.r57", ""},
+               {"release.r58.2", "go.r58.1"},
+               {"release.r59", "go.r59"},
+               {"release.r59.1", "go.r59.1"},
+               {"release.r60", "go.r59.1"},
+               {"release.r60.1", "go.r59.1"},
+               {"release.r61", "go.r61"},
+               {"release.r66", "go.r61.1"},
+               {"weekly.2010-01-01", ""},
+               {"weekly.2010-01-02", "go.weekly.2010-01-02"},
+               {"weekly.2010-01-02.1", "go.weekly.2010-01-02"},
+               {"weekly.2010-01-03", "go.weekly.2010-01-02"},
+               {"weekly.2011-10-12", "go.weekly.2011-10-12"},
+               {"weekly.2011-10-12.1", "go.weekly.2011-10-12.1"},
+               {"weekly.2011-10-13", "go.weekly.2011-10-12.1"},
+               {"weekly.2011-10-14", "go.weekly.2011-10-14"},
+               {"weekly.2011-10-14.1", "go.weekly.2011-10-14"},
+               {"weekly.2011-11-01", "go.weekly.2011-11-01"},
+               {"weekly.2014-01-01", "go.weekly.2011-11-01"},
+               {"weekly.3000-01-01", "go.weekly.2011-11-01"},
+               {"go1", "go1"},
+               {"go1.1", "go1.0.1"},
+               {"go1.998", "go1.9.2"},
+               {"go1.1000", "go1.999"},
+               {"go6", "go5"},
 
-       // faulty versions:
-       {"release.f00", ""},
-       {"weekly.1999-01-01", ""},
-       {"junk", ""},
-       {"", ""},
-       {"go2x", ""},
-       {"go200000000000", ""},
-       {"go2.", ""},
-       {"go2.0", ""},
+               // faulty versions:
+               {"release.f00", ""},
+               {"weekly.1999-01-01", ""},
+               {"junk", ""},
+               {"", ""},
+               {"go2x", ""},
+               {"go200000000000", ""},
+               {"go2.", ""},
+               {"go2.0", ""},
+       */
+       {"anything", "go1"},
 }
 
 func TestSelectTag(t *testing.T) {