From 3256c407fb608aabe1bb9c30b36fa2d33a4aa279 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sun, 5 May 2019 14:45:44 -0400 Subject: [PATCH] Make version numbers of snapshots more meaningful. --- .version.in | 1 + CMakeLists.txt | 29 +++++++++++++++++++++++-- glabels-batch/main.cpp | 2 +- glabels/AboutDialog.cpp | 2 +- glabels/main.cpp | 2 +- model/Version.h.in | 1 + user-docs/_build/man/glabels-batch-qt.1 | 4 ++-- user-docs/_build/man/glabels-qt.1 | 4 ++-- 8 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 .version.in diff --git a/.version.in b/.version.in new file mode 100644 index 0000000..f3e763d --- /dev/null +++ b/.version.in @@ -0,0 +1 @@ +@VERSION_STRING@ diff --git a/CMakeLists.txt b/CMakeLists.txt index 885788f..f58d062 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,26 @@ set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/" set (WEBSITE "glabels.org") set (BUG_WEBSITE "https://github.com/jimevins/glabels-qt/issues") +execute_process( + COMMAND git rev-parse --abbrev-ref HEAD + RESULT_VARIABLE BRANCH_VALID + OUTPUT_VARIABLE BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE +) +if (NOT ${BRANCH_VALID} STREQUAL "0") + set (BRANCH "Unkonwn") +endif () + +execute_process( + COMMAND git rev-list --count ${BRANCH} + RESULT_VARIABLE COMMIT_COUNT_VALID + OUTPUT_VARIABLE COMMIT_COUNT + OUTPUT_STRIP_TRAILING_WHITESPACE +) +if (NOT ${COMMIT_COUNT_VALID} STREQUAL "0") + set (COMMIT_COUNT "?") +endif () + execute_process( COMMAND git log -1 --format=%h RESULT_VARIABLE COMMIT_HASH_VALID @@ -38,11 +58,16 @@ if (NOT ${COMMIT_DATE_VALID} STREQUAL "0") endif () # Uncomment for snapshots, comment for releases -set(VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}-snapshot (${COMMIT_HASH} ${COMMIT_DATE})") +set(VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}-${BRANCH}${COMMIT_COUNT}") # Uncomment for releases, comment for snapshots #set(VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") +set(LONG_VERSION_STRING "${VERSION_STRING} (${COMMIT_HASH} ${COMMIT_DATE})") + +# Auto-generate version file +configure_file (.version.in VERSION @ONLY) + #======================================= # Packaging Information @@ -147,7 +172,7 @@ add_subdirectory (data) #======================================= message (STATUS "") message (STATUS "Project name ............ " ${CMAKE_PROJECT_NAME}) -message (STATUS "Project version ......... " ${VERSION_STRING}) +message (STATUS "Project version ......... " ${LONG_VERSION_STRING}) message (STATUS "Installation prefix ..... " ${CMAKE_INSTALL_PREFIX}) message (STATUS "Source code location .... " ${glabels_SOURCE_DIR}) message (STATUS "CMake version ........... " ${CMAKE_VERSION}) diff --git a/glabels-batch/main.cpp b/glabels-batch/main.cpp index e857f44..a89d045 100644 --- a/glabels-batch/main.cpp +++ b/glabels-batch/main.cpp @@ -60,7 +60,7 @@ int main( int argc, char **argv ) QCoreApplication::setOrganizationName( "glabels.org" ); QCoreApplication::setOrganizationDomain( "glabels.org" ); QCoreApplication::setApplicationName( "glabels-batch-qt" ); - QCoreApplication::setApplicationVersion( glabels::model::Version::STRING ); + QCoreApplication::setApplicationVersion( glabels::model::Version::LONG_STRING ); // // Setup translators diff --git a/glabels/AboutDialog.cpp b/glabels/AboutDialog.cpp index ef9ff99..acfb423 100644 --- a/glabels/AboutDialog.cpp +++ b/glabels/AboutDialog.cpp @@ -38,7 +38,7 @@ namespace glabels { setupUi( this ); - QString version = tr("Version") + " " + model::Version::STRING; + QString version = tr("Version") + " " + model::Version::LONG_STRING; QString description = tr("A program to create labels and business cards."); diff --git a/glabels/main.cpp b/glabels/main.cpp index 1acdf1c..67b9c7c 100644 --- a/glabels/main.cpp +++ b/glabels/main.cpp @@ -45,7 +45,7 @@ int main( int argc, char **argv ) QCoreApplication::setOrganizationName( "glabels.org" ); QCoreApplication::setOrganizationDomain( "glabels.org" ); QCoreApplication::setApplicationName( "glabels-qt" ); - QCoreApplication::setApplicationVersion( glabels::model::Version::STRING ); + QCoreApplication::setApplicationVersion( glabels::model::Version::LONG_STRING ); // // Setup translators diff --git a/model/Version.h.in b/model/Version.h.in index b9cf033..0444361 100644 --- a/model/Version.h.in +++ b/model/Version.h.in @@ -37,6 +37,7 @@ namespace glabels const int MICRO = @glabels-qt_VERSION_PATCH@; const QString STRING = "@VERSION_STRING@"; + const QString LONG_STRING = "@LONG_VERSION_STRING@"; } } diff --git a/user-docs/_build/man/glabels-batch-qt.1 b/user-docs/_build/man/glabels-batch-qt.1 index 069178f..ce4b77f 100644 --- a/user-docs/_build/man/glabels-batch-qt.1 +++ b/user-docs/_build/man/glabels-batch-qt.1 @@ -1,6 +1,6 @@ .\" Man page generated from reStructuredText. . -.TH "GLABELS-BATCH-QT" "1" "Apr 29, 2019" "" "gLabels" +.TH "GLABELS-BATCH-QT" "1" "May 05, 2019" "" "gLabels" .SH NAME glabels-batch-qt \- batch creation of labels and business cards . @@ -110,7 +110,7 @@ Directory for manually created product templates. .UNINDENT .SH BUGS .sp -Bugs and featue requests can be reported via the gLabels issue tracking system at GitHub (<\fI\%https://github.com/jimevins/glabels\-qt/issues\fP>). You will need a GitHub account to submit new issues or to comment on existing issues. +Bugs and feature requests can be reported via the gLabels issue tracking system at GitHub (<\fI\%https://github.com/jimevins/glabels\-qt/issues\fP>). You will need a GitHub account to submit new issues or to comment on existing issues. .SH SEE ALSO .sp \fBglabels\-qt(1)\fP diff --git a/user-docs/_build/man/glabels-qt.1 b/user-docs/_build/man/glabels-qt.1 index d90c351..f68653b 100644 --- a/user-docs/_build/man/glabels-qt.1 +++ b/user-docs/_build/man/glabels-qt.1 @@ -1,6 +1,6 @@ .\" Man page generated from reStructuredText. . -.TH "GLABELS-QT" "1" "Apr 29, 2019" "" "gLabels" +.TH "GLABELS-QT" "1" "May 05, 2019" "" "gLabels" .SH NAME glabels-qt \- create labels and business cards . @@ -69,7 +69,7 @@ Directory for manually created product templates. .UNINDENT .SH BUGS .sp -Bugs and featue requests can be reported via the gLabels issue tracking system at GitHub (<\fI\%https://github.com/jimevins/glabels\-qt/issues\fP>). You will need a GitHub account to submit new issues or to comment on existing issues. +Bugs and feature requests can be reported via the gLabels issue tracking system at GitHub (<\fI\%https://github.com/jimevins/glabels\-qt/issues\fP>). You will need a GitHub account to submit new issues or to comment on existing issues. .SH SEE ALSO .sp \fBglabels\-batch\-qt(1)\fP