Skip to content

Commit

Permalink
Merge pull request #3816 from Holzhaus/version-date
Browse files Browse the repository at this point in the history
Show Commit Date in About Dialog / Git Describe Format Improvements
  • Loading branch information
daschuer authored May 1, 2021
2 parents 05f4766 + 3e54121 commit 43a3964
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 29 deletions.
20 changes: 17 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/dialog/dlgabout.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "dialog/dlgabout.h"

#include <QFile>
#include <QLocale>

#include "defs_urls.h"
#include "moc_dlgabout.cpp"
Expand All @@ -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)) {
Expand Down
40 changes: 27 additions & 13 deletions src/dialog/dlgaboutdlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,8 @@
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLabel" name="git_version_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item row="2" column="1">
<widget class="QLabel" name="platform_label">
<property name="text">
<string>Unknown</string>
</property>
Expand All @@ -94,6 +88,13 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Git Commit Date:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
Expand All @@ -107,8 +108,21 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="platform_label">
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Platform:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="git_version_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Unknown</string>
</property>
Expand All @@ -117,10 +131,10 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<item row="1" column="1">
<widget class="QLabel" name="date_label">
<property name="text">
<string>Platform:</string>
<string>Unknown</string>
</property>
</widget>
</item>
Expand Down
5 changes: 5 additions & 0 deletions src/util/versionstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -62,6 +63,10 @@ QString VersionStore::versionSuffix() {
return kMixxxVersionSuffix;
}

QDateTime VersionStore::date() {
return kGitCommitDate;
}

// static
QString VersionStore::applicationName() {
return kMixxx;
Expand Down
30 changes: 17 additions & 13 deletions src/util/versionstore.h
Original file line number Diff line number Diff line change
@@ -1,42 +1,46 @@
#pragma once

#include <QDateTime>
#include <QString>
#include <QVersionNumber>

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 platform (e.g. "Windows x86_64")
/// Returns the last change date
static QDateTime date();

/// 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();
};
1 change: 1 addition & 0 deletions src/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@"

0 comments on commit 43a3964

Please sign in to comment.