From ccf09e498d8f71ecf489dec5d975f652bb74e8c6 Mon Sep 17 00:00:00 2001 From: Silas Davis <silas@monax.io> Date: Fri, 6 Apr 2018 10:52:50 +0100 Subject: [PATCH] Add install_db make target and a hash summarising any tracked changes in the working directory that will be added to burrow --version output when burrow is build with a dirty working dir - useful for distinguishing builds against uncommitted code. Signed-off-by: Silas Davis <silas@monax.io> --- Makefile | 6 +++++- scripts/commit_hash.sh | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 scripts/commit_hash.sh diff --git a/Makefile b/Makefile index 1ae718c5..77bcfd8d 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ SHELL := /bin/bash REPO := $(shell pwd) GOFILES_NOVENDOR := $(shell go list -f "{{.Dir}}" ./...) PACKAGES_NOVENDOR := $(shell go list ./...) -COMMIT := $(shell git rev-parse --short HEAD) +COMMIT := $(shell ./scripts/commit_hash.sh) # Bosmarmot integration testing BOSMARMOT_PROJECT := github.com/monax/bosmarmot BOSMARMOT_GOPATH := ${REPO}/.gopath_bos @@ -102,6 +102,10 @@ build_race: check build_race_db build_race_client build_db: go build -ldflags "-X github.com/hyperledger/burrow/project.commit=${COMMIT}" -o ${REPO}/bin/burrow ./cmd/burrow +.PHONY: install_db +install_db: build_db + cp ${REPO}/bin/burrow ${GOPATH}/bin/burrow + # build burrow-client .PHONY: build_client build_client: diff --git a/scripts/commit_hash.sh b/scripts/commit_hash.sh new file mode 100755 index 00000000..cd20bcb1 --- /dev/null +++ b/scripts/commit_hash.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +# Gets the git commit hash of the working dir and adds an additional hash of any tracked modified files +commit=$(git describe --tags) +dirty=$(git ls-files -m) +if [[ -n ${dirty} ]]; then + commit="$commit+dirty.$(echo ${dirty} | git hash-object --stdin | head -c8)" +fi +echo "$commit" + -- GitLab