From ed1e6cc8f2c134cbc6b0a4c3d4aa51ebc4f502c6 Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Mon, 29 Jul 2013 12:55:40 +0100 Subject: [PATCH] Updated comment notes on what needs doing. --- src/backend/network.cpp | 44 +++++++++++++++++++++++++++++++++++++++++ src/backend/network.h | 16 +-------------- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/src/backend/network.cpp b/src/backend/network.cpp index 60367f4d..bf4b4309 100644 --- a/src/backend/network.cpp +++ b/src/backend/network.cpp @@ -215,6 +215,50 @@ namespace boss { } } } else { //Git. + /* List of operations (porcelain commands shown, will need to implement using plumbing in the API though): + + 1. Check if there is already a Git repository in the game's BOSS subfolder. + + Since the masterlists will each be in the root of a separate repository, just check if there is a `.git` folder present. + + 2a. If there is, compare its remote URL with the URL that BOSS is currently set to use. + + The current remote can be gotten using `git config --get remote.origin.url`. + + + 3a. If the URLs are different, then update the remote URL to the one given by BOSS. + + The remote URL can be changed using `git remote set-url origin ` + + 2b. If there isn't already a Git repo present, initialise one using the URL given (remembering to split the URL so that it ends in `.git`). + + `git init` + `git remote add -f origin ` + + + 3b. Now set up sparse checkout support, so that even if the repository has other files, the user's BOSS install only gets the masterlist added to it. + + `git config core.sparsecheckout true` + `echo masterlist.yaml >> .git/info/sparse-checkout` + + 4. Now update the repository. + + `git reset --hard HEAD` is required to undo any roll-backs that were done in the local repository. + `git pull origin master` + + 5. Now get the revision hash of the masterlist. + + `git ls-files -s masterlist.yaml`. This also gives the file type and path though, so it's not a 1:1 match to what we really want. + + 6. Test the updated masterlist parsing, to make sure it isn't broken. + + 7a. If it is broken, roll back the masterlist one revision, according to the remote history. + + `git checkout HEAD~1 masterlist.yaml` to roll back one revision. HEAD stays in the same place, so need to increment the number if rolling back multiple times. + + 8a. Now go back to step (5). + + 7b. If it isn't broken, finish. } } diff --git a/src/backend/network.h b/src/backend/network.h index d16c272f..890348e3 100644 --- a/src/backend/network.h +++ b/src/backend/network.h @@ -59,21 +59,7 @@ namespace boss { /* 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. + So when using Git, the Game::URL() function would return the path to the repository, and BOSS would expect that the masterlist be in the root directory of the repository, which is not unreasonable. */ std::string UpdateMasterlist(const Game& game, std::vector& parsingErrors);