1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor(logging): change VERSION_REGEX_STRING to a const

This commit is contained in:
powerjungle 2020-11-15 15:44:37 +02:00
parent 0ee37a7a09
commit 54d8c35b82
No known key found for this signature in database
GPG Key ID: 190C37B0F8665DA8

View File

@ -29,10 +29,9 @@
#include <QTimer> #include <QTimer>
#include <cassert> #include <cassert>
#define VERSION_REGEX_STRING "v([0-9]+)\\.([0-9]+)\\.([0-9]+)"
namespace { namespace {
const QString versionUrl{QStringLiteral("https://api.github.com/repos/qTox/qTox/releases/latest")}; const QString versionUrl{QStringLiteral("https://api.github.com/repos/qTox/qTox/releases/latest")};
const QString versionRegexString{QStringLiteral("v([0-9]+)\\.([0-9]+)\\.([0-9]+)")};
struct Version { struct Version {
int major; int major;
@ -43,7 +42,7 @@ struct Version {
Version tagToVersion(QString tagName) Version tagToVersion(QString tagName)
{ {
// capture tag name to avoid showing update available on dev builds which include hash as part of describe // capture tag name to avoid showing update available on dev builds which include hash as part of describe
QRegularExpression versionFormat{QStringLiteral(VERSION_REGEX_STRING)}; QRegularExpression versionFormat(versionRegexString);
auto matches = versionFormat.match(tagName); auto matches = versionFormat.match(tagName);
assert(matches.lastCapturedIndex() == 3); assert(matches.lastCapturedIndex() == 3);
@ -89,7 +88,7 @@ bool isUpdateAvailable(Version current, Version available)
bool isCurrentVersionStable() bool isCurrentVersionStable()
{ {
QRegularExpression versionRegex{QStringLiteral(VERSION_REGEX_STRING)}; QRegularExpression versionRegex(versionRegexString);
auto currentVer = versionRegex.match(GIT_DESCRIBE_EXACT); auto currentVer = versionRegex.match(GIT_DESCRIBE_EXACT);
if (currentVer.hasMatch()){ if (currentVer.hasMatch()){
return true; return true;