mirror of https://github.com/status-im/consul.git
remove GIT_DESCRIBE variable since we have a revision line (#8310)
This commit is contained in:
parent
76abc184ae
commit
2a040342ba
|
@ -3,6 +3,5 @@
|
||||||
export GIT_COMMIT=$(git rev-parse --short HEAD)
|
export GIT_COMMIT=$(git rev-parse --short HEAD)
|
||||||
export GIT_COMMIT_YEAR=$(git show -s --format=%cd --date=format:%Y HEAD)
|
export GIT_COMMIT_YEAR=$(git show -s --format=%cd --date=format:%Y HEAD)
|
||||||
export GIT_DIRTY=$(test -n "`git status --porcelain`" && echo "+CHANGES" || true)
|
export GIT_DIRTY=$(test -n "`git status --porcelain`" && echo "+CHANGES" || true)
|
||||||
export GIT_DESCRIBE=$(git describe --tags --always --match "v*")
|
|
||||||
export GIT_IMPORT=github.com/hashicorp/consul/version
|
export GIT_IMPORT=github.com/hashicorp/consul/version
|
||||||
export GOLDFLAGS="-X ${GIT_IMPORT}.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X ${GIT_IMPORT}.GitDescribe=${GIT_DESCRIBE}"
|
export GOLDFLAGS="-X ${GIT_IMPORT}.GitCommit=${GIT_COMMIT}${GIT_DIRTY}
|
|
@ -21,9 +21,8 @@ ASSETFS_PATH?=agent/bindata_assetfs.go
|
||||||
GIT_COMMIT?=$(shell git rev-parse --short HEAD)
|
GIT_COMMIT?=$(shell git rev-parse --short HEAD)
|
||||||
GIT_COMMIT_YEAR?=$(shell git show -s --format=%cd --date=format:%Y HEAD)
|
GIT_COMMIT_YEAR?=$(shell git show -s --format=%cd --date=format:%Y HEAD)
|
||||||
GIT_DIRTY?=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
|
GIT_DIRTY?=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
|
||||||
GIT_DESCRIBE?=$(shell git describe --tags --always --match "v*")
|
|
||||||
GIT_IMPORT=github.com/hashicorp/consul/version
|
GIT_IMPORT=github.com/hashicorp/consul/version
|
||||||
GOLDFLAGS=-X $(GIT_IMPORT).GitCommit=$(GIT_COMMIT)$(GIT_DIRTY) -X $(GIT_IMPORT).GitDescribe=$(GIT_DESCRIBE)
|
GOLDFLAGS=-X $(GIT_IMPORT).GitCommit=$(GIT_COMMIT)$(GIT_DIRTY)
|
||||||
|
|
||||||
PROTOFILES?=$(shell find . -name '*.proto' | grep -v 'vendor/')
|
PROTOFILES?=$(shell find . -name '*.proto' | grep -v 'vendor/')
|
||||||
PROTOGOFILES=$(PROTOFILES:.proto=.pb.go)
|
PROTOGOFILES=$(PROTOFILES:.proto=.pb.go)
|
||||||
|
@ -124,7 +123,6 @@ export BUILD_CONTAINER_NAME
|
||||||
export GIT_COMMIT
|
export GIT_COMMIT
|
||||||
export GIT_COMMIT_YEAR
|
export GIT_COMMIT_YEAR
|
||||||
export GIT_DIRTY
|
export GIT_DIRTY
|
||||||
export GIT_DESCRIBE
|
|
||||||
export GOTAGS
|
export GOTAGS
|
||||||
export GOLDFLAGS
|
export GOLDFLAGS
|
||||||
|
|
||||||
|
@ -282,7 +280,6 @@ test-docker: linux go-build-image
|
||||||
-e 'GIT_COMMIT=$(GIT_COMMIT)' \
|
-e 'GIT_COMMIT=$(GIT_COMMIT)' \
|
||||||
-e 'GIT_COMMIT_YEAR=$(GIT_COMMIT_YEAR)' \
|
-e 'GIT_COMMIT_YEAR=$(GIT_COMMIT_YEAR)' \
|
||||||
-e 'GIT_DIRTY=$(GIT_DIRTY)' \
|
-e 'GIT_DIRTY=$(GIT_DIRTY)' \
|
||||||
-e 'GIT_DESCRIBE=$(GIT_DESCRIBE)' \
|
|
||||||
$(TEST_PARALLELIZATION) \
|
$(TEST_PARALLELIZATION) \
|
||||||
$(TEST_DOCKER_RESOURCE_CONSTRAINTS) \
|
$(TEST_DOCKER_RESOURCE_CONSTRAINTS) \
|
||||||
$(TEST_MODCACHE_VOL) \
|
$(TEST_MODCACHE_VOL) \
|
||||||
|
|
|
@ -110,7 +110,7 @@ function parse_version {
|
||||||
# Arguments:
|
# Arguments:
|
||||||
# $1 - Path to the top level Consul source
|
# $1 - Path to the top level Consul source
|
||||||
# $2 - boolean value for whether the release version should be parsed from the source
|
# $2 - boolean value for whether the release version should be parsed from the source
|
||||||
# $3 - boolean whether to use GIT_DESCRIBE and GIT_COMMIT environment variables
|
# $3 - boolean whether to use GIT_COMMIT environment variable
|
||||||
# $4 - boolean whether to omit the version part of the version string. (optional)
|
# $4 - boolean whether to omit the version part of the version string. (optional)
|
||||||
#
|
#
|
||||||
# Return:
|
# Return:
|
||||||
|
@ -134,7 +134,6 @@ function parse_version {
|
||||||
local use_git_env="$3"
|
local use_git_env="$3"
|
||||||
local omit_version="$4"
|
local omit_version="$4"
|
||||||
|
|
||||||
local git_version=""
|
|
||||||
local git_commit=""
|
local git_commit=""
|
||||||
|
|
||||||
if test -z "${include_release}"
|
if test -z "${include_release}"
|
||||||
|
@ -149,7 +148,6 @@ function parse_version {
|
||||||
|
|
||||||
if is_set "${use_git_env}"
|
if is_set "${use_git_env}"
|
||||||
then
|
then
|
||||||
git_version="${GIT_DESCRIBE}"
|
|
||||||
git_commit="${GIT_COMMIT}"
|
git_commit="${GIT_COMMIT}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -172,11 +170,6 @@ function parse_version {
|
||||||
done
|
done
|
||||||
|
|
||||||
local version="${version_main}"
|
local version="${version_main}"
|
||||||
# override the version from source with the value of the GIT_DESCRIBE env var if present
|
|
||||||
if test -n "${git_version}"
|
|
||||||
then
|
|
||||||
version="${git_version}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
local rel_ver=""
|
local rel_ver=""
|
||||||
if is_set "${include_release}"
|
if is_set "${include_release}"
|
||||||
|
@ -184,9 +177,8 @@ function parse_version {
|
||||||
# Default to pre-release from the source
|
# Default to pre-release from the source
|
||||||
rel_ver="${release_main}"
|
rel_ver="${release_main}"
|
||||||
|
|
||||||
# When no GIT_DESCRIBE env var is present and no release is in the source then we
|
# When no release is in the source then we are definitely in dev mode
|
||||||
# are definitely in dev mode
|
if test -z "${rel_ver}" && is_set "${use_git_env}"
|
||||||
if test -z "${git_version}" -a -z "${rel_ver}" && is_set "${use_git_env}"
|
|
||||||
then
|
then
|
||||||
rel_ver="dev"
|
rel_ver="dev"
|
||||||
fi
|
fi
|
||||||
|
@ -220,7 +212,7 @@ function get_version {
|
||||||
# Arguments:
|
# Arguments:
|
||||||
# $1 - Path to the top level Consul source
|
# $1 - Path to the top level Consul source
|
||||||
# $2 - Whether the release version should be parsed from source (optional)
|
# $2 - Whether the release version should be parsed from source (optional)
|
||||||
# $3 - Whether to use GIT_DESCRIBE and GIT_COMMIT environment variables
|
# $3 - Whether to use GIT_COMMIT environment variable
|
||||||
#
|
#
|
||||||
# Returns:
|
# Returns:
|
||||||
# 0 - success (the version is also echoed to stdout)
|
# 0 - success (the version is also echoed to stdout)
|
||||||
|
@ -519,9 +511,8 @@ function update_git_env {
|
||||||
|
|
||||||
export GIT_COMMIT=$(git rev-parse --short HEAD)
|
export GIT_COMMIT=$(git rev-parse --short HEAD)
|
||||||
export GIT_DIRTY=$(test -n "$(git status --porcelain)" && echo "+CHANGES")
|
export GIT_DIRTY=$(test -n "$(git status --porcelain)" && echo "+CHANGES")
|
||||||
export GIT_DESCRIBE=$(git describe --tags --always --match "v*")
|
|
||||||
export GIT_IMPORT=github.com/hashicorp/consul/version
|
export GIT_IMPORT=github.com/hashicorp/consul/version
|
||||||
export GOLDFLAGS="-X ${GIT_IMPORT}.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X ${GIT_IMPORT}.GitDescribe=${GIT_DESCRIBE}"
|
export GOLDFLAGS="-X ${GIT_IMPORT}.GitCommit=${GIT_COMMIT}${GIT_DIRTY}"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,13 +64,13 @@ function build_ui {
|
||||||
then
|
then
|
||||||
commit_hash=$(git rev-parse --short HEAD)
|
commit_hash=$(git rev-parse --short HEAD)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local commit_year="${GIT_COMMIT_YEAR}"
|
local commit_year="${GIT_COMMIT_YEAR}"
|
||||||
if test -z "${commit_year}"
|
if test -z "${commit_year}"
|
||||||
then
|
then
|
||||||
commit_year=$(git show -s --format=%cd --date=format:%Y HEAD)
|
commit_year=$(git show -s --format=%cd --date=format:%Y HEAD)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local logo_type="${CONSUL_BINARY_TYPE}"
|
local logo_type="${CONSUL_BINARY_TYPE}"
|
||||||
if test "$logo_type" != "oss"
|
if test "$logo_type" != "oss"
|
||||||
then
|
then
|
||||||
|
@ -140,7 +140,7 @@ function build_assetfs {
|
||||||
# * - error
|
# * - error
|
||||||
#
|
#
|
||||||
# Note:
|
# Note:
|
||||||
# The GIT_COMMIT, GIT_DIRTY and GIT_DESCRIBE environment variables will be used if present
|
# The GIT_COMMIT and GIT_DIRTY environment variables will be used if present
|
||||||
|
|
||||||
if ! test -d "$1"
|
if ! test -d "$1"
|
||||||
then
|
then
|
||||||
|
@ -157,7 +157,7 @@ function build_assetfs {
|
||||||
|
|
||||||
pushd ${sdir} > /dev/null
|
pushd ${sdir} > /dev/null
|
||||||
status "Creating the Go Build Container with image: ${image_name}"
|
status "Creating the Go Build Container with image: ${image_name}"
|
||||||
local container_id=$(docker create -it -e GIT_COMMIT=${GIT_COMMIT} -e GIT_DIRTY=${GIT_DIRTY} -e GIT_DESCRIBE=${GIT_DESCRIBE} ${image_name} make static-assets ASSETFS_PATH=bindata_assetfs.go)
|
local container_id=$(docker create -it -e GIT_COMMIT=${GIT_COMMIT} -e GIT_DIRTY=${GIT_DIRTY} ${image_name} make static-assets ASSETFS_PATH=bindata_assetfs.go)
|
||||||
local ret=$?
|
local ret=$?
|
||||||
if test $ret -eq 0
|
if test $ret -eq 0
|
||||||
then
|
then
|
||||||
|
@ -436,7 +436,7 @@ function build_consul_local {
|
||||||
if test "${arch}" != "amd64"
|
if test "${arch}" != "amd64"
|
||||||
then
|
then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"linux" )
|
"linux" )
|
||||||
# build all the binaries for Linux
|
# build all the binaries for Linux
|
||||||
|
@ -444,7 +444,7 @@ function build_consul_local {
|
||||||
*)
|
*)
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo "---> ${osarch}"
|
echo "---> ${osarch}"
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,7 @@ import (
|
||||||
var (
|
var (
|
||||||
// The git commit that was compiled. These will be filled in by the
|
// The git commit that was compiled. These will be filled in by the
|
||||||
// compiler.
|
// compiler.
|
||||||
GitCommit string
|
GitCommit string
|
||||||
GitDescribe string
|
|
||||||
|
|
||||||
// The main version number that is being run at the moment.
|
// The main version number that is being run at the moment.
|
||||||
//
|
//
|
||||||
|
@ -27,23 +26,13 @@ var (
|
||||||
// for displaying to humans.
|
// for displaying to humans.
|
||||||
func GetHumanVersion() string {
|
func GetHumanVersion() string {
|
||||||
version := Version
|
version := Version
|
||||||
if GitDescribe != "" {
|
|
||||||
version = GitDescribe
|
|
||||||
}
|
|
||||||
|
|
||||||
release := VersionPrerelease
|
release := VersionPrerelease
|
||||||
if GitDescribe == "" && release == "" {
|
|
||||||
release = "dev"
|
|
||||||
}
|
|
||||||
|
|
||||||
if release != "" {
|
if release != "" {
|
||||||
if !strings.HasSuffix(version, "-"+release) {
|
if !strings.HasSuffix(version, "-"+release) {
|
||||||
// if we tagged a prerelease version then the release is in the version already
|
// if we tagged a prerelease version then the release is in the version already
|
||||||
version += fmt.Sprintf("-%s", release)
|
version += fmt.Sprintf("-%s", release)
|
||||||
}
|
}
|
||||||
if GitCommit != "" {
|
|
||||||
version += fmt.Sprintf(" (%s)", GitCommit)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strip off any single quotes added by the git information.
|
// Strip off any single quotes added by the git information.
|
||||||
|
|
Loading…
Reference in New Issue