summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-06-04 14:38:24 +0200
committerCarl Hetherington <cth@carlh.net>2020-06-04 14:38:24 +0200
commit3f0eb324e4cce5e713cddaf3682a6a66cbb675c8 (patch)
tree9b9b12e5b169e5f02a9728f9e4d8f2fa8712cab0
parentc7c2815670b69146bdc1bf510c85e088f9018b4d (diff)
Add support for git_reference.
-rwxr-xr-xcdist21
1 files changed, 17 insertions, 4 deletions
diff --git a/cdist b/cdist
index ae04483..bd64e77 100755
--- a/cdist
+++ b/cdist
@@ -103,6 +103,7 @@ class Config:
def __init__(self):
self.options = [ Option('mxe_prefix'),
Option('git_prefix'),
+ Option('git_reference'),
Option('osx_environment_prefix'),
Option('osx_sdk_prefix'),
Option('osx_sdk'),
@@ -901,7 +902,9 @@ class Tree(object):
if globals.quiet:
flags = '-q'
redirect = '>/dev/null'
- command('git clone %s %s/%s.git %s/src/%s' % (flags, config.get('git_prefix'), self.name, target.directory, self.name))
+ if config.has('git_reference'):
+ ref = '--reference-if-able %s/%s.git' % (config.get('git_reference'), self.name)
+ command('git clone %s %s %s/%s.git %s/src/%s' % (flags, ref, config.get('git_prefix'), self.name, target.directory, self.name))
os.chdir('%s/src/%s' % (target.directory, self.name))
spec = self.specifier
@@ -917,9 +920,19 @@ class Tree(object):
exec(open('%s/cscript' % proj).read(), self.cscript)
# cscript can include submodules = False to stop submodules being fetched
- if not 'submodules' in self.cscript or self.cscript['submodules'] == True:
- command('git submodule init --quiet')
- command('git submodule update --quiet')
+ if (not 'submodules' in self.cscript or self.cscript['submodules'] == True) and os.path.exists('.gitmodules'):
+ command('git submodule --quiet init')
+ paths = command_and_read('git config --file .gitmodules --get-regexp path')
+ urls = command_and_read('git config --file .gitmodules --get-regexp url')
+ for path, url in zip(paths, urls):
+ path = path.split(' ')[1]
+ url = url.split(' ')[1]
+ ref = ''
+ if config.has('git_reference'):
+ ref_path = os.path.join(config.get('git_reference'), os.path.basename(url))
+ if os.path.exists(ref_path):
+ ref = '--reference %s' % ref_path
+ command('git submodule --quiet update %s %s' % (ref, path))
if os.path.exists('%s/wscript' % proj):
v = read_wscript_variable(proj, "VERSION");