Skip to content
Snippets Groups Projects
Commit 2a0bbfc7 authored by Martyn Gigg's avatar Martyn Gigg
Browse files

Use git log rather than git describe to generate version number

git describe requires a tag to be present in the tree and in particular
errors out if a shallow clone is used. We no longer use the number of
commits after the last tag as a descriptor so "git log" will suffice.
parent 87f013aa
No related branches found
No related tags found
No related merge requests found
......@@ -95,22 +95,21 @@ find_package ( OpenSSL REQUIRED )
set ( MtdVersion_WC_LAST_CHANGED_DATE Unknown )
set ( MtdVersion_WC_LAST_CHANGED_DATETIME 0 )
set ( MtdVersion_WC_LAST_CHANGED_SHA Unknown )
set ( NOT_GIT_REPO "Not" )
if ( GIT_FOUND )
# Get the last revision
execute_process ( COMMAND ${GIT_EXECUTABLE} describe --long
OUTPUT_VARIABLE GIT_DESCRIBE
execute_process ( COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
OUTPUT_VARIABLE GIT_SHA_HEAD
ERROR_VARIABLE NOT_GIT_REPO
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if ( NOT NOT_GIT_REPO ) # i.e This is a git repository!
# Remove the tag name part
string ( REGEX MATCH "[-](.*)" MtdVersion_WC_LAST_CHANGED_REV ${GIT_DESCRIBE} )
# Extract the SHA1 part (with a 'g' prefix which stands for 'git')
# N.B. The variable comes back from 'git describe' with a line feed on the end, so we need to lose that
string ( REGEX MATCH "(g.*)[^\n]" MtdVersion_WC_LAST_CHANGED_SHA ${MtdVersion_WC_LAST_CHANGED_REV} )
# "git describe" was originally used to produce this variable and this prefixes the short
# SHA1 with a 'g'. We keep the same format here now that we use rev-parse
set ( MtdVersion_WC_LAST_CHANGED_SHA "g${GIT_SHA_HEAD}" )
# Get the date of the last commit
execute_process ( COMMAND ${GIT_EXECUTABLE} log -1 --format=format:%cD OUTPUT_VARIABLE MtdVersion_WC_LAST_CHANGED_DATE
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
......@@ -215,8 +214,8 @@ endif()
###########################################################################
# Include the file that contains the version number
# This must come after the git describe business above because it can be
# used to override the patch version number (MtdVersion_WC_LAST_CHANGED_REV)
# This must come after the git business above because it can be
# used to override the patch version number
###########################################################################
include ( VersionNumber )
......
......@@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>MantidPlot</string>
<key>CFBundleGetInfoString</key>
<string>@VERSION_MAJOR@.@VERSION_MINOR@.@MtdVersion_WC_LAST_CHANGED_REV@</string>
<string>@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@</string>
<key>CFBundleIconFile</key>
<string>MantidPlot.icns</string>
<key>CFBundleIdentifier</key>
......@@ -15,17 +15,17 @@
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>@VERSION_MAJOR@.@VERSION_MINOR@.@MtdVersion_WC_LAST_CHANGED_REV@</string>
<string>@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@</string>
<key>CFBundleName</key>
<string>MantidPlot</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>@VERSION_MAJOR@.@VERSION_MINOR@.@MtdVersion_WC_LAST_CHANGED_REV@</string>
<string>@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>@VERSION_MAJOR@.@VERSION_MINOR@.@MtdVersion_WC_LAST_CHANGED_REV@</string>
<string>@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSRequiresCarbon</key>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment