From 2f99255dbb96d568d5d8a01687d267142c7ef761 Mon Sep 17 00:00:00 2001 From: eatradish Date: Wed, 16 Aug 2023 17:05:47 +0800 Subject: [PATCH] fetch: add some hack to gix_fetch function try to fix second time clone --- acbs/fetch.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/acbs/fetch.py b/acbs/fetch.py index 67485ab..3966454 100644 --- a/acbs/fetch.py +++ b/acbs/fetch.py @@ -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]) @@ -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