Merge pull request #810 from Scrumplex/refactor-launcher-version

Hide channel from version for tagged commits
This commit is contained in:
flow
2022-07-12 07:46:46 -03:00
committed by GitHub
5 changed files with 242 additions and 69 deletions

View File

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