diff --git a/run-container.sh b/run-container.sh index 220133d..948be08 100755 --- a/run-container.sh +++ b/run-container.sh @@ -211,6 +211,7 @@ function main --publish $PORT:5010 \ --env DOCKER_IMAGE_NAME="vasl-templates:$IMAGE_TAG" \ --env DOCKER_IMAGE_TIMESTAMP="$(date --utc +"%Y-%m-%d %H:%M:%S %:z")" \ + --env BUILD_GIT_INFO="$(get_git_info)" \ --env DOCKER_CONTAINER_NAME="$CONTAINER_NAME" \ $CONTROL_TESTS_PORT_RUN \ $VASSAL_VOLUME $VASL_MOD_VOLUME $VASL_EXTNS_VOLUME $VASL_BOARDS_VOLUME $CHAPTER_H_NOTES_VOLUME $TEMPLATE_PACK_VOLUME $USER_FILES_VOLUME \ @@ -226,6 +227,20 @@ function main # --------------------------------------------------------------------- +function get_git_info { + # NOTE: We assume the source code has a git repo, and git is installed, etc. etc., which should + # all be true, but in the event we can't get the current branch and commit ID, we return nothing, + # and nothing will be shown in the Program Info dialog in the UI. + cd "${0%/*}" + local branch=$( git branch | grep "^\*" | cut -c 3- ) + local commit=$( git log | head -n 1 | cut -f 2 -d " " | cut -c 1-8 ) + if [[ -n "$branch" && -n "$commit" ]]; then + echo "$branch:$commit" + fi +} + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + function get_target { local type=$1 local target=$2 diff --git a/vasl_templates/webapp/main.py b/vasl_templates/webapp/main.py index e0ace94..864f3b1 100644 --- a/vasl_templates/webapp/main.py +++ b/vasl_templates/webapp/main.py @@ -212,6 +212,7 @@ def get_program_info(): # check if we are running inside a Docker container if app.config.get( "IS_CONTAINER" ): # yup - return related information + params[ "BUILD_GIT_INFO" ] = os.environ.get( "BUILD_GIT_INFO" ) params[ "DOCKER_IMAGE_NAME" ] = os.environ.get( "DOCKER_IMAGE_NAME" ) params[ "DOCKER_IMAGE_TIMESTAMP" ] = datetime.strftime( parse_timestamp( os.environ.get( "DOCKER_IMAGE_TIMESTAMP" ) ), diff --git a/vasl_templates/webapp/templates/program-info-content.html b/vasl_templates/webapp/templates/program-info-content.html index 977e010..1a5ccfc 100644 --- a/vasl_templates/webapp/templates/program-info-content.html +++ b/vasl_templates/webapp/templates/program-info-content.html @@ -11,7 +11,10 @@ Docker container: {{DOCKER_CONTAINER_NAME}} ({{DOCKER_CONTAINER_ID}}) Docker image: - {{DOCKER_IMAGE_NAME}} (built {{DOCKER_IMAGE_TIMESTAMP}}) + {{DOCKER_IMAGE_NAME}} + (built {{DOCKER_IMAGE_TIMESTAMP}}) + {%if BUILD_GIT_INFO%} ({{BUILD_GIT_INFO}}) {%endif%} + {%endif%}