From edfe32735e5eaf614107710c8a187eddf0ccac89 Mon Sep 17 00:00:00 2001
From: xiadanni1 <xiadanni1@huawei.com>
Date: Wed, 10 Jun 2020 01:44:18 +0800
Subject: [PATCH] docker: use git-commit to store commit ID

Signed-off-by: xiadanni1 <xiadanni1@huawei.com>
---
 components/cli/scripts/build/.variables | 2 +-
 components/engine/hack/make.sh          | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/components/cli/scripts/build/.variables b/components/cli/scripts/build/.variables
index 86d0e3a..a23e379 100755
--- a/components/cli/scripts/build/.variables
+++ b/components/cli/scripts/build/.variables
@@ -4,7 +4,7 @@ set -eu
 PLATFORM=${PLATFORM:-}
 VERSION=${VERSION:-"unknown-version"}
 EULERVERSION=${EULERVERSION:-$(cat VERSION-vendor)}
-GITCOMMIT=${GITCOMMIT:-$(git rev-parse --short HEAD 2> /dev/null || true)}
+GITCOMMIT=${GITCOMMIT:-$(cat git-commit | head -c 7)}
 BUILDTIME=${BUILDTIME:-$(date --utc --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/')}
 
 PLATFORM_LDFLAGS=
diff --git a/components/engine/hack/make.sh b/components/engine/hack/make.sh
index 686e688..f4a51e7 100755
--- a/components/engine/hack/make.sh
+++ b/components/engine/hack/make.sh
@@ -68,6 +68,7 @@ DEFAULT_BUNDLES=(
 VERSION_EULER=$(< ./VERSION-vendor)
 VERSION=${VERSION:-dev}
 ! BUILDTIME=$(date -u -d "@${SOURCE_DATE_EPOCH:-$(date +%s)}" --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/')
+DOCKER_GITCOMMIT=$(cat git-commit | head -c 7)
 if [ "$DOCKER_GITCOMMIT" ]; then
 	GITCOMMIT="$DOCKER_GITCOMMIT"
 elif command -v git &> /dev/null && [ -e .git ] && git rev-parse &> /dev/null; then
-- 
1.8.3.1

