diff options
Diffstat (limited to 'buildconfig')
-rw-r--r-- | buildconfig/BuildConfig.cpp.in | 25 | ||||
-rw-r--r-- | buildconfig/BuildConfig.h | 4 |
2 files changed, 22 insertions, 7 deletions
diff --git a/buildconfig/BuildConfig.cpp.in b/buildconfig/BuildConfig.cpp.in index 55a0eabe..7da66f36 100644 --- a/buildconfig/BuildConfig.cpp.in +++ b/buildconfig/BuildConfig.cpp.in @@ -70,12 +70,18 @@ Config::Config() } GIT_COMMIT = "@Launcher_GIT_COMMIT@"; + GIT_TAG = "@Launcher_GIT_TAG@"; GIT_REFSPEC = "@Launcher_GIT_REFSPEC@"; - if (GIT_REFSPEC == QStringLiteral("GITDIR-NOTFOUND")) + + // Assume that builds outside of Git repos are "stable" + if (GIT_REFSPEC == QStringLiteral("GITDIR-NOTFOUND") + || GIT_TAG == QStringLiteral("GITDIR-NOTFOUND")) { - VERSION_CHANNEL = QStringLiteral("stable"); + GIT_REFSPEC = "refs/heads/stable"; + GIT_TAG = versionString(); } - else if(GIT_REFSPEC.startsWith("refs/heads/")) + + if (GIT_REFSPEC.startsWith("refs/heads/")) { VERSION_CHANNEL = GIT_REFSPEC; VERSION_CHANNEL.remove("refs/heads/"); @@ -89,7 +95,7 @@ Config::Config() } else { - VERSION_CHANNEL = QObject::tr("unknown"); + VERSION_CHANNEL = "unknown"; } VERSION_STR = "@Launcher_VERSION_STRING@"; @@ -108,12 +114,17 @@ Config::Config() SUBREDDIT_URL = "@Launcher_SUBREDDIT_URL@"; } +QString Config::versionString() const +{ + return QString("%1.%2.%3").arg(VERSION_MAJOR).arg(VERSION_MINOR).arg(VERSION_HOTFIX); +} + QString Config::printableVersionString() const { - QString vstr = QString("%1.%2.%3").arg(QString::number(VERSION_MAJOR), QString::number(VERSION_MINOR), QString::number(VERSION_HOTFIX)); + QString vstr = versionString(); // If the build is not a main release, append the channel - if(VERSION_CHANNEL != "stable") + if(VERSION_CHANNEL != "stable" && GIT_TAG != vstr) { vstr += "-" + VERSION_CHANNEL; } @@ -121,7 +132,7 @@ QString Config::printableVersionString() const // if a build number is set, also add it to the end if(VERSION_BUILD >= 0) { - vstr += "-" + QString::number(VERSION_BUILD); + vstr += "+build." + QString::number(VERSION_BUILD); } return vstr; } diff --git a/buildconfig/BuildConfig.h b/buildconfig/BuildConfig.h index 6e4a6fab..95786d82 100644 --- a/buildconfig/BuildConfig.h +++ b/buildconfig/BuildConfig.h @@ -89,6 +89,9 @@ class Config { /// The git commit hash of this build QString GIT_COMMIT; + /// The git tag of this build + QString GIT_TAG; + /// The git refspec of this build QString GIT_REFSPEC; @@ -160,6 +163,7 @@ class Config { QString MODRINTH_STAGING_URL = "https://staging-api.modrinth.com/v2"; QString MODRINTH_PROD_URL = "https://api.modrinth.com/v2"; + QString versionString() const; /** * \brief Converts the Version to a string. * \return The version number in string format (major.minor.revision.build). |