diff options
author | ShadowNinja <shadowninja@minetest.net> | 2015-05-04 18:46:49 -0400 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2015-05-05 17:13:05 +0200 |
commit | 1be2d32fd502eeb68bd63fb07b0325b25ee357bd (patch) | |
tree | c1c1481f91d0d933a65459354cf979d461557223 /cmake/Modules | |
parent | dfd790930c8c1464ead730999c3ac9677d130360 (diff) | |
download | minetest-1be2d32fd502eeb68bd63fb07b0325b25ee357bd.tar.gz minetest-1be2d32fd502eeb68bd63fb07b0325b25ee357bd.tar.bz2 minetest-1be2d32fd502eeb68bd63fb07b0325b25ee357bd.zip |
Make Git version detection use VERSION_STRING instead of tags
This fixes the problem where 0.4.12-dev versions were erroneously shown as
0.4.11-dev because the tag was added on a separate branch. It also fixes a
similar issue when builders didn't fetch new tags when updating.
This also removes the number-of-commits-since-tag field, since it's
incompatible with this. Said field doesn't seem to be useful anyway if you
have the commit hash.
Diffstat (limited to 'cmake/Modules')
-rw-r--r-- | cmake/Modules/GenerateVersion.cmake | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/cmake/Modules/GenerateVersion.cmake b/cmake/Modules/GenerateVersion.cmake index 9b5304ad5..ad0e38263 100644 --- a/cmake/Modules/GenerateVersion.cmake +++ b/cmake/Modules/GenerateVersion.cmake @@ -1,28 +1,24 @@ # Always run during 'make' -if(VERSION_EXTRA) - set(VERSION_GITHASH "${VERSION_STRING}") -else() - execute_process(COMMAND git describe --tag --dirty +if(DEVELOPMENT_BUILD) + execute_process(COMMAND git rev-parse --short HEAD WORKING_DIRECTORY "${GENERATE_VERSION_SOURCE_DIR}" OUTPUT_VARIABLE VERSION_GITHASH OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) - if(VERSION_GITHASH) - message(STATUS "*** Detected Git version ${VERSION_GITHASH} ***") - else() - execute_process(COMMAND git describe --always --tag --dirty + set(VERSION_GITHASH "${VERSION_STRING}-${VERSION_GITHASH}") + execute_process(COMMAND git diff-index --quiet HEAD WORKING_DIRECTORY "${GENERATE_VERSION_SOURCE_DIR}" - OUTPUT_VARIABLE VERSION_GITHASH OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET) - if(VERSION_GITHASH) - set(VERSION_GITHASH "${VERSION_STRING}-${VERSION_GITHASH}") - message(STATUS "*** Detected shallow Git version ${VERSION_GITHASH} ***") - else() - set(VERSION_GITHASH "${VERSION_STRING}") + RESULT_VARIABLE IS_DIRTY) + if(IS_DIRTY) + set(VERSION_GITHASH "${VERSION_GITHASH}-dirty") endif() + message(STATUS "*** Detected Git version ${VERSION_GITHASH} ***") endif() endif() +if(NOT VERSION_GITHASH) + set(VERSION_GITHASH "${VERSION_STRING}") +endif() configure_file( ${GENERATE_VERSION_SOURCE_DIR}/cmake_config_githash.h.in |