From d587e2f03f8a162bbc2bc73027226f641e2d52a8 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 29 Nov 2018 23:03:57 +0100 Subject: [PATCH] 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. --- wmake/wmakePrintBuild | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/wmake/wmakePrintBuild b/wmake/wmakePrintBuild index c6b21dbaab..03f26d59a0 100755 --- a/wmake/wmakePrintBuild +++ b/wmake/wmakePrintBuild @@ -4,7 +4,7 @@ # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / 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 # This file is part of OpenFOAM, licensed under GNU General Public License @@ -35,7 +35,7 @@ options: -help 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_VERSION @@ -162,23 +162,13 @@ then # Specified a version - no error possible rc=0 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" ] - then - # Mark as success and prefix with WM_PROJECT_VERSION - rc=0 - version="${WM_PROJECT_VERSION}-$version" - else - # Mark as failure - rc=1 - fi + # Abbrev commit hash + data + # Date format (YYMMDD) for authoring of the commit + version="$(git --git-dir=$WM_PROJECT_DIR/.git log -1 --date='format:%y%m%d' --format='%h-%ad' 2>/dev/null)" + + test -n "$version" + rc=$? fi