Backend changes for issue #99.

This should be all the backend changes required. Reading/writing of new
settings tested. Sorting works fine using default and other branches. If
an invalid branch is given, a sensible error message is produced.

Still need to update settings UI for editing the branch.
This commit is contained in:
WrinklyNinja
2014-02-01 15:02:51 +00:00
parent 84dd66ed8d
commit eaa09220bd
5 changed files with 46 additions and 28 deletions
+20 -9
View File
@@ -67,28 +67,32 @@ namespace boss {
bossFolderName = "Oblivion";
_masterFile = "Oblivion.esm";
espm_settings = espm::Settings("tes4");
_masterlistURL = "https://github.com/boss-developers/boss-oblivion.git";
_repositoryURL = "https://github.com/boss-developers/boss-oblivion.git";
_repositoryBranch = "gh-pages";
} else if (Id() == g_game_tes5) {
_name = "TES V: Skyrim";
registryKey = "Software\\Bethesda Softworks\\Skyrim\\Installed Path";
bossFolderName = "Skyrim";
_masterFile = "Skyrim.esm";
espm_settings = espm::Settings("tes5");
_masterlistURL = "https://github.com/boss-developers/boss-skyrim.git";
_repositoryURL = "https://github.com/boss-developers/boss-skyrim.git";
_repositoryBranch = "gh-pages";
} else if (Id() == g_game_fo3) {
_name = "Fallout 3";
registryKey = "Software\\Bethesda Softworks\\Fallout3\\Installed Path";
bossFolderName = "Fallout3";
_masterFile = "Fallout3.esm";
espm_settings = espm::Settings("fo3");
_masterlistURL = "https://github.com/boss-developers/boss-fallout3.git";
_repositoryURL = "https://github.com/boss-developers/boss-fallout3.git";
_repositoryBranch = "gh-pages";
} else if (Id() == g_game_fonv) {
_name = "Fallout: New Vegas";
registryKey = "Software\\Bethesda Softworks\\FalloutNV\\Installed Path";
bossFolderName = "FalloutNV";
_masterFile = "FalloutNV.esm";
espm_settings = espm::Settings("fonv");
_masterlistURL = "https://github.com/boss-developers/boss-fallout-new-vegas.git";
_repositoryURL = "https://github.com/boss-developers/boss-fallout-new-vegas.git";
_repositoryBranch = "gh-pages";
} else {
BOOST_LOG_TRIVIAL(error) << "Invalid game ID supplied.";
throw error(error::invalid_args, lc::translate("Invalid game ID supplied.").str());
@@ -99,7 +103,7 @@ namespace boss {
}
Game& Game::SetDetails(const std::string& name, const std::string& masterFile,
const std::string& url, const std::string& path, const std::string& registry) {
const std::string& repositoryURL, const std::string& repositoryBranch, const std::string& path, const std::string& registry) {
BOOST_LOG_TRIVIAL(trace) << "Setting new details for game: " << _name;
@@ -109,8 +113,11 @@ namespace boss {
if (!masterFile.empty())
_masterFile = masterFile;
if (!url.empty())
_masterlistURL = url;
if (!repositoryURL.empty())
_repositoryURL = repositoryURL;
if (!repositoryBranch.empty())
_repositoryBranch = repositoryBranch;
if (!path.empty())
gamePath = path;
@@ -201,8 +208,12 @@ namespace boss {
return registryKey;
}
std::string Game::URL() const {
return _masterlistURL;
std::string Game::RepoURL() const {
return _repositoryURL;
}
std::string Game::RepoBranch() const {
return _repositoryBranch;
}
fs::path Game::GamePath() const {
+6 -3
View File
@@ -47,7 +47,8 @@ namespace boss {
Game(const unsigned int baseGameCode, const std::string& bossFolder = "");
Game& SetDetails(const std::string& name, const std::string& masterFile,
const std::string& url, const std::string& path, const std::string& registry);
const std::string& repositoryURL, const std::string& repositoryBranch,
const std::string& path, const std::string& registry);
Game& SetPath(const std::string& path); //Used by API.
Game& Init();
@@ -60,7 +61,8 @@ namespace boss {
std::string FolderName() const;
std::string Master() const;
std::string RegistryKey() const;
std::string URL() const;
std::string RepoURL() const;
std::string RepoBranch() const;
boost::filesystem::path GamePath() const;
@@ -89,7 +91,8 @@ namespace boss {
std::string registryKey;
std::string bossFolderName;
std::string _masterlistURL;
std::string _repositoryURL;
std::string _repositoryBranch;
boost::filesystem::path gamePath; //Path to the game's folder.
boost::unordered_set<std::string> activePlugins; //Holds lowercased strings.
+3 -2
View File
@@ -587,7 +587,7 @@ namespace boss {
games.push_back(Game(g_game_tes5));
games.push_back(Game(g_game_fo3));
games.push_back(Game(g_game_fonv));
games.push_back(Game(g_game_tes4, "Nehrim").SetDetails("Nehrim - At Fate's Edge", "Nehrim.esm", "https://github.com/boss-developers/boss-oblivion.git", "", "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Nehrim - At Fate's Edge_is1"));
games.push_back(Game(g_game_tes4, "Nehrim").SetDetails("Nehrim - At Fate's Edge", "Nehrim.esm", "https://github.com/boss-developers/boss-oblivion.git", "gh-pages", "", "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Nehrim - At Fate's Edge_is1"));
root["Games"] = games;
@@ -637,7 +637,8 @@ namespace YAML {
<< Key << "folder" << Value << rhs.FolderName()
<< Key << "name" << Value << rhs.Name()
<< Key << "master" << Value << rhs.Master()
<< Key << "url" << Value << rhs.URL()
<< Key << "repo" << Value << rhs.RepoURL()
<< Key << "branch" << Value << rhs.RepoBranch()
<< Key << "path" << Value << rhs.GamePath().string()
<< Key << "registry" << Value << rhs.RegistryKey();
+9 -9
View File
@@ -167,13 +167,13 @@ namespace boss {
BOOST_LOG_TRIVIAL(trace) << "Checking to see if remote URL matches URL in settings.";
//Check if the URLs match.
BOOST_LOG_TRIVIAL(info) << "Remote URL given: " << game.URL();
//Check if the repo URLs match.
BOOST_LOG_TRIVIAL(info) << "Remote URL given: " << game.RepoURL();
BOOST_LOG_TRIVIAL(info) << "Remote URL in repository settings: " << url;
if (url != game.URL()) {
if (url != game.RepoURL()) {
BOOST_LOG_TRIVIAL(trace) << "URLs do not match, setting repository URL to URL in settings.";
//The URLs don't match. Change the remote URL to match the one BOSS has.
handle_error(git_remote_set_url(ptrs.remote, game.URL().c_str()), ptrs);
handle_error(git_remote_set_url(ptrs.remote, game.RepoURL().c_str()), ptrs);
//Now save change.
handle_error(git_remote_save(ptrs.remote), ptrs);
@@ -183,10 +183,10 @@ namespace boss {
//Repository doesn't exist. Set up a repository.
handle_error(git_repository_init(&ptrs.repo, game.MasterlistPath().parent_path().string().c_str(), false), ptrs);
BOOST_LOG_TRIVIAL(info) << "Setting the new repository's remote to: " << game.URL();
BOOST_LOG_TRIVIAL(info) << "Setting the new repository's remote to: " << game.RepoURL();
//Now set the repository's remote.
handle_error(git_remote_create(&ptrs.remote, ptrs.repo, "origin", game.URL().c_str()), ptrs);
handle_error(git_remote_create(&ptrs.remote, ptrs.repo, "origin", game.RepoURL().c_str()), ptrs);
BOOST_LOG_TRIVIAL(trace) << "Getting the repository config.";
@@ -252,15 +252,15 @@ namespace boss {
unsigned int rollbacks = 0;
char revision[10];
do {
BOOST_LOG_TRIVIAL(trace) << "Getting the Git object for the tree at refs/remotes/origin/gh-pages~" << rollbacks << ".";
BOOST_LOG_TRIVIAL(trace) << "Getting the Git object for the tree at refs/remotes/origin/" << game.RepoBranch() << "~" << rollbacks << ".";
//Get the commit hash so that we can report the revision if there is an error.
string filespec = "refs/remotes/origin/gh-pages~" + IntToString(rollbacks);
string filespec = "refs/remotes/origin/" + game.RepoBranch() + "~" + IntToString(rollbacks);
git_object * mlistObj;
handle_error(git_revparse_single(&ptrs.obj, ptrs.repo, filespec.c_str()), ptrs);
BOOST_LOG_TRIVIAL(trace) << "Checking out the tree at refs/remotes/origin/gh-pages~" << rollbacks << ".";
BOOST_LOG_TRIVIAL(trace) << "Checking out the tree at refs/remotes/origin/" << game.RepoBranch() << "~" << rollbacks << ".";
//Now we can do the checkout.
handle_error(git_checkout_tree(ptrs.repo, ptrs.obj, &opts), ptrs);
+8 -5
View File
@@ -67,7 +67,8 @@ namespace YAML {
node["name"] = rhs.Name();
node["folder"] = rhs.FolderName();
node["master"] = rhs.Master();
node["url"] = rhs.URL();
node["repo"] = rhs.RepoURL();
node["branch"] = rhs.RepoBranch();
node["path"] = rhs.GamePath().string();
node["registry"] = rhs.RegistryKey();
@@ -89,19 +90,21 @@ namespace YAML {
else
return false;
std::string name, master, url, path, registry;
std::string name, master, repo, branch, path, registry;
if (node["name"])
name = node["name"].as<std::string>();
if (node["master"])
master = node["master"].as<std::string>();
if (node["url"])
url = node["url"].as<std::string>();
if (node["repo"])
repo = node["repo"].as<std::string>();
if (node["branch"])
branch = node["branch"].as<std::string>();
if (node["path"])
path = node["path"].as<std::string>();
if (node["registry"])
registry = node["registry"].as<std::string>();
rhs.SetDetails(name, master, url, path, registry);
rhs.SetDetails(name, master, repo, branch, path, registry);
return true;
}