Skip to content

Commit 762b2f7

Browse files
committed
fetch: try use gix to fetch package src
1 parent 1cebb4e commit 762b2f7

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

acbs/fetch.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,32 @@ def blob_processor(package: ACBSPackageInfo, index: int, source_name: str) -> No
120120

121121

122122
def git_fetch(info: ACBSSourceInfo, source_location: str, name: str) -> Optional[ACBSSourceInfo]:
123+
try:
124+
return gix_fetch(info, source_location, name)
125+
except:
126+
full_path = os.path.join(source_location, name)
127+
if not os.path.exists(full_path):
128+
subprocess.check_call(['git', 'clone', '--bare', info.url, full_path])
129+
else:
130+
logging.info('Updating repository...')
131+
subprocess.check_call(
132+
['git', 'fetch', 'origin', '+refs/heads/*:refs/heads/*', '--prune'], cwd=full_path)
133+
info.source_location = full_path
134+
return info
135+
136+
137+
def gix_fetch(info: ACBSSourceInfo, source_location: str, name: str) -> Optional[ACBSSourceInfo]:
123138
full_path = os.path.join(source_location, name)
124139
if not os.path.exists(full_path):
125-
subprocess.check_call(['git', 'clone', '--bare', info.url, full_path])
140+
subprocess.check_call(['gix', 'clone', '--bare', info.url, full_path])
126141
else:
127142
logging.info('Updating repository...')
143+
# gix doesn't have the --prune option yet.
128144
subprocess.check_call(
129-
['git', 'fetch', 'origin', '+refs/heads/*:refs/heads/*', '--prune'], cwd=full_path)
145+
['gix', 'fetch', 'origin', '+refs/heads/*:refs/heads/*'], cwd=full_path)
130146
info.source_location = full_path
131147
return info
132148

133-
134149
def git_processor(package: ACBSPackageInfo, index: int, source_name: str) -> None:
135150
info = package.source_uri[index]
136151
if not info.revision:

0 commit comments

Comments
 (0)