summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorJakob Borg <jakob@nym.se>2014-06-23 10:38:50 +0200
committerJakob Borg <jakob@nym.se>2014-06-23 10:40:09 +0200
commita6eb690e31e029e1b2970ff5d790de5acee3ec0d (patch)
tree3552122e330c27c30740f46d66499ea2245b1ce9 /cmd
parent77fe8449ba0658b9327d08ca60715e617faa37b0 (diff)
Ensure correct version string format
Diffstat (limited to 'cmd')
-rw-r--r--cmd/syncthing/main.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go
index dfbb4957de..2feb060f54 100644
--- a/cmd/syncthing/main.go
+++ b/cmd/syncthing/main.go
@@ -18,6 +18,7 @@ import (
"os"
"os/exec"
"path/filepath"
+ "regexp"
"runtime"
"runtime/debug"
"runtime/pprof"
@@ -48,6 +49,14 @@ var (
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+(-\d+-g[0-9a-f]+)?(-dirty)?$`)
+ if !exp.MatchString(Version) {
+ l.Fatalf("Invalid version string %q;\n\tdoes not match regexp %v", Version, exp)
+ }
+ }
+
stamp, _ := strconv.Atoi(BuildStamp)
BuildDate = time.Unix(int64(stamp), 0)