diff --git a/CMakeLists.txt b/CMakeLists.txt index 8302bb078921f50a25955898f15155a59f6a0722..f2d82bb35bcd6bbeb152f859eb154d34809483ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,6 +71,22 @@ if(WITH_TESTS) endif() endif() +find_package(Git) +if(GIT_FOUND) + execute_process(COMMAND + "${GIT_EXECUTABLE}" describe + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE copyq_git_describe_result + OUTPUT_VARIABLE copyq_git_describe_output + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(copyq_git_describe_result EQUAL 0) + message(STATUS "Building CopyQ version ${copyq_git_describe_output}.") + add_definitions( -DCOPYQ_VERSION="${copyq_git_describe_output}" ) + endif() +endif() + if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") install(FILES ${copyq_ICON_NORMAL} DESTINATION ${ICON_INSTALL_PREFIX} RENAME copyq-normal.svg) install(FILES ${copyq_ICON_BUSY} DESTINATION ${ICON_INSTALL_PREFIX} RENAME copyq-busy.svg) diff --git a/src/common/common.h b/src/common/common.h index 161c5b47161fc1dc2e95beb3a988b494e6aa2704..e8ff06f5e4ccd251d56b2f0e2eb854752e7d5218 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -26,9 +26,6 @@ #include <QtGlobal> // Q_WS_* #include <QVariantMap> -// Application version -#define COPYQ_VERSION "2.4.6" - class QAction; class QByteArray; class QIODevice; diff --git a/src/common/version.h b/src/common/version.h new file mode 100644 index 0000000000000000000000000000000000000000..96d90361d7613d738df34f2f446e7fc3ff45a569 --- /dev/null +++ b/src/common/version.h @@ -0,0 +1,8 @@ +#ifndef VERSION_H +#define VERSION_H + +#ifndef COPYQ_VERSION +# define COPYQ_VERSION "v2.4.6" +#endif + +#endif diff --git a/src/gui/aboutdialog.cpp b/src/gui/aboutdialog.cpp index 28af611fd9e2bc71c0098e1c5ab68f9acb901b9b..1935d0b36160720ba07012401974152e038dcff0 100644 --- a/src/gui/aboutdialog.cpp +++ b/src/gui/aboutdialog.cpp @@ -21,6 +21,7 @@ #include "ui_aboutdialog.h" #include "common/common.h" +#include "common/version.h" #include "configurationmanager.h" namespace { @@ -131,7 +132,7 @@ QString AboutDialog::aboutPage() "<div class='h1'>CopyQ</div>" // subtitle "<div class=\"h1x\">" + escapeHtml(tr("Clipboard Manager")) - + " v" COPYQ_VERSION "</div>" + + " " COPYQ_VERSION "</div>" "<p>" "<table class='links'>" diff --git a/src/scriptable/scriptable.cpp b/src/scriptable/scriptable.cpp index 30e2414fda558ecf908093486e7e6e93ea718298..c34c59ae4f7781beee10e53559dfb4145ecf581f 100644 --- a/src/scriptable/scriptable.cpp +++ b/src/scriptable/scriptable.cpp @@ -24,6 +24,7 @@ #include "common/commandstatus.h" #include "common/common.h" #include "common/mimetypes.h" +#include "common/version.h" #include "item/serialize.h" #include "scriptable/commandhelp.h" #include "scriptable/dirclass.h" @@ -368,7 +369,7 @@ void Scriptable::sendWindowActivationCommandToClient(const QByteArray &message) QScriptValue Scriptable::version() { - return tr(programName) + " v" COPYQ_VERSION " (hluk@email.cz)\n" + return tr(programName) + " " COPYQ_VERSION " (hluk@email.cz)\n" + tr("Built with: ") + "Qt " + QT_VERSION_STR + + ", LibQxt " + QXT_VERSION_STR @@ -386,7 +387,7 @@ QScriptValue Scriptable::help() helpString.append(hlp.toString()); helpString.append("\n" + helpTail() + "\n\n" + tr(programName) - + " v" + COPYQ_VERSION + " (hluk@email.cz)\n"); + + " " + COPYQ_VERSION + " (hluk@email.cz)\n"); } else { for (int i = 0; i < argumentCount(); ++i) { const QString &cmd = toString(argument(i)); diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp index eace6bb0b20a97f773316aa31f7042bc27fccb3f..89593cd6cd5db910267c6e153fc3111b5af40ca8 100644 --- a/src/tests/tests.cpp +++ b/src/tests/tests.cpp @@ -24,6 +24,7 @@ #include "common/common.h" #include "common/mimetypes.h" #include "common/monitormessagecode.h" +#include "common/version.h" #include "item/itemfactory.h" #include "item/itemwidget.h" #include "item/serialize.h" @@ -721,7 +722,7 @@ void Tests::versionCommand() const QString version = QString::fromUtf8(stdoutActual); // Version contains application name and version. - QVERIFY( version.contains(QRegExp("\\bCopyQ\\b.*v" + QRegExp::escape(COPYQ_VERSION))) ); + QVERIFY( version.contains(QRegExp("\\bCopyQ\\b.*" + QRegExp::escape(COPYQ_VERSION))) ); // Version contains Qt version. QVERIFY( version.contains(QRegExp("\\bQt\\s+\\d")) ); // Version contains Qxt version. diff --git a/utils/create_source_package.sh b/utils/create_source_package.sh index 5570828028bbc764c394bbd581b97ae495499d1c..ed7501d7cb479dd78e06976578198dce1d509a41 100755 --- a/utils/create_source_package.sh +++ b/utils/create_source_package.sh @@ -1,6 +1,7 @@ #!/bin/bash version=$1 out=${2:-"copyq-${version}.tar.gz"} +version_header="src/common/version.h" set -e @@ -12,6 +13,9 @@ die () { grep -q '^v'"$version"'$' CHANGES || die "CHANGES file doesn't contain changes for given version!" +grep -q '"v'"$version"'"' "$version_header" || + die "String for given version is missing in \"$version_header\" file!" + git archive --format=tar.gz --prefix="copyq-$version/" --output="$out" "v$version" || die "First arguments must be existing version (tag v<VERSION> must exist in repository)!"