From 5ba8b3ab0151c26af55d7138cd6eca0adb6a087b Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Sun, 28 Jul 2013 18:21:12 +0100 Subject: [PATCH] First commit to git-support branch for issue #29 work. --- README.md | 5 +++-- src/backend/network.cpp | 42 ++++++++++++++++++++--------------------- src/backend/network.h | 21 ++++++++++++++++++++- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 769f217d..82530556 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ At the moment, BOSSv3 is in alpha testing, and so is not recommended for use unl ## About This Repository -This repository holds the source code and documentation for BOSS v3. The masterlists, along with the source code and documentation for previous versions of BOSS, are stored in BOSS's [Google Code repository](http://code.google.com/p/better-oblivion-sorting-software/). +This repository holds the source code and documentation for BOSS v3. The masterlists, along with the source code and documentation for previous versions of BOSS, are stored in BOSS's [Google Code repository](http://code.google.com/p/better-oblivion-sorting-software/). -The reason for the split is that GitHub offers a more feature-rich project hosting service than Google Code, but BOSS has been using the latter site for most of its existence. As most of the BOSS team maintain the masterlists and don't develop the program itself, splitting the masterlists and everything else between the two sites minimises any disruption while taking advantage of GitHub's superior service. +The reason for the split is that GitHub offers a more feature-rich project hosting service than Google Code, but BOSS has been using the latter site for most of its existence. As most of the BOSS team maintain the masterlists and don't develop the program itself, splitting the masterlists and everything else between the two sites minimises any disruption while taking advantage of GitHub's superior service. ## Build Instructions @@ -32,6 +32,7 @@ BOSS requires the following libraries: * [Alphanum](http://www.davekoelle.com/files/alphanum.hpp) * [Boost](http://www.boost.org) v1.54.0 or later. * [Libespm](http://github.com/WrinklyNinja/libespm) +* [Libgit2](https://github.com/libgit2) v0.19.0. * [Libloadorder](http://github.com/WrinklyNinja/libloadorder) * [PugiXML](http://code.google.com/p/pugixml/) v1.2 or later. * [wxWidgets](http://www.wxwidgets.org) v2.9.5 or later. diff --git a/src/backend/network.cpp b/src/backend/network.cpp index bb140ec2..c70e7de7 100644 --- a/src/backend/network.cpp +++ b/src/backend/network.cpp @@ -37,7 +37,7 @@ # include "windows.h" # include "shlobj.h" #endif -#define BUFSIZE 4096 +#define BUFSIZE 4096 using namespace std; @@ -51,14 +51,14 @@ namespace boss { SECURITY_ATTRIBUTES saAttr; - PROCESS_INFORMATION piProcInfo; + PROCESS_INFORMATION piProcInfo; STARTUPINFO siStartInfo; CHAR chBuf[BUFSIZE]; DWORD dwRead; - + DWORD exitCode; - + //Init attributes. saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = TRUE; @@ -75,7 +75,7 @@ namespace boss { ZeroMemory(&piProcInfo, sizeof(PROCESS_INFORMATION)); ZeroMemory(&siStartInfo, sizeof(STARTUPINFO)); - siStartInfo.cb = sizeof(STARTUPINFO); + siStartInfo.cb = sizeof(STARTUPINFO); siStartInfo.hStdError = consoleWrite; siStartInfo.hStdOutput = consoleWrite; siStartInfo.dwFlags |= STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; @@ -85,15 +85,15 @@ namespace boss { wchar_t * cmdLine = new wchar_t[utf16Len]; MultiByteToWideChar(CP_UTF8, 0, command.c_str(), -1, cmdLine, utf16Len); - bool result = CreateProcess(NULL, - cmdLine, // command line - NULL, // process security attributes - NULL, // primary thread security attributes - TRUE, // handles are inherited - 0, // creation flags - NULL, // use parent's environment - NULL, // use parent's current directory - &siStartInfo, // STARTUPINFO pointer + bool result = CreateProcess(NULL, + cmdLine, // command line + NULL, // process security attributes + NULL, // primary thread security attributes + TRUE, // handles are inherited + 0, // creation flags + NULL, // use parent's environment + NULL, // use parent's current directory + &siStartInfo, // STARTUPINFO pointer &piProcInfo); // receives PROCESS_INFORMATION delete [] cmdLine; @@ -109,14 +109,14 @@ namespace boss { BOOST_LOG_TRIVIAL(error) << "Could not get Subversion process exit code."; throw error(error::subversion_error, "Could not get Subversion process exit code."); } - + if (!ReadFile(consoleRead, chBuf, BUFSIZE, &dwRead, NULL)) { BOOST_LOG_TRIVIAL(error) << "Could not read Subversion process output."; throw error(error::subversion_error, "Could not read Subversion process output."); } - + output = string(chBuf, dwRead); - + return exitCode == 0; } @@ -124,11 +124,11 @@ namespace boss { string GetRevision(const std::string& buffer) { string revision, date; size_t pos1, pos2; - + pos1 = buffer.rfind("Revision: "); if (pos1 == string::npos) return ""; - + pos2 = buffer.find('\n', pos1); revision = buffer.substr(pos1+10, pos2-pos1-10); @@ -142,7 +142,7 @@ namespace boss { } std::string UpdateMasterlist(const Game& game, std::vector& parsingErrors) { - + string command, output, revision; //First check if the working copy is set up or not. command = g_path_svn.string() + " info \"" + game.MasterlistPath().string() + "\""; @@ -158,7 +158,7 @@ namespace boss { else return "N/A"; } - + if (!success) { BOOST_LOG_TRIVIAL(trace) << "Working copy is not set up, checking out repository."; //Working copy not set up, perform a checkout. diff --git a/src/backend/network.h b/src/backend/network.h index eb8c343f..d16c272f 100644 --- a/src/backend/network.h +++ b/src/backend/network.h @@ -31,7 +31,7 @@ namespace boss { - /* Masterlist updating is carried out using subversion. Haven't decided whether to use its API (which is in C and a bit complex) or call its executables via system(). + /* Masterlist updating is carried out using subversion's executables via system() since it's API has too many dependencies to build myself. Basic workflow is: @@ -57,6 +57,25 @@ namespace boss { ```svn info masterlist.txt``` returns a bunch of info: the line "Revision: XXXX" contains the revision number. */ + /* Also looking into adding Git support (issue #29). Git support would involve sparse checkouts of the masterlists into each game folder, with the masterlists sitting in the root of each game's repository online. + + Not sure how to handle the URL stuff with Git, because while Subversion allows you to pass it a URL and assumes that it goes to a location on a SVN server, with Git it needs to know the repository URL (with git extension), and then also the relative path of the file you want to checkout within the repository. + + Perhaps it's best to use a false URL that includes the ".git" extension at the location of the repository, eg. + + https://github.com/WrinklyNinja/BOSSv3.git/README.md + + That's not actually a valid URL, but it means that it can be split up in code into + + https://github.com/WrinklyNinja/BOSSv3.git + + and + + /README.md + + which is what is needed, AFAIK. + */ + std::string UpdateMasterlist(const Game& game, std::vector& parsingErrors); } #endif