From 1affc55b17cb68c748ef6f5192705b0a0d536ea0 Mon Sep 17 00:00:00 2001 From: Ulysses Souza Date: Thu, 22 Nov 2018 15:58:41 +0100 Subject: [PATCH] Adopts 'unknown' as build revision in case git cannot retrieve it. Signed-off-by: Ulysses Souza --- script/build/write-git-sha | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/script/build/write-git-sha b/script/build/write-git-sha index d16743c6f..be87f5058 100755 --- a/script/build/write-git-sha +++ b/script/build/write-git-sha @@ -2,6 +2,11 @@ # # Write the current commit sha to the file GITSHA. This file is included in # packaging so that `docker-compose version` can include the git sha. -# -set -e -git rev-parse --short HEAD > compose/GITSHA +# sets to 'unknown' and echoes a message if the command is not successful + +DOCKER_COMPOSE_GITSHA="$(git rev-parse --short HEAD)" +if [[ "${?}" != "0" ]]; then + echo "Couldn't get revision of the git repository. Setting to 'unknown' instead" + DOCKER_COMPOSE_GITSHA="unknown" +fi +echo "${DOCKER_COMPOSE_GITSHA}" > compose/GITSHA