diff options
author | Jabasukuriputo Wang <wfjsw@users.noreply.github.com> | 2023-08-01 03:24:54 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-01 03:24:54 +0000 |
commit | 955542a6540e3c2c27b39dc515c0ee3f8044b57b (patch) | |
tree | bf1dd78a3b41fe7ad5cbdc071b2938bb30f980bd | |
parent | 2f1d5b6b04fd38b1fca1b0193b800533398d91ca (diff) | |
download | stable-diffusion-webui-gfx803-955542a6540e3c2c27b39dc515c0ee3f8044b57b.tar.gz stable-diffusion-webui-gfx803-955542a6540e3c2c27b39dc515c0ee3f8044b57b.tar.bz2 stable-diffusion-webui-gfx803-955542a6540e3c2c27b39dc515c0ee3f8044b57b.zip |
also check on rev-parse
-rw-r--r-- | modules/launch_utils.py | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/modules/launch_utils.py b/modules/launch_utils.py index c7bb9370..87c577e0 100644 --- a/modules/launch_utils.py +++ b/modules/launch_utils.py @@ -152,27 +152,25 @@ def git_clone(url, dir, name, commithash=None): if commithash is None:
return
- current_hash = run(f'"{git}" -C "{dir}" rev-parse HEAD', None, f"Couldn't determine {name}'s hash: {commithash}", live=False).strip()
- if current_hash == commithash:
- return
+ try:
+ current_hash = subprocess.check_output([git, "-C", dir, "rev-parse", "HEAD"], shell=False, encoding='utf8').strip()
+ if current_hash == commithash:
+ return
+ except RuntimeError:
+ print(f"Unable to determine {name}'s hash, attempting autofix...")
+ git_fix_workspace(dir)
+ current_hash = subprocess.check_output([git, "-C", dir, "rev-parse", "HEAD"], shell=False, encoding='utf8').strip()
+ if current_hash == commithash:
+ return
run(f'"{git}" -C "{dir}" fetch', f"Fetching updates for {name}...", f"Couldn't fetch {name}")
- if commithash is not None:
- try:
- run(f'"{git}" -C "{dir}" checkout {commithash}', f"Checking out commit for {name} with hash: {commithash}...", f"Couldn't checkout commit {commithash} for {name}", live=True)
- except RuntimeError:
- print(f"Unable to checkout {name} with hash {commithash}, attempting autofix...")
- git_fix_workspace(dir)
- run(f'"{git}" -C "{dir}" checkout {commithash}', f"Checking out commit for {name} with hash: {commithash}...", f"Couldn't checkout commit {commithash} for {name}", live=True)
- else:
- try:
- run(f'"{git}" -C "{dir}" reset --hard FETCH_HEAD', f"Checking out latest commit for {name}...", f"Couldn't checkout latest commit for {name}", live=True)
- except RuntimeError:
- print(f"Unable to checkout {name}, attempting autofix...")
- git_fix_workspace(dir)
- run(f'"{git}" -C "{dir}" reset --hard FETCH_HEAD', f"Checking out latest commit for {name}...", f"Couldn't checkout latest commit for {name}", live=True)
-
+ try:
+ run(f'"{git}" -C "{dir}" checkout {commithash}', f"Checking out commit for {name} with hash: {commithash}...", f"Couldn't checkout commit {commithash} for {name}", live=True)
+ except RuntimeError:
+ print(f"Unable to checkout {name} with hash {commithash}, attempting autofix...")
+ git_fix_workspace(dir)
+ run(f'"{git}" -C "{dir}" checkout {commithash}', f"Checking out commit for {name} with hash: {commithash}...", f"Couldn't checkout commit {commithash} for {name}", live=True)
return
|