mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-26 04:03:11 +00:00
pkg: Simplify dirty handling
By setting `DIRTY` to either "-dirty" or "" directly we can simply use `$(HASH)$(DIRTY)` and avoid make adding a space as it does with `+=`. For the push check we now block pushing if `$(DIRTY)` is non-empty. Signed-off-by: Ian Campbell <ian.campbell@docker.com>
This commit is contained in:
parent
55f537631a
commit
b6728a85e9
@ -5,18 +5,8 @@ ORG?=linuxkit
|
|||||||
HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}')
|
HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}')
|
||||||
BASE_DEPS=Dockerfile Makefile
|
BASE_DEPS=Dockerfile Makefile
|
||||||
|
|
||||||
# Add '-dirty' to hash if the repository is not clean. make does not
|
DIRTY=$(shell git diff-index --quiet HEAD -- ) || echo "-dirty")
|
||||||
# concatenate strings without spaces, so we use the documented trick
|
TAG=$(HASH)$(DIRTY)
|
||||||
# of replacing the space with nothing.
|
|
||||||
DIRTY=$(shell git diff-index --quiet HEAD --; echo $$?)
|
|
||||||
ifneq ($(DIRTY),0)
|
|
||||||
HASH+=-dirty
|
|
||||||
nullstring :=
|
|
||||||
space := $(nullstring) $(nullstring)
|
|
||||||
TAG=$(subst $(space),,$(HASH))
|
|
||||||
else
|
|
||||||
TAG=$(HASH)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Get a release tag, if present
|
# Get a release tag, if present
|
||||||
RELEASE=$(shell git tag -l --points-at HEAD)
|
RELEASE=$(shell git tag -l --points-at HEAD)
|
||||||
@ -35,7 +25,7 @@ tag: $(BASE_DEPS) $(DEPS)
|
|||||||
docker build $(NET_OPT) -t $(ORG)/$(IMAGE):$(TAG) .
|
docker build $(NET_OPT) -t $(ORG)/$(IMAGE):$(TAG) .
|
||||||
|
|
||||||
push: tag
|
push: tag
|
||||||
ifneq ($(DIRTY),0)
|
ifneq ($(DIRTY),)
|
||||||
$(error Your repository is not clean. Will not push package image.)
|
$(error Your repository is not clean. Will not push package image.)
|
||||||
endif
|
endif
|
||||||
DOCKER_CONTENT_TRUST=1 docker pull $(ORG)/$(IMAGE):$(TAG) || \
|
DOCKER_CONTENT_TRUST=1 docker pull $(ORG)/$(IMAGE):$(TAG) || \
|
||||||
|
Loading…
Reference in New Issue
Block a user