Skip to content

Commit

Permalink
fetch: add some hack to gix_fetch function try to fix second time clone
Browse files Browse the repository at this point in the history
  • Loading branch information
eatradish committed Aug 16, 2023
1 parent 762b2f7 commit 2f99255
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion acbs/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ def blob_processor(package: ACBSPackageInfo, index: int, source_name: str) -> No

def git_fetch(info: ACBSSourceInfo, source_location: str, name: str) -> Optional[ACBSSourceInfo]:
try:
# Try use gix
return gix_fetch(info, source_location, name)
except:
# Fallback to git
full_path = os.path.join(source_location, name)
if not os.path.exists(full_path):
subprocess.check_call(['git', 'clone', '--bare', info.url, full_path])
Expand All @@ -139,8 +141,10 @@ def gix_fetch(info: ACBSSourceInfo, source_location: str, name: str) -> Optional
if not os.path.exists(full_path):
subprocess.check_call(['gix', 'clone', '--bare', info.url, full_path])
else:
logging.info('Updating repository...')
logging.info('Updating repository with gix...')
# gix doesn't have the --prune option yet.
subprocess.check_cell(['git', 'update-ref', 'HEAD', 'HEAD^'], cwd=full_path)
os.remove(os.path.join(full_path, "index"))
subprocess.check_call(
['gix', 'fetch', 'origin', '+refs/heads/*:refs/heads/*'], cwd=full_path)
info.source_location = full_path
Expand Down

0 comments on commit 2f99255

Please sign in to comment.