mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
hack: use long SHA for DOCKER_GITCOMMIT
This better aligns to GHA/CI settings, and is in general a better practice in the year 2023. We also drop the 'unsupported' fallback for `git rev-parse` in the Makefile; we have a better fallback behavior for an empty DOCKER_GITCOMMIT in `hack/make.sh`. Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
This commit is contained in:
2
Makefile
2
Makefile
@@ -7,7 +7,7 @@ BUILDX ?= $(DOCKER) buildx
|
|||||||
DOCKER_GRAPHDRIVER := $(if $(DOCKER_GRAPHDRIVER),$(DOCKER_GRAPHDRIVER),$(shell docker info 2>&1 | grep "Storage Driver" | sed 's/.*: //'))
|
DOCKER_GRAPHDRIVER := $(if $(DOCKER_GRAPHDRIVER),$(DOCKER_GRAPHDRIVER),$(shell docker info 2>&1 | grep "Storage Driver" | sed 's/.*: //'))
|
||||||
export DOCKER_GRAPHDRIVER
|
export DOCKER_GRAPHDRIVER
|
||||||
|
|
||||||
DOCKER_GITCOMMIT := $(shell git rev-parse --short HEAD || echo unsupported)
|
DOCKER_GITCOMMIT := $(shell git rev-parse HEAD)
|
||||||
export DOCKER_GITCOMMIT
|
export DOCKER_GITCOMMIT
|
||||||
|
|
||||||
# allow overriding the repository and branch that validation scripts are running
|
# allow overriding the repository and branch that validation scripts are running
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ fi
|
|||||||
if [ "$DOCKER_GITCOMMIT" ]; then
|
if [ "$DOCKER_GITCOMMIT" ]; then
|
||||||
GITCOMMIT="$DOCKER_GITCOMMIT"
|
GITCOMMIT="$DOCKER_GITCOMMIT"
|
||||||
elif command -v git &> /dev/null && [ -e .git ] && git rev-parse &> /dev/null; then
|
elif command -v git &> /dev/null && [ -e .git ] && git rev-parse &> /dev/null; then
|
||||||
GITCOMMIT=$(git rev-parse --short HEAD)
|
GITCOMMIT=$(git rev-parse HEAD)
|
||||||
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
|
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
|
||||||
GITCOMMIT="$GITCOMMIT-unsupported"
|
GITCOMMIT="$GITCOMMIT-unsupported"
|
||||||
echo "#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
echo "#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||||
@@ -66,8 +66,8 @@ elif command -v git &> /dev/null && [ -e .git ] && git rev-parse &> /dev/null; t
|
|||||||
else
|
else
|
||||||
echo >&2 'error: .git directory missing and DOCKER_GITCOMMIT not specified'
|
echo >&2 'error: .git directory missing and DOCKER_GITCOMMIT not specified'
|
||||||
echo >&2 ' Please either build with the .git directory accessible, or specify the'
|
echo >&2 ' Please either build with the .git directory accessible, or specify the'
|
||||||
echo >&2 ' exact (--short) commit hash you are building using DOCKER_GITCOMMIT for'
|
echo >&2 ' exact commit hash you are building using DOCKER_GITCOMMIT for future'
|
||||||
echo >&2 ' future accountability in diagnosing build issues. Thanks!'
|
echo >&2 ' accountability in diagnosing build issues. Thanks!'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user