wrap: Fix broken logic when initializing submodules

Also be more lenient when doing git checkout, and continue even if it
failed.

Closes https://github.com/mesonbuild/meson/issues/3088
pull/3103/head
Nirbheek Chauhan 7 years ago committed by Jussi Pakkanen
parent 15358ecc9f
commit 0ec18a0531
  1. 16
      mesonbuild/wrap/wrap.py

@ -165,17 +165,21 @@ class Resolver:
return False
# Submodule has not been added, add it
if out.startswith(b'+'):
mlog.warning('submodule {} might be out of date'.format(dirname))
mlog.warning('git submodule {} might be out of date'.format(dirname))
return True
elif out.startswith(b'U'):
raise RuntimeError('submodule {} has merge conflicts'.format(dirname))
# Submodule exists, but is deinitialized or wasn't initialized
elif out.startswith(b'-'):
if subprocess.call(['git', '-C', self.subdir_root, 'submodule', 'update', '--init', dirname]) != 0:
return False
# Submodule was added already, but it wasn't populated. Do a checkout.
elif out.startswith(b' '):
if subprocess.call(['git', 'checkout', '.'], cwd=dirname):
if subprocess.call(['git', '-C', self.subdir_root, 'submodule', 'update', '--init', dirname]) == 0:
return True
raise RuntimeError('Failed to git submodule init {!r}'.format(dirname))
# Submodule looks fine, but maybe it wasn't populated properly. Do a checkout.
elif out.startswith(b' '):
subprocess.call(['git', 'checkout', '.'], cwd=dirname)
# Even if checkout failed, try building it anyway and let the user
# handle any problems manually.
return True
m = 'Unknown git submodule output: {!r}'
raise RuntimeError(m.format(out))

Loading…
Cancel
Save