helpers: Fix version string for Hugo 0.20 and similar
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 1 Mar 2017 13:34:40 +0000 (14:34 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 1 Mar 2017 13:34:40 +0000 (14:34 +0100)
Fixes #3112

helpers/hugo.go
helpers/hugo_test.go

index d1dd57f4d197f8418d1bd57b5e189c93c571143e..12d37b54dc7f21be07f05114cefe897198df926d 100644 (file)
@@ -50,14 +50,14 @@ func NextHugoReleaseVersion() string {
 
 func hugoVersion(version float32, patchVersion int, suffix string) string {
        if patchVersion > 0 {
-               return fmt.Sprintf("%.2g.%d%s", version, patchVersion, suffix)
+               return fmt.Sprintf("%.2f.%d%s", version, patchVersion, suffix)
        }
-       return fmt.Sprintf("%.2g%s", version, suffix)
+       return fmt.Sprintf("%.2f%s", version, suffix)
 }
 
 func hugoVersionNoSuffix(version float32, patchVersion int) string {
        if patchVersion > 0 {
-               return fmt.Sprintf("%.2g.%d", version, patchVersion)
+               return fmt.Sprintf("%.2f.%d", version, patchVersion)
        }
-       return fmt.Sprintf("%.2g", version)
+       return fmt.Sprintf("%.2f", version)
 }
index 8dfa7f4348cc33074e1f10bd2c9108e7f0563402..d901395e2737eccf221fa1fc1387d1bc1b3ba96a 100644 (file)
@@ -22,7 +22,7 @@ import (
 func TestHugoVersion(t *testing.T) {
        assert.Equal(t, "0.15-DEV", hugoVersion(0.15, 0, "-DEV"))
        assert.Equal(t, "0.17", hugoVersionNoSuffix(0.16+0.01, 0))
-
+       assert.Equal(t, "0.20", hugoVersionNoSuffix(0.20, 0))
        assert.Equal(t, "0.15.2-DEV", hugoVersion(0.15, 2, "-DEV"))
        assert.Equal(t, "0.17.3", hugoVersionNoSuffix(0.16+0.01, 3))
 }