Avoid check-out branches to speed-up windows slow fs

This commit is contained in:
Christos Choutouridis 2025-06-27 12:48:12 +03:00
parent da998d8eec
commit 2fb0b910a9

View File

@ -64,7 +64,7 @@ def sync_repo(nick, from_entry, to_entry, use_mirror, dry_run=False):
"""
Synchronizes a repository from from_entry to to_entry.
Executes git fetch from the source and git push to the destination.
If --mirror is used, performs full push of all refs. Otherwise, checks out all remote branches and pushes with --all and --tags.
If --mirror is used, performs full push of all refs. Otherwise, creates local tracking branches and pushes them without checking out.
"""
_, _, from_remote, from_url, local_dir = from_entry
_, _, to_remote, to_url, _ = to_entry
@ -94,9 +94,9 @@ def sync_repo(nick, from_entry, to_entry, use_mirror, dry_run=False):
for r in remotes:
if f'{from_remote}/' in r and '->' not in r:
branch = r.strip().split(f'{from_remote}/')[1]
subprocess.run(["git", "checkout", "-B", branch, f"{from_remote}/{branch}"], cwd=local_dir)
subprocess.run(["git", "branch", branch, f"{from_remote}/{branch}"], cwd=local_dir)
except subprocess.CalledProcessError as e:
print(f"Error: Failed to checkout remote branches in {local_dir}\nMessage: {e}")
print(f"Error: Failed to create tracking branches in {local_dir}\nMessage: {e}")
sys.exit(1)
run_git(["git", "push", to_remote, "--all"], cwd=local_dir, dry_run=dry_run)
run_git(["git", "push", to_remote, "--tags"], cwd=local_dir, dry_run=dry_run)