msubprojects: if fetching the remote fails, gracefully fallback to local copy

This command is useful to e.g. update a cloned subproject which does not
have its packagefiles merged, or which has updated packagefiles. This
does not strictly require internet, so if we can satisfy the ref, simply
log a warning and continue.

This enables a workflow where for network-isolated builds, the
subproject is cloned and moved into place and later on the build
orchestrator runs `meson subprojects update` without a network interface
to initialize the subproject.
pull/9277/head
Eli Schwartz 3 years ago
parent 82e68e98ad
commit 4568482316
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 11
      mesonbuild/msubprojects.py

@ -261,9 +261,14 @@ class Runner:
self.git_output(['fetch', '--refmap', heads_refmap, '--refmap', tags_refmap, 'origin', revision]) self.git_output(['fetch', '--refmap', heads_refmap, '--refmap', tags_refmap, 'origin', revision])
except GitException as e: except GitException as e:
self.log(' -> Could not fetch revision', mlog.bold(revision), 'in', mlog.bold(self.repo_dir)) self.log(' -> Could not fetch revision', mlog.bold(revision), 'in', mlog.bold(self.repo_dir))
self.log(mlog.red(e.output)) if quiet_git(['rev-parse', revision + '^{commit}'], self.repo_dir)[0]:
self.log(mlog.red(str(e))) self.log(mlog.yellow('WARNING:'), 'Proceeding with locally available copy')
return False # Trick git into setting FETCH_HEAD from the local revision.
quiet_git(['fetch', '.', revision], self.repo_dir)
else:
self.log(mlog.red(e.output))
self.log(mlog.red(str(e)))
return False
if branch == '': if branch == '':
# We are currently in detached mode # We are currently in detached mode

Loading…
Cancel
Save