#! /bin/sh
#
# Simple test to confirm that the git sha1 reported in the docker image
# is the same as the one that's checked out.  This was added after
# allowing the build.properties generation to run without git to close the
# hole that might allow this information to disappear without us noticing.
#
REPORTED_SHA1=$(    ./bin/docker-as-user.sh ${RISKSCAPE_CLI_IMAGE} \
                            /opt/riskscape-cli/bin/riskscape --version | \
                        grep 'Git SHA1' | grep -Eo '[0-9a-z]{40}' )


GIT_SHA1=$(git rev-parse HEAD)


if [ "${GIT_SHA1}" != "${REPORTED_SHA1}" ]; then
    echo "Version mismatch"
    echo "Git reports       - '$GIT_SHA1'"
    echo "RiskScape reports - '$REPORTED_SHA1'"
    exit 1
fi
