mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-08 22:31:04 +00:00
Hide build version behind plus character (fixes #473)
This commit is contained in:
parent
8ce8476547
commit
4be6a54bc0
4
build.sh
4
build.sh
@ -4,7 +4,11 @@ export COPYFILE_DISABLE=true
|
||||
export GO386=387 # Don't use SSE on 32 bit builds
|
||||
|
||||
distFiles=(README.md LICENSE CONTRIBUTORS) # apart from the binary itself
|
||||
|
||||
# replace "...-12-g123abc" with "...+12-g123abc" to remain semver compatible-ish
|
||||
version=$(git describe --always --dirty)
|
||||
version=$(echo "$version" | sed 's/-\([0-9]\{1,3\}-g[0-9a-f]\{5,10\}\)/+\1/')
|
||||
|
||||
date=$(git show -s --format=%ct)
|
||||
user=$(whoami)
|
||||
host=$(hostname)
|
||||
|
@ -54,7 +54,7 @@ var l = logger.DefaultLogger
|
||||
func init() {
|
||||
if Version != "unknown-dev" {
|
||||
// If not a generic dev build, version string should come from git describe
|
||||
exp := regexp.MustCompile(`^v\d+\.\d+\.\d+(-beta\d+)?(-\d+-g[0-9a-f]+)?(-dirty)?$`)
|
||||
exp := regexp.MustCompile(`^v\d+\.\d+\.\d+(-[a-z0-9]+)*(\+\d+-g[0-9a-f]+)?(-dirty)?$`)
|
||||
if !exp.MatchString(Version) {
|
||||
l.Fatalf("Invalid version string %q;\n\tdoes not match regexp %v", Version, exp)
|
||||
}
|
||||
|
@ -114,7 +114,8 @@ func CompareVersions(a, b string) int {
|
||||
// Split a version into parts.
|
||||
// "1.2.3-beta.2" -> []int{1, 2, 3}, []interface{}{"beta", 2}
|
||||
func versionParts(v string) ([]int, []interface{}) {
|
||||
parts := strings.SplitN(v, "-", 2)
|
||||
parts := strings.SplitN(v, "+", 2)
|
||||
parts = strings.SplitN(parts[0], "-", 2)
|
||||
fields := strings.Split(parts[0], ".")
|
||||
|
||||
release := make([]int, len(fields))
|
||||
|
@ -28,6 +28,9 @@ var testcases = []struct {
|
||||
{"1.0.0-beta.2", "1.0.0-beta.11", -1},
|
||||
{"1.0.0-beta.11", "1.0.0-rc.1", -1},
|
||||
{"1.0.0-rc.1", "1.0.0", -1},
|
||||
{"1.0.0+45", "1.0.0+23-dev-foo", 0},
|
||||
{"1.0.0-beta.23+45", "1.0.0-beta.23+23-dev-foo", 0},
|
||||
{"1.0.0-beta.3+99", "1.0.0-beta.24+0", -1},
|
||||
}
|
||||
|
||||
func TestCompareVersions(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user