From bf59291a7941d1a23d80eb051d72e5e97210bf90 Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Tue, 22 Jan 2019 21:16:29 +0100 Subject: [PATCH] Merge PR #3343: Enrich version command's output --- .circleci/config.yml | 6 +++--- Makefile | 18 ++++++++++++------ PENDING.md | 9 +++------ version/command.go | 7 ++++++- version/version.go | 8 ++++++-- 5 files changed, 30 insertions(+), 18 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 17c5e38f6..9c6dac7a4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -44,7 +44,7 @@ deps: &dependencies name: dependencies command: | export PATH="$GOBIN:$PATH" - make get_vendor_deps + make vendor-deps jobs: setup_dependencies: @@ -260,7 +260,7 @@ jobs: popd set -x make tools - make get_vendor_deps + make vendor-deps make build-linux make localnet-start ./scripts/localnet-blocks-test.sh 40 5 10 localhost @@ -292,7 +292,7 @@ jobs: command: | source $BASH_ENV make tools - make get_vendor_deps + make vendor-deps make install - run: name: Integration tests diff --git a/Makefile b/Makefile index dbc31842c..6656bf640 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,20 @@ PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation') PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation') VERSION := $(subst v,,$(shell git describe --tags --long)) +COMMIT := $(shell git log -1 --format='%H') BUILD_TAGS = netgo -BUILD_FLAGS = -tags "${BUILD_TAGS}" -ldflags "-X github.com/cosmos/cosmos-sdk/version.Version=${VERSION}" +CAT := $(if $(filter $(OS),Windows_NT),type,cat) +BUILD_FLAGS = -tags "${BUILD_TAGS}" -ldflags \ + "-X github.com/cosmos/cosmos-sdk/version.Version=${VERSION} \ + -X github.com/cosmos/cosmos-sdk/version.Commit=${COMMIT} \ + -X github.com/cosmos/cosmos-sdk/version.VendorDirHash=$(shell $(CAT) vendor-deps)" LEDGER_ENABLED ?= true GOTOOLS = \ github.com/golang/dep/cmd/dep \ github.com/alecthomas/gometalinter \ github.com/rakyll/statik GOBIN ?= $(GOPATH)/bin -all: devtools get_vendor_deps install install_examples install_cosmos-sdk-cli test_lint test +all: devtools vendor-deps install install_examples install_cosmos-sdk-cli test_lint test # The below include contains the tools target. include scripts/Makefile @@ -17,7 +22,7 @@ include scripts/Makefile ######################################## ### CI -ci: devtools get_vendor_deps install test_cover test_lint test +ci: devtools vendor-deps install test_cover test_lint test ######################################## ### Build/Install @@ -131,10 +136,11 @@ devtools-stamp: tools go get github.com/tendermint/lint/golint touch $@ -get_vendor_deps: tools +vendor-deps: tools @echo "--> Generating vendor directory via dep ensure" @rm -rf .vendor-new @dep ensure -v -vendor-only + tar -c vendor/ | sha1sum | cut -d' ' -f1 > $@ update_vendor_deps: tools @echo "--> Running dep ensure" @@ -147,7 +153,7 @@ draw_deps: tools @goviz -i github.com/cosmos/cosmos-sdk/cmd/gaia/cmd/gaiad -d 2 | dot -Tpng -o dependency-graph.png clean: - rm -f devtools-stamp + rm -f devtools-stamp vendor-deps ######################################## ### Documentation @@ -268,7 +274,7 @@ localnet-stop: # unless there is a reason not to. # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html .PHONY: build build_cosmos-sdk-cli build_examples install install_examples install_cosmos-sdk-cli install_debug dist \ -check_tools check_dev_tools get_vendor_deps draw_deps test test_cli test_unit \ +check_tools check_dev_tools draw_deps test test_cli test_unit \ test_cover test_lint benchmark devdoc_init devdoc devdoc_save devdoc_update \ build-linux build-docker-gaiadnode localnet-start localnet-stop \ format check-ledger test_sim_gaia_nondeterminism test_sim_modules test_sim_gaia_fast \ diff --git a/PENDING.md b/PENDING.md index 67e2e7b3f..a3b72242a 100644 --- a/PENDING.md +++ b/PENDING.md @@ -19,6 +19,7 @@ BREAKING CHANGES * [\#3069](https://github.com/cosmos/cosmos-sdk/pull/3069) `--fee` flag renamed to `--fees` to support multiple coins * [\#3156](https://github.com/cosmos/cosmos-sdk/pull/3156) Remove unimplemented `gaiacli init` command * [\#2222] `gaiacli tx stake` -> `gaiacli tx staking`, `gaiacli query stake` -> `gaiacli query staking` + * [\#1894](https://github.com/cosmos/cosmos-sdk/issues/1894) `version` command now shows latest commit, vendor dir hash, and build machine info. * [\#3320](https://github.com/cosmos/cosmos-sdk/pull/3320) Ensure all `gaiacli query` commands respect the `--output` and `--indent` flags * Gaia @@ -26,6 +27,7 @@ BREAKING CHANGES * [\#3162](https://github.com/cosmos/cosmos-sdk/issues/3162) The `--gas` flag now takes `auto` instead of `simulate` in order to trigger a simulation of the tx before the actual execution. * [\#3285](https://github.com/cosmos/cosmos-sdk/pull/3285) New `gaiad tendermint version` to print libs versions + * [\#1894](https://github.com/cosmos/cosmos-sdk/pull/1894) `version` command now shows latest commit, vendor dir hash, and build machine info. * SDK * [staking] \#2513 Validator power type from Dec -> Int @@ -35,10 +37,9 @@ BREAKING CHANGES * [\#3242](https://github.com/cosmos/cosmos-sdk/issues/3242) Fix infinite gas meter utilization during aborted ante handler executions. * [x/distribution] \#3292 Enable or disable withdraw addresses with a parameter in the param store - * [\#2222] [x/staking] `/stake` -> `/staking` module rename + * [staking] \#2222 `/stake` -> `/staking` module rename * [staking] \#1268 `LooseTokens` -> `NotBondedTokens` * [staking] \#1402 Redelegation and unbonding-delegation structs changed to include multiple an array of entries - * [staking] \#3289 misc renames: * `Validator.UnbondingMinTime` -> `Validator.UnbondingCompletionTime` * `Delegation` -> `Value` in `MsgCreateValidator` and `MsgDelegate` @@ -117,12 +118,8 @@ IMPROVEMENTS slashing, and staking modules. * [\#3093](https://github.com/cosmos/cosmos-sdk/issues/3093) Ante handler does no longer read all accounts in one go when processing signatures as signature verification may fail before last signature is checked. -<<<<<<< HEAD * [staking] \#1402 Add for multiple simultaneous redelegations or unbonding-delegations within an unbonding period * [staking] \#1268 staking spec rewrite -======= - * [x/stake] \#1402 Add for multiple simultaneous redelegations or unbonding-delegations within an unbonding period ->>>>>>> Pending.md * Tendermint diff --git a/version/command.go b/version/command.go index 8f47dba8f..49cf1e021 100644 --- a/version/command.go +++ b/version/command.go @@ -2,6 +2,7 @@ package version import ( "fmt" + "runtime" "github.com/spf13/cobra" ) @@ -22,5 +23,9 @@ func GetVersion() string { // CMD func printVersion(cmd *cobra.Command, args []string) { - fmt.Println(GetVersion()) + fmt.Println("cosmos-sdk:", GetVersion()) + fmt.Println("git commit:", Commit) + fmt.Println("vendor hash:", VendorDirHash) + fmt.Printf("go version %s %s/%s\n", + runtime.Version(), runtime.GOOS, runtime.GOARCH) } diff --git a/version/version.go b/version/version.go index 407797eeb..031976ecd 100644 --- a/version/version.go +++ b/version/version.go @@ -1,5 +1,9 @@ //nolint package version -// GitCommit set by build flags -var Version = "" +// Variables set by build flags +var ( + Commit = "" + Version = "" + VendorDirHash = "" +)