Skip to content

Commit 4529549

Browse files
committed
base, parser, fetch: add nogix in SRCS git option in spec file to control use gix fetch src
1 parent 2326d95 commit 4529549

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed

acbs/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
class ACBSSourceInfo(object):
9-
def __init__(self, type: str, url: str, revision=None, branch=None, depth=None) -> None:
9+
def __init__(self, type: str, url: str, revision=None, branch=None, depth=None, no_gix=False) -> None:
1010
self.type = type
1111
self.url = url
1212
self.revision: Optional[str] = revision
@@ -21,9 +21,10 @@ def __init__(self, type: str, url: str, revision=None, branch=None, depth=None)
2121
self.copy_repo: bool = False
2222
# this is a tristate: 0 - off; 1 - on (non-recursive); 2 - recursive
2323
self.submodule: int = 2
24+
self.no_gix: bool = no_gix
2425

2526
def __repr__(self) -> str:
26-
return '<ACBSSourceInfo {type}: {url}:{branch}@{revision} integrity: {checksum}>'.format(type=self.type, url=self.url, branch=self.branch, revision=self.revision, checksum=self.chksum)
27+
return '<ACBSSourceInfo {type}: {url}:{branch}@{revision} integrity: {checksum} no_gix: {no_gix}>'.format(type=self.type, url=self.url, branch=self.branch, revision=self.revision, checksum=self.chksum, no_gix=self.no_gix)
2728

2829

2930
class ACBSPackageInfo(object):

acbs/fetch.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -119,21 +119,28 @@ def blob_processor(package: ACBSPackageInfo, index: int, source_name: str) -> No
119119
return tarball_processor_innner(package, index, source_name, False)
120120

121121

122-
def git_fetch(info: ACBSSourceInfo, source_location: str, name: str) -> Optional[ACBSSourceInfo]:
123-
try:
124-
# Try use gix
125-
return gix_fetch(info, source_location, name)
126-
except:
127-
# Fallback to git
128-
full_path = os.path.join(source_location, name)
129-
if not os.path.exists(full_path):
130-
subprocess.check_call(['git', 'clone', '--bare', info.url, full_path])
131-
else:
132-
logging.info('Updating repository...')
133-
subprocess.check_call(
122+
def git_fetch_fallback(info: ACBSSourceInfo, source_location: str, name: str) -> Optional[ACBSSourceInfo]:
123+
if info.no_gix:
124+
return git_fetch(info, source_location, name)
125+
else:
126+
try:
127+
# Try use gix
128+
return gix_fetch(info, source_location, name)
129+
except:
130+
# Fallback to git
131+
return git_fetch(info, source_location, name)
132+
133+
134+
def git_fetch(info, source_location, name):
135+
full_path = os.path.join(source_location, name)
136+
if not os.path.exists(full_path):
137+
subprocess.check_call(['git', 'clone', '--bare', info.url, full_path])
138+
else:
139+
logging.info('Updating repository...')
140+
subprocess.check_call(
134141
['git', 'fetch', 'origin', '+refs/heads/*:refs/heads/*', '--prune'], cwd=full_path)
135-
info.source_location = full_path
136-
return info
142+
info.source_location = full_path
143+
return info
137144

138145

139146
def gix_hack(path: str):
@@ -334,7 +341,7 @@ def fossil_processor(package: ACBSPackageInfo, index: int, source_name: str) ->
334341

335342

336343
handlers: Dict[str, pair_signature] = {
337-
'GIT': (git_fetch, git_processor),
344+
'GIT': (git_fetch_fallback, git_processor),
338345
'SVN': (svn_fetch, svn_processor),
339346
'BZR': (bzr_fetch, bzr_processor),
340347
'HG': (hg_fetch, hg_processor),

acbs/parser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ def parse_fetch_options(options: str, acbs_source_info: ACBSSourceInfo):
7575
if translated is None:
7676
raise ValueError(f'Invalid submodule directive: {v}')
7777
acbs_source_info.submodule = translated
78+
elif k == 'nogix':
79+
acbs_source_info.no_gix = v.strip() == 'true'
80+
7881
return acbs_source_info
7982

8083

0 commit comments

Comments
 (0)