mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Simplify game settings branch upgrade handling
This commit is contained in:
@@ -35,6 +35,11 @@ using std::recursive_mutex;
|
||||
using std::string;
|
||||
|
||||
namespace loot {
|
||||
const std::set<std::string> LootSettings::oldDefaultBranches({
|
||||
"master",
|
||||
"v0.7",
|
||||
});
|
||||
|
||||
LootSettings::WindowPosition::WindowPosition() : top(0), bottom(0), left(0), right(0) {}
|
||||
|
||||
LootSettings::LootSettings() :
|
||||
@@ -253,17 +258,12 @@ void LootSettings::upgradeYaml(YAML::Node& yaml) {
|
||||
for (auto node : yaml["games"]) {
|
||||
if (node["url"]) {
|
||||
node["repo"] = node["url"];
|
||||
node["branch"] = "v0.8";
|
||||
node["branch"] = "master"; // It'll get updated to the correct default
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (yaml["games"]) {
|
||||
const std::set<string> oldDefaultBranches({
|
||||
"master",
|
||||
"v0.7",
|
||||
});
|
||||
|
||||
// Handle exception if YAML is invalid, eg. if an unrecognised
|
||||
// game type is used (which can happen if downgrading from a
|
||||
// later version of LOOT that supports more game types).
|
||||
@@ -280,7 +280,7 @@ void LootSettings::upgradeYaml(YAML::Node& yaml) {
|
||||
// repositories are used.
|
||||
if (settings.RepoURL() == GameSettings(settings.Type()).RepoURL()
|
||||
&& oldDefaultBranches.count(settings.RepoBranch()) == 1) {
|
||||
settings.SetRepoBranch("v0.8");
|
||||
settings.SetRepoBranch(GameSettings(settings.Type()).RepoBranch());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,8 @@ public:
|
||||
|
||||
YAML::Node toYaml() const;
|
||||
private:
|
||||
static const std::set<std::string> oldDefaultBranches;
|
||||
|
||||
static void upgradeYaml(YAML::Node& yaml);
|
||||
|
||||
bool enableDebugLogging_;
|
||||
|
||||
@@ -215,7 +215,7 @@ TEST_F(LootSettingsTest, loadingFromYamlShouldUpgradeFromVersion0Point6Format) {
|
||||
|
||||
EXPECT_EQ(Games[0].Name(), settings_.getGameSettings()[0].Name());
|
||||
EXPECT_EQ(Games[0].RepoURL(), settings_.getGameSettings()[0].RepoURL());
|
||||
EXPECT_EQ(Games[0].RepoBranch(), settings_.getGameSettings()[0].RepoBranch());
|
||||
EXPECT_EQ("master", settings_.getGameSettings()[0].RepoBranch());
|
||||
}
|
||||
|
||||
TEST_F(LootSettingsTest, loadingFromYamlShouldNotUpgradeVersion0Point6SettingsIfEquivalentsAlreadyExist) {
|
||||
|
||||
Reference in New Issue
Block a user