Skip to content

Commit 2f99255

Browse files
committed
fetch: add some hack to gix_fetch function try to fix second time clone
1 parent 762b2f7 commit 2f99255

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

acbs/fetch.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ def blob_processor(package: ACBSPackageInfo, index: int, source_name: str) -> No
121121

122122
def git_fetch(info: ACBSSourceInfo, source_location: str, name: str) -> Optional[ACBSSourceInfo]:
123123
try:
124+
# Try use gix
124125
return gix_fetch(info, source_location, name)
125126
except:
127+
# Fallback to git
126128
full_path = os.path.join(source_location, name)
127129
if not os.path.exists(full_path):
128130
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
139141
if not os.path.exists(full_path):
140142
subprocess.check_call(['gix', 'clone', '--bare', info.url, full_path])
141143
else:
142-
logging.info('Updating repository...')
144+
logging.info('Updating repository with gix...')
143145
# gix doesn't have the --prune option yet.
146+
subprocess.check_cell(['git', 'update-ref', 'HEAD', 'HEAD^'], cwd=full_path)
147+
os.remove(os.path.join(full_path, "index"))
144148
subprocess.check_call(
145149
['gix', 'fetch', 'origin', '+refs/heads/*:refs/heads/*'], cwd=full_path)
146150
info.source_location = full_path

0 commit comments

Comments
 (0)