Skip to content

Commit

Permalink
Merge pull request #12454 from wfjsw/no-autofix-on-fetch
Browse files Browse the repository at this point in the history
rm dir on failed clone, disable autofix for fetch
  • Loading branch information
AUTOMATIC1111 authored Aug 10, 2023
2 parents e090609 + 5a705c2 commit 9af5cce
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions modules/launch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import re
import subprocess
import os
import shutil
import sys
import importlib.util
import platform
Expand Down Expand Up @@ -152,10 +153,8 @@ def run_git(dir, name, command, desc=None, errdesc=None, custom_env=None, live:
try:
return run(f'"{git}" -C "{dir}" {command}', desc=desc, errdesc=errdesc, custom_env=custom_env, live=live)
except RuntimeError:
pass

if not autofix:
return None
if not autofix:
raise

print(f"{errdesc}, attempting autofix...")
git_fix_workspace(dir, name)
Expand All @@ -174,13 +173,17 @@ def git_clone(url, dir, name, commithash=None):
if current_hash == commithash:
return

run_git('fetch', f"Fetching updates for {name}...", f"Couldn't fetch {name}")
run_git('fetch', f"Fetching updates for {name}...", f"Couldn't fetch {name}", autofix=False)

run_git('checkout', f"Checking out commit for {name} with hash: {commithash}...", f"Couldn't checkout commit {commithash} for {name}", live=True)

return

run(f'"{git}" clone "{url}" "{dir}"', f"Cloning {name} into {dir}...", f"Couldn't clone {name}", live=True)
try:
run(f'"{git}" clone "{url}" "{dir}"', f"Cloning {name} into {dir}...", f"Couldn't clone {name}", live=True)
except RuntimeError:
shutil.rmtree(dir, ignore_errors=True)
raise

if commithash is not None:
run(f'"{git}" -C "{dir}" checkout {commithash}', None, "Couldn't checkout {name}'s hash: {commithash}")
Expand Down

0 comments on commit 9af5cce

Please sign in to comment.