Remove masterlist update loading and rollback

LOOT's ability to roll back to a working masterlist version hasn't been
exercised in years, as our CI testing has gotten better at catching
issues before they reach users.

Coupling updating a masterlist with loading it also complicates the
introduction of a common prelude, so given the very low usefulness of
the functionality it's best to drop it entirely .
This commit is contained in:
Oliver Hamlet
2021-08-05 19:13:37 +01:00
parent 7849515daf
commit be30bc500f
6 changed files with 5 additions and 59 deletions
+2 -4
View File
@@ -95,8 +95,7 @@ public:
* @details Uses Git to update the given masterlist to a given remote.
* If the masterlist doesn't exist, this will create it. This
* function also initialises a Git repository in the given
* masterlist's parent folder. If the masterlist was not already
* up-to-date, it will be re-loaded, but not re-evaluated.
* masterlist's parent folder.
*
* If a Git repository is already present, it will be used to
* perform a diff-only update, but if for any reason a
@@ -120,8 +119,7 @@ public:
* check their repositories to see which is the latest release branch.
* @returns `true` if the masterlist was updated. `false` if no update was
* necessary, ie. it was already up-to-date. If `true`, the
* masterlist will have been re-loaded, but will need to be
* re-evaluated separately.
* masterlist will need to be re-loaded and re-evaluated separately.
*/
virtual bool UpdateMasterlist(const std::filesystem::path& masterlist_path,
const std::string& remote_url,
+1 -7
View File
@@ -95,13 +95,7 @@ bool ApiDatabase::UpdateMasterlist(const std::filesystem::path& masterlistPath,
masterlistPath.u8string() +
"\" does not have a valid parent directory.");
Masterlist masterlist;
if (masterlist.Update(masterlistPath, remoteURL, remoteBranch)) {
masterlist_ = masterlist;
return true;
}
return false;
return Masterlist::Update(masterlistPath, remoteURL, remoteBranch);
}
MasterlistInfo ApiDatabase::GetMasterlistRevision(
-27
View File
@@ -346,33 +346,6 @@ void GitHelper::CheckoutNewBranch(const std::string& remote,
data_.reference = nullptr;
}
void GitHelper::CheckoutRevision(const std::string& revision) {
if (data_.repo == nullptr)
throw GitStateError(
"Cannot checkout revision for repository that has not been opened.");
else if (data_.object != nullptr)
throw GitStateError(
"Cannot fetch repository updates, object memory already allocated.");
// Get an object ID for 'HEAD^'.
Call(git_revparse_single(&data_.object, data_.repo, revision.c_str()));
const git_oid* oid = git_object_id(data_.object);
// Detach HEAD to HEAD~1. This will roll back HEAD by one commit each time it
// is called.
Call(git_repository_set_head_detached(data_.repo, oid));
// Checkout the new HEAD.
auto logger = getLogger();
if (logger) {
logger->trace("Performing a Git checkout of HEAD.");
}
Call(git_checkout_head(data_.repo, &data_.checkout_options));
git_object_free(data_.object);
data_.object = nullptr;
}
void GitHelper::DeleteBranch(const std::string& branch) {
if (data_.repo == nullptr) {
throw GitStateError(
-1
View File
@@ -47,7 +47,6 @@ public:
void Fetch(const std::string& remote);
void CheckoutNewBranch(const std::string& remote, const std::string& branch);
void CheckoutRevision(const std::string& revision);
// Deletes the branch, detaching HEAD if it's currently set to the branch.
void DeleteBranch(const std::string& branch);
+1 -19
View File
@@ -150,25 +150,7 @@ bool Masterlist::Update(const std::filesystem::path& path,
}
// Now whether the repository was cloned or updated, the working directory
// contains the latest masterlist. Try parsing it: on failure, detach the HEAD
// back one commit and try again.
while (true) {
try {
this->Load(path);
return true;
} catch (std::exception& e) {
if (logger) {
logger->error("Masterlist parsing failed. Masterlist revision {}: {}",
git.GetHeadCommitId(true),
e.what());
}
git.CheckoutRevision("HEAD^");
}
}
// This should never be reached as git.CheckoutRevision() will throw if it
// tries to go one back from the start of history.
// contains the latest masterlist.
return true;
}
}
+1 -1
View File
@@ -34,7 +34,7 @@
namespace loot {
class Masterlist : public MetadataList {
public:
bool Update(const std::filesystem::path& path,
static bool Update(const std::filesystem::path& path,
const std::string& repoURL,
const std::string& repoBranch);