pkg: Allow override of commit to calculate hash for show-tag

Useful to answer the question of what the hash was at the point of some older
commit.

$ make --no-print-directory -C pkg/init/ show-tag
linuxkit/init:36c56f0664d49c5a6adc1120d1bf5ba6ac30b389
$ make --no-print-directory -C pkg/init/ show-tag HASH_COMMIT=4699f80ef73141ee87a77d03f93065e541fab382
linuxkit/init:17693d233dd009b2a3a8d23673cb85969e1dce80

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
This commit is contained in:
Ian Campbell 2017-06-28 12:43:36 +01:00
parent a315e0b681
commit bdd7e7163b

View File

@ -2,10 +2,13 @@
default: push
ORG?=linuxkit
HASH?=$(shell git ls-tree --full-tree HEAD -- $(CURDIR) | awk '{print $$3}')
HASH_COMMIT?=HEAD # Setting this is only really useful with the show-tag target
HASH?=$(shell git ls-tree --full-tree $(HASH_COMMIT) -- $(CURDIR) | awk '{print $$3}')
BASE_DEPS=Dockerfile Makefile
ifneq ($(HASH_COMMIT),HEAD) # Others can't be dirty by definition
DIRTY=$(shell git diff-index --quiet HEAD -- $(CURDIR) || echo "-dirty")
endif
TAG=$(ORG)/$(IMAGE):$(HASH)$(DIRTY)
# Get a release tag, if present