diff --git a/src/backend/app/loot_settings.cpp b/src/backend/app/loot_settings.cpp index bc57d899..0ecf67d8 100644 --- a/src/backend/app/loot_settings.cpp +++ b/src/backend/app/loot_settings.cpp @@ -35,6 +35,11 @@ using std::recursive_mutex; using std::string; namespace loot { +const std::set 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 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()); } } diff --git a/src/backend/app/loot_settings.h b/src/backend/app/loot_settings.h index 2166b29e..5736e7d5 100644 --- a/src/backend/app/loot_settings.h +++ b/src/backend/app/loot_settings.h @@ -71,6 +71,8 @@ public: YAML::Node toYaml() const; private: + static const std::set oldDefaultBranches; + static void upgradeYaml(YAML::Node& yaml); bool enableDebugLogging_; diff --git a/src/tests/backend/app/loot_settings_test.h b/src/tests/backend/app/loot_settings_test.h index 91540fee..a1b1da85 100644 --- a/src/tests/backend/app/loot_settings_test.h +++ b/src/tests/backend/app/loot_settings_test.h @@ -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) {