From d671d1d45dfab61292ed788fd7778a33a82212ee Mon Sep 17 00:00:00 2001 From: Mrau Hu Date: Sat, 12 Nov 2022 21:44:42 +0300 Subject: [PATCH] Fix: `error: Your local changes to the following files would be overwritten by merge` when run `pull()` method, because WSL2 Docker set 755 file permissions instead of 644, this results to the error. Updated `Extension` class: replaced `pull()` with `fetch_and_reset_hard()` method. Updated `apply_and_restart()` function: replaced `ext.pull()` with `ext.fetch_and_reset_hard()` function. --- modules/extensions.py | 7 +++++-- modules/ui_extensions.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/extensions.py b/modules/extensions.py index 94ce479a..db9c4200 100644 --- a/modules/extensions.py +++ b/modules/extensions.py @@ -65,9 +65,12 @@ class Extension: self.can_update = False self.status = "latest" - def pull(self): + def fetch_and_reset_hard(self): repo = git.Repo(self.path) - repo.remotes.origin.pull() + # Fix: `error: Your local changes to the following files would be overwritten by merge`, + # because WSL2 Docker set 755 file permissions instead of 644, this results to the error. + repo.git.fetch('--all') + repo.git.reset('--hard', 'origin') def list_extensions(): diff --git a/modules/ui_extensions.py b/modules/ui_extensions.py index 6671cb60..030f011e 100644 --- a/modules/ui_extensions.py +++ b/modules/ui_extensions.py @@ -36,9 +36,9 @@ def apply_and_restart(disable_list, update_list): continue try: - ext.pull() + ext.fetch_and_reset_hard() except Exception: - print(f"Error pulling updates for {ext.name}:", file=sys.stderr) + print(f"Error getting updates for {ext.name}:", file=sys.stderr) print(traceback.format_exc(), file=sys.stderr) shared.opts.disabled_extensions = disabled