Browse Source

refactor(logging): change VERSION_REGEX_STRING to a const

reviewable/pr6250/r2
powerjungle 5 years ago
parent
commit
54d8c35b82
No known key found for this signature in database
GPG Key ID: 190C37B0F8665DA8
  1. 7
      src/net/updatecheck.cpp

7
src/net/updatecheck.cpp

@ -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;

Loading…
Cancel
Save