From 3bb03f4c860565f8ba8b96c629384d0aa7e7ef39 Mon Sep 17 00:00:00 2001 From: Janne Paenkaelae Date: Sun, 23 Nov 2014 15:42:08 +0000 Subject: [PATCH] Update to 'consul version' behaviour After e6b6f181728b88c2e430fc7ad71fe1f84db3418c if consul was built with just running "go build" the GitDescribe would be empty and consul version would be empty. This change alters the behaviour so that if consul is build without proper ldflags the version will be postfixed with "dev" prerelease to indicate that it is self compiled in a wrong way. Should someone have a bug in such a binary at least devs should easily see from the version number that binary has not been created by recommended means. --- commands.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/commands.go b/commands.go index 3a31abd73f..2991cbae72 100644 --- a/commands.go +++ b/commands.go @@ -88,10 +88,20 @@ func init() { }, "version": func() (cli.Command, error) { + ver := "" + rel := "" + if len(GitDescribe) == 0 { + ver = Version + rel = "dev" + } else { + ver = GitDescribe + rel = VersionPrerelease + } + return &command.VersionCommand{ Revision: GitCommit, - Version: GitDescribe, - VersionPrerelease: VersionPrerelease, + Version: ver, + VersionPrerelease: rel, Ui: ui, }, nil },