forked from JOJ/Joint-Teapot
feat: remove all .lock files
This commit is contained in:
parent
9fc7649696
commit
3a511660bb
|
@ -90,32 +90,23 @@ class Git:
|
||||||
retry_interval = 2
|
retry_interval = 2
|
||||||
while retry_interval and auto_retry:
|
while retry_interval and auto_retry:
|
||||||
try:
|
try:
|
||||||
current_branch = ""
|
|
||||||
if repo.head.is_detached:
|
|
||||||
current_branch = repo.head.commit.hexsha
|
|
||||||
else:
|
|
||||||
current_branch = repo.active_branch.name
|
|
||||||
if clean_git_lock:
|
if clean_git_lock:
|
||||||
lock_files = [
|
locks_removed_count = 0
|
||||||
"index.lock",
|
for root, _, files in os.walk(os.path.join(repo_dir, ".git")):
|
||||||
"HEAD.lock",
|
for filename in files:
|
||||||
"fetch-pack.lock",
|
if filename.endswith(".lock"):
|
||||||
"packed-refs.lock",
|
lock_file_path = os.path.join(root, filename)
|
||||||
"config.lock",
|
if (
|
||||||
f"refs/heads/{current_branch}.lock",
|
os.path.join(".git", filename)
|
||||||
f"refs/remotes/origin/{current_branch}.lock",
|
== settings.joj3_lock_file_path
|
||||||
f"refs/heads/{checkout_dest}.lock",
|
):
|
||||||
f"refs/remotes/origin/{checkout_dest}.lock",
|
continue
|
||||||
"logs/HEAD.lock",
|
try:
|
||||||
f"logs/refs/heads/{current_branch}.lock",
|
os.remove(lock_file_path)
|
||||||
f"logs/refs/remotes/origin/{current_branch}.lock",
|
locks_removed_count += 1
|
||||||
f"logs/refs/heads/{checkout_dest}.lock",
|
except OSError as e:
|
||||||
f"logs/refs/remotes/origin/{checkout_dest}.lock",
|
logger.warning(f"Error removing lock file: {e}")
|
||||||
]
|
logger.info(f"Removed {locks_removed_count} lock files")
|
||||||
for lock_file in lock_files:
|
|
||||||
lock_path = os.path.join(repo_dir, ".git", lock_file)
|
|
||||||
if os.path.exists(lock_path):
|
|
||||||
os.remove(lock_path)
|
|
||||||
repo.git.fetch("--tags", "--all", "-f")
|
repo.git.fetch("--tags", "--all", "-f")
|
||||||
repo.git.reset("--hard", reset_target)
|
repo.git.reset("--hard", reset_target)
|
||||||
repo.git.clean("-d", "-f", "-x")
|
repo.git.clean("-d", "-f", "-x")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user