aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Hostettler <textshell@uchuujin.de>2019-11-27 17:02:57 +0100
committerNirbheek Chauhan <nirbheek@centricular.com>2019-11-28 22:41:16 +0530
commit1ec17ba9e1cfdc7ca562ec05a31c8ac54a0ae407 (patch)
treefd215970e2c51174d0a5c7930c49684862673324
parent8f673d0139e327da78bceec583ec6afc5aa3ee0f (diff)
downloadmeson-1ec17ba9e1cfdc7ca562ec05a31c8ac54a0ae407.zip
meson-1ec17ba9e1cfdc7ca562ec05a31c8ac54a0ae407.tar.gz
meson-1ec17ba9e1cfdc7ca562ec05a31c8ac54a0ae407.tar.bz2
wrap: Resolver.get_git: Factor out --depth argument generation and make sure not to pass None as parameter
507cf47507cf47 broke the combination of clone-recursive without depth. Because it passed depth (as None) to git. To fix this the depth option is now generated once as a list when depth is set and else set to an empty list and unpacked into the argument this when needed. This reduces duplication and allows code to work the same for both cases.
-rw-r--r--mesonbuild/wrap/wrap.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py
index 8b19b6d..ebf9f9e 100644
--- a/mesonbuild/wrap/wrap.py
+++ b/mesonbuild/wrap/wrap.py
@@ -227,7 +227,11 @@ class Resolver:
def get_git(self):
revno = self.wrap.get('revision')
- is_shallow = self.wrap.values.get('depth', '') != ''
+ is_shallow = False
+ depth_option = [] # type: typing.List[str]
+ if self.wrap.values.get('depth', '') != '':
+ is_shallow = True
+ depth_option = ['--depth', self.wrap.values.get('depth')]
# for some reason git only allows commit ids to be shallowly fetched by fetch not with clone
if is_shallow and self.is_git_full_commit_id(revno):
# git doesn't support directly cloning shallowly for commits,
@@ -236,12 +240,12 @@ class Resolver:
subprocess.check_call(['git', 'remote', 'add', 'origin', self.wrap.get('url')],
cwd=self.dirname)
revno = self.wrap.get('revision')
- subprocess.check_call(['git', 'fetch', '--depth', self.wrap.values.get('depth'), 'origin', revno],
+ subprocess.check_call(['git', 'fetch', *depth_option, 'origin', revno],
cwd=self.dirname)
subprocess.check_call(['git', 'checkout', revno], cwd=self.dirname)
if self.wrap.values.get('clone-recursive', '').lower() == 'true':
subprocess.check_call(['git', 'submodule', 'update',
- '--init', '--checkout', '--recursive', '--depth', self.wrap.values.get('depth')],
+ '--init', '--checkout', '--recursive', *depth_option],
cwd=self.dirname)
push_url = self.wrap.values.get('push-url')
if push_url:
@@ -257,13 +261,13 @@ class Resolver:
subprocess.check_call(['git', 'fetch', self.wrap.get('url'), revno], cwd=self.dirname)
subprocess.check_call(['git', 'checkout', revno], cwd=self.dirname)
else:
- subprocess.check_call(['git', 'clone', '--depth', self.wrap.values.get('depth'),
+ subprocess.check_call(['git', 'clone', *depth_option,
'--branch', revno,
self.wrap.get('url'),
self.directory], cwd=self.subdir_root)
if self.wrap.values.get('clone-recursive', '').lower() == 'true':
subprocess.check_call(['git', 'submodule', 'update',
- '--init', '--checkout', '--recursive', '--depth', self.wrap.values.get('depth')],
+ '--init', '--checkout', '--recursive', *depth_option],
cwd=self.dirname)
push_url = self.wrap.values.get('push-url')
if push_url: