summaryrefslogtreecommitdiffstats
path: root/model/version.go
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-09-17 13:01:40 -0700
committer=Corey Hulen <corey@hulen.com>2015-09-17 13:01:40 -0700
commitaf4deb2369ee6251d7f49db1d67808b773dd9db7 (patch)
tree51b6d6f6bc5501681f27d07791ea826c38105d55 /model/version.go
parent9b5198c69c01ff11b0977282b61cf2222ef2f2b1 (diff)
downloadchat-af4deb2369ee6251d7f49db1d67808b773dd9db7.tar.gz
chat-af4deb2369ee6251d7f49db1d67808b773dd9db7.tar.bz2
chat-af4deb2369ee6251d7f49db1d67808b773dd9db7.zip
Making changes to versioning
Diffstat (limited to 'model/version.go')
-rw-r--r--model/version.go56
1 files changed, 34 insertions, 22 deletions
diff --git a/model/version.go b/model/version.go
index e3e6e14b9..8b5258ec1 100644
--- a/model/version.go
+++ b/model/version.go
@@ -4,23 +4,26 @@
package model
import (
- "fmt"
"strconv"
"strings"
)
-const (
- VERSION_MAJOR = 0
- VERSION_MINOR = 8
- VERSION_PATCH = 0
- BUILD_NUMBER = "_BUILD_NUMBER_"
- BUILD_DATE = "_BUILD_DATE_"
-)
-
-func GetFullVersion() string {
- return fmt.Sprintf("%v.%v.%v", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)
+// This is a list of all the current viersions including any patches.
+// It should be maitained in chronological order with most current
+// release at the front of the list.
+var versions = []string{
+ "0.8.0",
+ "0.7.1",
+ "0.7.0",
+ "0.6.0",
+ "0.5.0",
}
+var CurrentVersion string = versions[0]
+var BuildNumber = "developer"
+var BuildDate = "unknown"
+var BuildHash = "unknown"
+
func SplitVersion(version string) (int64, int64, int64) {
parts := strings.Split(version, ".")
@@ -43,32 +46,41 @@ func SplitVersion(version string) (int64, int64, int64) {
return major, minor, patch
}
-func GetPreviousVersion(version string) (int64, int64) {
- major, minor, _ := SplitVersion(version)
+func GetPreviousVersion(currentVersion string) (int64, int64) {
+ currentIndex := -1
+ currentMajor, currentMinor, _ := SplitVersion(currentVersion)
- if minor == 0 {
- major = major - 1
- minor = 9
- } else {
- minor = minor - 1
+ for index, version := range versions {
+ major, minor, _ := SplitVersion(version)
+
+ if currentMajor == major && currentMinor == minor {
+ currentIndex = index
+ }
+
+ if currentIndex >= 0 {
+ if currentMajor != major || currentMinor != minor {
+ return major, minor
+ }
+ }
}
- return major, minor
+ return 0, 0
}
func IsCurrentVersion(versionToCheck string) bool {
+ currentMajor, currentMinor, _ := SplitVersion(CurrentVersion)
toCheckMajor, toCheckMinor, _ := SplitVersion(versionToCheck)
- if toCheckMajor == VERSION_MAJOR && toCheckMinor == VERSION_MINOR {
+ if toCheckMajor == currentMajor && toCheckMinor == currentMinor {
return true
} else {
return false
}
}
-func IsLastVersion(versionToCheck string) bool {
+func IsPreviousVersion(versionToCheck string) bool {
toCheckMajor, toCheckMinor, _ := SplitVersion(versionToCheck)
- prevMajor, prevMinor := GetPreviousVersion(GetFullVersion())
+ prevMajor, prevMinor := GetPreviousVersion(CurrentVersion)
if toCheckMajor == prevMajor && toCheckMinor == prevMinor {
return true