From be830a35c904df7a6574377db0b201cbb59a7521 Mon Sep 17 00:00:00 2001 From: Nourepide Date: Sun, 26 Nov 2023 15:56:04 +0300 Subject: [PATCH] Add update modes. --- Loader.py | 15 ++++++++++++++- template/template.json | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Loader.py b/Loader.py index 08f9d0e..91a9ec5 100644 --- a/Loader.py +++ b/Loader.py @@ -165,6 +165,7 @@ class Loader: import git from git import Repo + from git import GitCommandError # noinspection PyTypeChecker, PyUnboundLocalVariable repo = Repo(self.__ROOT_PATH, odbt=git.db.GitDB) @@ -184,7 +185,19 @@ class Loader: self.__notification("New updates are available.") if self.__config()["updates"]["auto_update"]: - repo.remotes.origin.pull() + update_mode = self.__config()["updates"]["update_mode"] + + if update_mode == "soft": + try: + repo.git.pull() + except GitCommandError: + self.__error("An error occurred during the update. " + "It is recommended to use \"hard\" update mode. " + "But be careful, it erases all personal changes from Allor repository.") + + elif update_mode == "hard": + repo.git.reset('--hard', 'origin/' + branch_name) + self.__notification("Update complete.") self.__update_timestamp() diff --git a/template/template.json b/template/template.json index bb85139..0c34e0a 100644 --- a/template/template.json +++ b/template/template.json @@ -24,7 +24,8 @@ "notify_if_has_new_updates": true, "notify_if_no_new_updates": true, "auto_update": true, - "branch_name": "main" + "branch_name": "main", + "update_mode": "soft" }, "fonts": { "folder_path": "comfy_extras/fonts",