Skip to content

Commit 8ec5992

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

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

acbs/fetch.py

Lines changed: 6 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,11 @@ 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+
# FIXME: reset HEAD to master to fix gix can't second fetch src issue.
147+
subprocess.check_cell(['git', 'symbolic-ref', 'HEAD', 'refs/heads/master'], cwd=full_path)
148+
os.remove(os.path.join(full_path, "index"))
144149
subprocess.check_call(
145150
['gix', 'fetch', 'origin', '+refs/heads/*:refs/heads/*'], cwd=full_path)
146151
info.source_location = full_path

0 commit comments

Comments
 (0)