wrap: Fix broken logic when initializing submodules
Also be more lenient when doing git checkout, and continue even if it
failed.
Closes
@@ -165,16 +165,20 @@ 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.
+ 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' '):
- if subprocess.call(['git', 'checkout', '.'], cwd=dirname):
+ 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))
