aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/msubprojects.py
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2021-09-19 11:28:20 -0400
committerEli Schwartz <eschwartz@archlinux.org>2021-09-19 23:34:33 -0400
commit4568482316f63c48559b97c9a4771740ed61eca6 (patch)
treec1981efbb5b7fe973f418dd952e2d1a266b1ce28 /mesonbuild/msubprojects.py
parent82e68e98adad23d45fd5a6028d1add613d99a1cb (diff)
downloadmeson-4568482316f63c48559b97c9a4771740ed61eca6.zip
meson-4568482316f63c48559b97c9a4771740ed61eca6.tar.gz
meson-4568482316f63c48559b97c9a4771740ed61eca6.tar.bz2
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.
Diffstat (limited to 'mesonbuild/msubprojects.py')
-rwxr-xr-xmesonbuild/msubprojects.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/mesonbuild/msubprojects.py b/mesonbuild/msubprojects.py
index b058f5b..c9081ba 100755
--- a/mesonbuild/msubprojects.py
+++ b/mesonbuild/msubprojects.py
@@ -261,9 +261,14 @@ class Runner:
self.git_output(['fetch', '--refmap', heads_refmap, '--refmap', tags_refmap, 'origin', revision])
except GitException as e:
self.log(' -> Could not fetch revision', mlog.bold(revision), 'in', mlog.bold(self.repo_dir))
- self.log(mlog.red(e.output))
- self.log(mlog.red(str(e)))
- return False
+ if quiet_git(['rev-parse', revision + '^{commit}'], self.repo_dir)[0]:
+ self.log(mlog.yellow('WARNING:'), 'Proceeding with locally available copy')
+ # 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 == '':
# We are currently in detached mode