mirror of
https://github.com/status-im/consul.git
synced 2025-01-11 14:24:39 +00:00
Merge pull request #480 from epankala/consul_version
Make the 'consul version' to return value that is from 'git describe --tags'
This commit is contained in:
commit
d6b37a9400
@ -21,7 +21,7 @@ func (c *VersionCommand) Help() string {
|
|||||||
|
|
||||||
func (c *VersionCommand) Run(_ []string) int {
|
func (c *VersionCommand) Run(_ []string) int {
|
||||||
var versionString bytes.Buffer
|
var versionString bytes.Buffer
|
||||||
fmt.Fprintf(&versionString, "Consul v%s", c.Version)
|
fmt.Fprintf(&versionString, "Consul %s", c.Version)
|
||||||
if c.VersionPrerelease != "" {
|
if c.VersionPrerelease != "" {
|
||||||
fmt.Fprintf(&versionString, ".%s", c.VersionPrerelease)
|
fmt.Fprintf(&versionString, ".%s", c.VersionPrerelease)
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ func init() {
|
|||||||
"version": func() (cli.Command, error) {
|
"version": func() (cli.Command, error) {
|
||||||
return &command.VersionCommand{
|
return &command.VersionCommand{
|
||||||
Revision: GitCommit,
|
Revision: GitCommit,
|
||||||
Version: Version,
|
Version: GitDescribe,
|
||||||
VersionPrerelease: VersionPrerelease,
|
VersionPrerelease: VersionPrerelease,
|
||||||
Ui: ui,
|
Ui: ui,
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -14,6 +14,7 @@ cd $DIR
|
|||||||
# Get the git commit
|
# Get the git commit
|
||||||
GIT_COMMIT=$(git rev-parse HEAD)
|
GIT_COMMIT=$(git rev-parse HEAD)
|
||||||
GIT_DIRTY=$(test -n "`git status --porcelain`" && echo "+CHANGES" || true)
|
GIT_DIRTY=$(test -n "`git status --porcelain`" && echo "+CHANGES" || true)
|
||||||
|
GIT_DESCRIBE=$(git describe --tags)
|
||||||
|
|
||||||
# If we're building on Windows, specify an extension
|
# If we're building on Windows, specify an extension
|
||||||
EXTENSION=""
|
EXTENSION=""
|
||||||
@ -45,7 +46,7 @@ go get \
|
|||||||
# Build!
|
# Build!
|
||||||
echo "--> Building..."
|
echo "--> Building..."
|
||||||
go build \
|
go build \
|
||||||
-ldflags "${CGO_LDFLAGS} -X main.GitCommit ${GIT_COMMIT}${GIT_DIRTY}" \
|
-ldflags "${CGO_LDFLAGS} -X main.GitCommit ${GIT_COMMIT}${GIT_DIRTY} -X main.GitDescribe ${GIT_DESCRIBE}" \
|
||||||
-v \
|
-v \
|
||||||
-o bin/consul${EXTENSION}
|
-o bin/consul${EXTENSION}
|
||||||
cp bin/consul${EXTENSION} ${GOPATHSINGLE}/bin
|
cp bin/consul${EXTENSION} ${GOPATHSINGLE}/bin
|
||||||
|
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
// The git commit that was compiled. This will be filled in by the compiler.
|
// The git commit that was compiled. This will be filled in by the compiler.
|
||||||
var GitCommit string
|
var GitCommit string
|
||||||
|
var GitDescribe string
|
||||||
|
|
||||||
// The main version number that is being run at the moment.
|
// The main version number that is being run at the moment.
|
||||||
const Version = "0.4.1"
|
const Version = "0.4.1"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user