From a6163ca2722a858413446458b8fb1a057c4f3ed6 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Thu, 29 Apr 2021 22:58:08 +0200 Subject: [PATCH 1/3] DlgAbout: Add git commit date to about dialog --- CMakeLists.txt | 16 +++++++++++++++- src/dialog/dlgabout.cpp | 3 +++ src/dialog/dlgaboutdlg.ui | 40 ++++++++++++++++++++++++++------------- src/util/versionstore.cpp | 5 +++++ src/util/versionstore.h | 4 ++++ src/version.h.in | 1 + 6 files changed, 55 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b73d19c09f8..415a8303a84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -333,6 +333,20 @@ else() message(STATUS "Git describe: ${GIT_DESCRIBE}") endif() +# Get the current commit date +execute_process( + COMMAND git show --quiet --format=%cI --date=short + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT_DATE + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) +if(NOT GIT_COMMIT_DATE) + message(STATUS "Git commit date: unknown") +else() + message(STATUS "Git commit date: ${GIT_COMMIT_DATE}") +endif() + # Get the current working branch execute_process( COMMAND git rev-parse --abbrev-ref HEAD @@ -1660,7 +1674,7 @@ endif() get_target_property(BUILD_FLAGS mixxx-lib COMPILE_OPTIONS) -# uses CMAKE_PROJECT_VERSION MIXXX_VERSION_PRERELEASE GIT_BRANCH GIT_DESCRIBE BUILD_FLAGS +# uses CMAKE_PROJECT_VERSION MIXXX_VERSION_PRERELEASE GIT_BRANCH GIT_DESCRIBE GIT_COMMIT_DATE BUILD_FLAGS configure_file(src/version.h.in src/version.h @ONLY) # Windows-only resource file diff --git a/src/dialog/dlgabout.cpp b/src/dialog/dlgabout.cpp index 735307b35c8..4389c899454 100644 --- a/src/dialog/dlgabout.cpp +++ b/src/dialog/dlgabout.cpp @@ -1,6 +1,7 @@ #include "dialog/dlgabout.h" #include +#include #include "defs_urls.h" #include "moc_dlgabout.cpp" @@ -17,6 +18,8 @@ DlgAbout::DlgAbout(QWidget* parent) : QDialog(parent), Ui::DlgAboutDlg() { QStringLiteral(" ") + VersionStore::version()); git_version_label->setText(VersionStore::gitVersion()); platform_label->setText(VersionStore::platform()); + QLocale locale; + date_label->setText(locale.toString(VersionStore::date().toLocalTime(), QLocale::LongFormat)); QFile licenseFile(":/LICENSE"); if (!licenseFile.open(QIODevice::ReadOnly)) { diff --git a/src/dialog/dlgaboutdlg.ui b/src/dialog/dlgaboutdlg.ui index 045737e9d14..f2b28092be0 100644 --- a/src/dialog/dlgaboutdlg.ui +++ b/src/dialog/dlgaboutdlg.ui @@ -78,19 +78,20 @@ - - - - - 0 - 0 - - + + Unknown + + + + Git Commit Date: + + + @@ -104,17 +105,30 @@ - - + + + + Platform: + + + + + + + + 0 + 0 + + Unknown - - + + - Platform: + Unknown diff --git a/src/util/versionstore.cpp b/src/util/versionstore.cpp index c14822dcc65..6a42509ce94 100644 --- a/src/util/versionstore.cpp +++ b/src/util/versionstore.cpp @@ -39,6 +39,7 @@ const QString kMixxxVersionSuffix = QString(MIXXX_VERSION_SUFFIX); const QString kMixxx = QStringLiteral("Mixxx"); const QString kGitBranch = QString(GIT_BRANCH); const QString kGitDescribe = QString(GIT_DESCRIBE); +const QDateTime kGitCommitDate = QDateTime::fromString(GIT_COMMIT_DATE, Qt::ISODate); const QString kBuildFlags = QString(BUILD_FLAGS); } // namespace @@ -62,6 +63,10 @@ QString VersionStore::versionSuffix() { return kMixxxVersionSuffix; } +QDateTime VersionStore::date() { + return kGitCommitDate; +} + // static QString VersionStore::applicationName() { return kMixxx; diff --git a/src/util/versionstore.h b/src/util/versionstore.h index a821d35411d..e738fae762a 100644 --- a/src/util/versionstore.h +++ b/src/util/versionstore.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -17,6 +18,9 @@ class VersionStore { // Returns the application name. (e.g. "Mixxx") static QString applicationName(); + // Returns the last change date + static QDateTime date(); + // Returns the platform (e.g. "Windows x86_64") static QString platform(); diff --git a/src/version.h.in b/src/version.h.in index 71c8381ab56..f40b1d2b80e 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -10,4 +10,5 @@ #define MIXXX_VERSION_SUFFIX "@MIXXX_VERSION_PRERELEASE@" #define GIT_BRANCH "@GIT_BRANCH@" #define GIT_DESCRIBE "@GIT_DESCRIBE@" +#define GIT_COMMIT_DATE "@GIT_COMMIT_DATE@" #define BUILD_FLAGS "@BUILD_FLAGS@" From 4558da069b587279160639299e3d387b514f9094 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Thu, 29 Apr 2021 22:59:22 +0200 Subject: [PATCH 2/3] VersionStore: Use /// for documentation comments --- src/util/versionstore.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/util/versionstore.h b/src/util/versionstore.h index e738fae762a..5f007576b17 100644 --- a/src/util/versionstore.h +++ b/src/util/versionstore.h @@ -6,41 +6,41 @@ class VersionStore { public: - // Returns the current Mixxx version string (e.g. 1.12.0-alpha) + /// Returns the current Mixxx version string (e.g. 1.12.0-alpha) static QString version(); - // Returns the current Mixxx version number (e.g. 1.12.0) + /// Returns the current Mixxx version number (e.g. 1.12.0) static QVersionNumber versionNumber(); - // Returns the current Mixxx version suffix (e.g. "beta") + /// Returns the current Mixxx version suffix (e.g. "beta") static QString versionSuffix(); - // Returns the application name. (e.g. "Mixxx") + /// Returns the application name. (e.g. "Mixxx") static QString applicationName(); - // Returns the last change date + /// Returns the last change date static QDateTime date(); - // Returns the platform (e.g. "Windows x86_64") + /// Returns the platform (e.g. "Windows x86_64") static QString platform(); - // Returns the git branch (e.g. features_key) or the null - // string if the branch is unknown. + /// Returns the git branch (e.g. features_key) or the null + /// string if the branch is unknown. static QString gitBranch(); - // Returns the output of "git describe" + /// Returns the output of "git describe" static QString gitDescribe(); - // Returns the output of "git describe" and the branch name (if available) + /// Returns the output of "git describe" and the branch name (if available) static QString gitVersion(); - // Returns the build flags used to build Mixxx (e.g. "hid=1 modplug=0") or - // the null string if the flags are unknown. + /// Returns the build flags used to build Mixxx (e.g. "hid=1 modplug=0") or + /// the null string if the flags are unknown. static QString buildFlags(); - // Returns a list of the version of each dependency: + /// Returns a list of the version of each dependency: static QStringList dependencyVersions(); - // Prints out diagnostic information about this build. + /// Prints out diagnostic information about this build. static void logBuildDetails(); }; From 3e5412107e728656f2dfea0d5db781b228504dfe Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Thu, 29 Apr 2021 23:09:29 +0200 Subject: [PATCH 3/3] CMakeLists: Improve git describe format --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 415a8303a84..d93733c9d76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -319,9 +319,9 @@ if(WIN32) set(CMAKE_FIND_LIBRARY_PREFIXES "" "lib") endif() -# Get the current working branch +# Get the current commit ref execute_process( - COMMAND git describe --dirty + COMMAND git describe --tags --always --dirty=-modified WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE