]> source.dussan.org Git - gitea.git/commitdiff
fix binding api broken
authorUnknwon <joe2010xtmf@163.com>
Mon, 15 Dec 2014 06:49:59 +0000 (01:49 -0500)
committerUnknwon <joe2010xtmf@163.com>
Mon, 15 Dec 2014 06:49:59 +0000 (01:49 -0500)
cmd/web.go
gogs.go
modules/auth/apiv1/miscellaneous.go
modules/auth/auth.go
templates/.VERSION

index df9a380c115315afec4166f1c2c981d6fbfeebc3..38b802b68266ab59ff6d6171ba4c6348612ddbc6 100644 (file)
@@ -55,6 +55,12 @@ and it takes care of all the other things for you`,
        Flags:  []cli.Flag{},
 }
 
+type VerChecker struct {
+       ImportPath string
+       Version    func() string
+       Expected   string
+}
+
 // checkVersion checks if binary matches the version of templates files.
 func checkVersion() {
        // Templates.
@@ -67,17 +73,17 @@ func checkVersion() {
        }
 
        // Check dependency version.
-       macaronVer := git.MustParseVersion(strings.Join(strings.Split(macaron.Version(), ".")[:3], "."))
-       if macaronVer.LessThan(git.MustParseVersion("0.4.7")) {
-               log.Fatal(4, "Package macaron version is too old, did you forget to update?(github.com/Unknwon/macaron)")
+       checkers := []VerChecker{
+               {"github.com/Unknwon/macaron", macaron.Version, "0.4.7"},
+               {"github.com/macaron-contrib/binding", binding.Version, "0.0.2"},
+               {"github.com/macaron-contrib/i18n", i18n.Version, "0.0.3"},
+               {"github.com/macaron-contrib/session", session.Version, "0.0.5"},
        }
-       i18nVer := git.MustParseVersion(i18n.Version())
-       if i18nVer.LessThan(git.MustParseVersion("0.0.2")) {
-               log.Fatal(4, "Package i18n version is too old, did you forget to update?(github.com/macaron-contrib/i18n)")
-       }
-       sessionVer := git.MustParseVersion(session.Version())
-       if sessionVer.LessThan(git.MustParseVersion("0.0.5")) {
-               log.Fatal(4, "Package session version is too old, did you forget to update?(github.com/macaron-contrib/session)")
+       for _, c := range checkers {
+               ver := strings.Join(strings.Split(c.Version(), ".")[:3], ".")
+               if git.MustParseVersion(ver).LessThan(git.MustParseVersion(c.Expected)) {
+                       log.Fatal(4, "Package '%s' version is too old(%s -> %s), did you forget to update?", c.ImportPath, ver, c.Expected)
+               }
        }
 }
 
diff --git a/gogs.go b/gogs.go
index af8e007d0728bf416f32ef330a14d2b0ac2bd4dd..c117d4ff603b4dd03e006a304a2d3ef80328b896 100644 (file)
--- a/gogs.go
+++ b/gogs.go
@@ -17,7 +17,7 @@ import (
        "github.com/gogits/gogs/modules/setting"
 )
 
-const APP_VER = "0.5.9.1213 Beta"
+const APP_VER = "0.5.9.1215 Beta"
 
 func init() {
        runtime.GOMAXPROCS(runtime.NumCPU())
index d470ff0e45e7c63be4c9a8f9d32171b104e7924e..4e7570051e8652055d6b34f1e695f39d6b7da79d 100644 (file)
@@ -49,19 +49,19 @@ func validateApiReq(errs binding.Errors, data map[string]interface{}, f auth.For
 
                if errs[0].FieldNames[0] == field.Name {
                        switch errs[0].Classification {
-                       case binding.RequiredError:
+                       case binding.ERR_REQUIRED:
                                data["ErrorMsg"] = fieldName + " cannot be empty"
-                       case binding.AlphaDashError:
+                       case binding.ERR_ALPHA_DASH:
                                data["ErrorMsg"] = fieldName + " must be valid alpha or numeric or dash(-_) characters"
-                       case binding.AlphaDashDotError:
+                       case binding.ERR_ALPHA_DASH_DOT:
                                data["ErrorMsg"] = fieldName + " must be valid alpha or numeric or dash(-_) or dot characters"
-                       case binding.MinSizeError:
+                       case binding.ERR_MIN_SIZE:
                                data["ErrorMsg"] = fieldName + " must contain at least " + auth.GetMinSize(field) + " characters"
-                       case binding.MaxSizeError:
+                       case binding.ERR_MAX_SIZE:
                                data["ErrorMsg"] = fieldName + " must contain at most " + auth.GetMaxSize(field) + " characters"
-                       case binding.EmailError:
+                       case binding.ERR_EMAIL:
                                data["ErrorMsg"] = fieldName + " is not a valid e-mail address"
-                       case binding.UrlError:
+                       case binding.ERR_URL:
                                data["ErrorMsg"] = fieldName + " is not a valid URL"
                        default:
                                data["ErrorMsg"] = "Unknown error: " + errs[0].Classification
index acf4bf02ef2879fb4f20755d1ebd2581425fda64..1dd96d8d40a0f61255518f83d1ca439239126388 100644 (file)
@@ -204,19 +204,19 @@ func validate(errs binding.Errors, data map[string]interface{}, f Form, l macaro
                        data["Err_"+field.Name] = true
                        trName := l.Tr("form." + field.Name)
                        switch errs[0].Classification {
-                       case binding.RequiredError:
+                       case binding.ERR_REQUIRED:
                                data["ErrorMsg"] = trName + l.Tr("form.require_error")
-                       case binding.AlphaDashError:
+                       case binding.ERR_ALPHA_DASH:
                                data["ErrorMsg"] = trName + l.Tr("form.alpha_dash_error")
-                       case binding.AlphaDashDotError:
+                       case binding.ERR_ALPHA_DASH_DOT:
                                data["ErrorMsg"] = trName + l.Tr("form.alpha_dash_dot_error")
-                       case binding.MinSizeError:
+                       case binding.ERR_MIN_SIZE:
                                data["ErrorMsg"] = trName + l.Tr("form.min_size_error", GetMinSize(field))
-                       case binding.MaxSizeError:
+                       case binding.ERR_MAX_SIZE:
                                data["ErrorMsg"] = trName + l.Tr("form.max_size_error", GetMaxSize(field))
-                       case binding.EmailError:
+                       case binding.ERR_EMAIL:
                                data["ErrorMsg"] = trName + l.Tr("form.email_error")
-                       case binding.UrlError:
+                       case binding.ERR_URL:
                                data["ErrorMsg"] = trName + l.Tr("form.url_error")
                        default:
                                data["ErrorMsg"] = l.Tr("form.unknown_error") + " " + errs[0].Classification
index 05142fea35be4121ad7bf66502f1b18636d5229a..4e6350ff43c8aa09120961d5f28449211d65a023 100644 (file)
@@ -1 +1 @@
-0.5.9.1213 Beta
\ No newline at end of file
+0.5.9.1215 Beta
\ No newline at end of file