Beispiel #1
0
// checkVersion checks if binary matches the version of templates files.
func checkVersion() {
	// Templates.
	data, err := ioutil.ReadFile(path.Join(setting.StaticRootPath, "templates/.VERSION"))
	if err != nil {
		log.Fatal(4, "Fail to read 'templates/.VERSION': %v", err)
	}
	if string(data) != setting.AppVer {
		log.Fatal(4, "Binary and template file version does not match, did you forget to recompile?")
	}

	// Check dependency version.
	checkers := []VerChecker{
		{"github.com/Unknwon/macaron", macaron.Version, "0.5.4"},
		{"github.com/macaron-contrib/binding", binding.Version, "0.1.0"},
		{"github.com/macaron-contrib/cache", cache.Version, "0.0.7"},
		{"github.com/macaron-contrib/csrf", csrf.Version, "0.0.3"},
		{"github.com/macaron-contrib/i18n", i18n.Version, "0.0.7"},
		{"github.com/macaron-contrib/session", session.Version, "0.1.6"},
		{"gopkg.in/ini.v1", ini.Version, "1.2.0"},
	}
	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)
		}
	}
}
Beispiel #2
0
// checkVersion checks if binary matches the version of templates files.
func checkVersion() {
	// Templates.
	data, err := ioutil.ReadFile(path.Join(setting.StaticRootPath, "templates/.VERSION"))
	if err != nil {
		log.Fatal(4, "Fail to read 'templates/.VERSION': %v", err)
	}
	if string(data) != setting.AppVer {
		log.Fatal(4, "Binary and template file version does not match, did you forget to recompile?")
	}

	// Check dependency version.
	macaronVer := git.MustParseVersion(strings.Join(strings.Split(macaron.Version(), ".")[:3], "."))
	if macaronVer.LessThan(git.MustParseVersion("0.2.3")) {
		log.Fatal(4, "Package macaron version is too old, did you forget to update?(github.com/Unknwon/macaron)")
	}
	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.3")) {
		log.Fatal(4, "Package session version is too old, did you forget to update?(github.com/macaron-contrib/session)")
	}
}