2017-08-16 14:37:37 -07:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
2020-08-09 15:29:54 -07:00
|
|
|
// See LICENSE.txt for license information.
|
2016-04-10 14:39:38 -07:00
|
|
|
|
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2018-11-18 09:55:05 -08:00
|
|
|
// This is a list of all the current versions including any patches.
|
|
|
|
// It should be maintained in chronological order with most current
|
2016-04-10 14:39:38 -07:00
|
|
|
// release at the front of the list.
|
|
|
|
var versions = []string{
|
2020-12-31 05:48:12 -08:00
|
|
|
"5.30.0",
|
2020-11-22 06:55:57 -08:00
|
|
|
"5.29.0",
|
2020-10-19 14:40:00 -07:00
|
|
|
"5.28.0",
|
|
|
|
"5.27.0",
|
|
|
|
"5.26.0",
|
2020-08-09 15:29:54 -07:00
|
|
|
"5.25.0",
|
|
|
|
"5.24.0",
|
|
|
|
"5.23.0",
|
|
|
|
"5.22.0",
|
|
|
|
"5.21.0",
|
|
|
|
"5.20.0",
|
|
|
|
"5.19.0",
|
|
|
|
"5.18.0",
|
|
|
|
"5.17.0",
|
|
|
|
"5.16.0",
|
|
|
|
"5.15.0",
|
|
|
|
"5.14.0",
|
|
|
|
"5.13.0",
|
|
|
|
"5.12.0",
|
|
|
|
"5.11.0",
|
|
|
|
"5.10.0",
|
|
|
|
"5.9.0",
|
|
|
|
"5.8.0",
|
|
|
|
"5.7.0",
|
|
|
|
"5.6.0",
|
2018-11-18 09:55:05 -08:00
|
|
|
"5.5.0",
|
|
|
|
"5.4.0",
|
|
|
|
"5.3.0",
|
|
|
|
"5.2.0",
|
|
|
|
"5.1.0",
|
|
|
|
"5.0.0",
|
|
|
|
"4.10.0",
|
|
|
|
"4.9.0",
|
|
|
|
"4.8.1",
|
|
|
|
"4.8.0",
|
|
|
|
"4.7.2",
|
|
|
|
"4.7.1",
|
|
|
|
"4.7.0",
|
2018-02-08 15:11:04 -08:00
|
|
|
"4.6.0",
|
|
|
|
"4.5.0",
|
|
|
|
"4.4.0",
|
|
|
|
"4.3.0",
|
|
|
|
"4.2.0",
|
2017-08-16 14:37:37 -07:00
|
|
|
"4.1.0",
|
|
|
|
"4.0.0",
|
|
|
|
"3.10.0",
|
|
|
|
"3.9.0",
|
|
|
|
"3.8.0",
|
2017-03-25 13:04:10 -07:00
|
|
|
"3.7.0",
|
2017-01-16 14:59:50 -08:00
|
|
|
"3.6.0",
|
2016-11-12 13:00:53 -08:00
|
|
|
"3.5.0",
|
2016-09-17 06:19:18 -07:00
|
|
|
"3.4.0",
|
2016-08-15 09:47:31 -07:00
|
|
|
"3.3.0",
|
2016-07-22 14:14:13 -07:00
|
|
|
"3.2.0",
|
2016-06-23 11:28:05 -07:00
|
|
|
"3.1.0",
|
2016-05-15 14:02:30 -07:00
|
|
|
"3.0.0",
|
2016-04-16 11:39:43 -07:00
|
|
|
"2.2.0",
|
2016-04-10 14:39:38 -07:00
|
|
|
"2.1.0",
|
|
|
|
"2.0.0",
|
|
|
|
"1.4.0",
|
|
|
|
"1.3.0",
|
|
|
|
"1.2.1",
|
|
|
|
"1.2.0",
|
|
|
|
"1.1.0",
|
|
|
|
"1.0.0",
|
|
|
|
"0.7.1",
|
|
|
|
"0.7.0",
|
|
|
|
"0.6.0",
|
|
|
|
"0.5.0",
|
|
|
|
}
|
|
|
|
|
|
|
|
var CurrentVersion string = versions[0]
|
2016-05-15 14:02:30 -07:00
|
|
|
var BuildNumber string
|
|
|
|
var BuildDate string
|
|
|
|
var BuildHash string
|
2016-06-23 11:28:05 -07:00
|
|
|
var BuildHashEnterprise string
|
2016-05-15 14:02:30 -07:00
|
|
|
var BuildEnterpriseReady string
|
2016-04-10 14:39:38 -07:00
|
|
|
var versionsWithoutHotFixes []string
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
versionsWithoutHotFixes = make([]string, 0, len(versions))
|
|
|
|
seen := make(map[string]string)
|
|
|
|
|
|
|
|
for _, version := range versions {
|
|
|
|
maj, min, _ := SplitVersion(version)
|
|
|
|
verStr := fmt.Sprintf("%v.%v.0", maj, min)
|
|
|
|
|
|
|
|
if seen[verStr] == "" {
|
|
|
|
versionsWithoutHotFixes = append(versionsWithoutHotFixes, verStr)
|
|
|
|
seen[verStr] = verStr
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func SplitVersion(version string) (int64, int64, int64) {
|
|
|
|
parts := strings.Split(version, ".")
|
|
|
|
|
|
|
|
major := int64(0)
|
|
|
|
minor := int64(0)
|
|
|
|
patch := int64(0)
|
|
|
|
|
|
|
|
if len(parts) > 0 {
|
|
|
|
major, _ = strconv.ParseInt(parts[0], 10, 64)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(parts) > 1 {
|
|
|
|
minor, _ = strconv.ParseInt(parts[1], 10, 64)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(parts) > 2 {
|
|
|
|
patch, _ = strconv.ParseInt(parts[2], 10, 64)
|
|
|
|
}
|
|
|
|
|
|
|
|
return major, minor, patch
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetPreviousVersion(version string) string {
|
|
|
|
verMajor, verMinor, _ := SplitVersion(version)
|
|
|
|
verStr := fmt.Sprintf("%v.%v.0", verMajor, verMinor)
|
|
|
|
|
|
|
|
for index, v := range versionsWithoutHotFixes {
|
|
|
|
if v == verStr && len(versionsWithoutHotFixes) > index+1 {
|
|
|
|
return versionsWithoutHotFixes[index+1]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func IsCurrentVersion(versionToCheck string) bool {
|
|
|
|
currentMajor, currentMinor, _ := SplitVersion(CurrentVersion)
|
|
|
|
toCheckMajor, toCheckMinor, _ := SplitVersion(versionToCheck)
|
|
|
|
|
|
|
|
if toCheckMajor == currentMajor && toCheckMinor == currentMinor {
|
|
|
|
return true
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func IsPreviousVersionsSupported(versionToCheck string) bool {
|
|
|
|
toCheckMajor, toCheckMinor, _ := SplitVersion(versionToCheck)
|
|
|
|
versionToCheckStr := fmt.Sprintf("%v.%v.0", toCheckMajor, toCheckMinor)
|
|
|
|
|
|
|
|
// Current Supported
|
|
|
|
if versionsWithoutHotFixes[0] == versionToCheckStr {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// Current - 1 Supported
|
|
|
|
if versionsWithoutHotFixes[1] == versionToCheckStr {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// Current - 2 Supported
|
|
|
|
if versionsWithoutHotFixes[2] == versionToCheckStr {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2016-05-15 14:02:30 -07:00
|
|
|
// Current - 3 Supported
|
|
|
|
if versionsWithoutHotFixes[3] == versionToCheckStr {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2016-04-10 14:39:38 -07:00
|
|
|
return false
|
|
|
|
}
|