Add update modes.

This commit is contained in:
Nourepide
2023-11-26 15:56:04 +03:00
parent 6bb16f8cf4
commit be830a35c9
2 changed files with 16 additions and 2 deletions
+14 -1
View File
@@ -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()
+2 -1
View File
@@ -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",