Show the current git info in the Program Info dialog when running in a container.

master
Pacman Ghost 3 years ago
parent 95b7c52be4
commit a6e314f592
  1. 15
      run-container.sh
  2. 1
      vasl_templates/webapp/main.py
  3. 5
      vasl_templates/webapp/templates/program-info-content.html

@ -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

@ -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" ) ),

@ -11,7 +11,10 @@
<tr> <td class="key"> Docker container:
<td class="val"> {{DOCKER_CONTAINER_NAME}} <span class="info"> ({{DOCKER_CONTAINER_ID}}) </span>
<tr> <td class="key"> Docker image:
<td class="val"> {{DOCKER_IMAGE_NAME}} <span class="info"> (built {{DOCKER_IMAGE_TIMESTAMP}}) </span>
<td class="val"> {{DOCKER_IMAGE_NAME}} <span class="info">
(built {{DOCKER_IMAGE_TIMESTAMP}})
{%if BUILD_GIT_INFO%} ({{BUILD_GIT_INFO}}) {%endif%}
</span>
</table>
{%endif%}

Loading…
Cancel
Save