aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/wrap/wrap.py
diff options
context:
space:
mode:
authorChristoph Weiss <weiss@wsoptics.de>2019-09-18 08:45:46 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2019-09-29 20:47:59 +0300
commit0008b326ffc39c86be2ae4352bdddc03f01840cc (patch)
treeb6dd4664e33d74da8cbe27c86ddc27feebf56e96 /mesonbuild/wrap/wrap.py
parenta65d5801f363f70c01bc76c562d9b9e820dc52aa (diff)
downloadmeson-0008b326ffc39c86be2ae4352bdddc03f01840cc.zip
meson-0008b326ffc39c86be2ae4352bdddc03f01840cc.tar.gz
meson-0008b326ffc39c86be2ae4352bdddc03f01840cc.tar.bz2
Add support for `depth` option in wrap-git
This allows cloning subprojects shallowly. It works recursively for a subproject's submodules in case `clone-recursive` is set to `true`.
Diffstat (limited to 'mesonbuild/wrap/wrap.py')
-rw-r--r--mesonbuild/wrap/wrap.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py
index 4b2a323..89bc307 100644
--- a/mesonbuild/wrap/wrap.py
+++ b/mesonbuild/wrap/wrap.py
@@ -226,16 +226,21 @@ class Resolver:
self.apply_patch()
def get_git(self):
+ # git doesn't support directly cloning shallowly for commits,
+ # so we follow https://stackoverflow.com/a/43136160
+ subprocess.check_call(['git', 'init', self.directory], cwd=self.subdir_root)
+ subprocess.check_call(['git', 'remote', 'add', 'origin', self.wrap.get('url')],
+ cwd=self.dirname)
+ git_options = []
revno = self.wrap.get('revision')
- subprocess.check_call(['git', 'clone', self.wrap.get('url'),
- self.directory], cwd=self.subdir_root)
- if revno.lower() != 'head':
- if subprocess.call(['git', 'checkout', revno], cwd=self.dirname) != 0:
- subprocess.check_call(['git', 'fetch', self.wrap.get('url'), revno], cwd=self.dirname)
- subprocess.check_call(['git', 'checkout', revno], cwd=self.dirname)
+ if self.wrap.values.get('depth', '') != '':
+ git_options.extend(['--depth', self.wrap.values.get('depth')])
+ subprocess.check_call(['git', 'fetch'] + git_options + ['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'],
+ '--init', '--checkout', '--recursive'] + git_options,
cwd=self.dirname)
push_url = self.wrap.values.get('push-url')
if push_url: