ENH: append date to build info

- append the commit hash value with the commit date when creating
  the build string information and drop the version prefix.

  This provides an immediate overview of when the code was last
  changed. The prefixed version information can be dropped from
  the build string, since it is readily available in other forms.
This commit is contained in:
Mark Olesen
2018-11-29 23:03:57 +01:00
parent 4b7e11fc8b
commit d587e2f03f

View File

@ -4,7 +4,7 @@
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. # \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, licensed under GNU General Public License # This file is part of OpenFOAM, licensed under GNU General Public License
@ -35,7 +35,7 @@ options:
-help -help
Print the version used when building the project, in this order of precedence: Print the version used when building the project, in this order of precedence:
* the git head commit (prefixed with \$WM_PROJECT_VERSION) * the git head commit
* \$WM_PROJECT_DIR/.build * \$WM_PROJECT_DIR/.build
* \$WM_PROJECT_VERSION * \$WM_PROJECT_VERSION
@ -162,23 +162,13 @@ then
# Specified a version - no error possible # Specified a version - no error possible
rc=0 rc=0
else else
# Get the head SHA1 (first 12 chars) when building under git.
# If there are multiple values (eg, HEAD, origin/HEAD, ...)
# only take the first one, which is 'HEAD'
version=$(
git --git-dir=$WM_PROJECT_DIR/.git show-ref --head HEAD 2>/dev/null |\
sed -ne '1s@^\(.\{12\}\).*$@\1@p'
)
if [ -n "$version" ] # Abbrev commit hash + data
then # Date format (YYMMDD) for authoring of the commit
# Mark as success and prefix with WM_PROJECT_VERSION version="$(git --git-dir=$WM_PROJECT_DIR/.git log -1 --date='format:%y%m%d' --format='%h-%ad' 2>/dev/null)"
rc=0
version="${WM_PROJECT_VERSION}-$version" test -n "$version"
else rc=$?
# Mark as failure
rc=1
fi
fi fi