diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2020-08-07 10:06:33 -0400 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2020-09-10 11:39:30 -0400 |
commit | 98d445a0708e56a511fb91c6189dea97b0a57d43 (patch) | |
tree | 390a72c98aafc2c69b16956e1360cdfdc0dfc553 | |
parent | 3d443d84bdfd4987dbe299ac3b5fad591d01bced (diff) | |
download | meson-98d445a0708e56a511fb91c6189dea97b0a57d43.zip meson-98d445a0708e56a511fb91c6189dea97b0a57d43.tar.gz meson-98d445a0708e56a511fb91c6189dea97b0a57d43.tar.bz2 |
msubprojects: Support git subprojects with no wrap file
User could have cloned manually a subproject.
-rwxr-xr-x | mesonbuild/msubprojects.py | 7 | ||||
-rw-r--r-- | mesonbuild/wrap/wrap.py | 12 |
2 files changed, 19 insertions, 0 deletions
diff --git a/mesonbuild/msubprojects.py b/mesonbuild/msubprojects.py index 4575181..f1cc515 100755 --- a/mesonbuild/msubprojects.py +++ b/mesonbuild/msubprojects.py @@ -53,6 +53,10 @@ def update_git(wrap, repo_dir, options): mlog.log(' -> Not used.') return revision = wrap.get('revision') + if not revision: + # It could be a detached git submodule for example. + mlog.log(' -> No revision specified.') + return branch = git_output(['branch', '--show-current'], repo_dir).strip() if branch == '': try: @@ -145,6 +149,9 @@ def checkout(wrap, repo_dir, options): if wrap.type != 'git' or not os.path.isdir(repo_dir): return branch_name = options.branch_name if options.branch_name else wrap.get('revision') + if not branch_name: + # It could be a detached git submodule for example. + return cmd = ['checkout', branch_name, '--'] if options.b: cmd.insert(1, '-b') diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 68f83c1..26f3d4a 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -118,10 +118,22 @@ class PackageDefinition: self.provided_deps[self.name] = None if fname.endswith('.wrap'): self.parse_wrap(fname) + else: + self.guess_type(); self.directory = self.values.get('directory', self.name) if os.path.dirname(self.directory): raise WrapException('Directory key must be a name and not a path') + def guess_type(self) -> None: + if os.path.exists(os.path.join(self.filename, '.git')): + # This is a git subproject without wrap file. Either the user cloned + # it manually, or it's a git submodule. The revision is used in + # msubprojects.py to update the git repo. If it's a submodule the repo + # is likely detached and revision will be empty. + res, stdout = quiet_git(['branch', '--show-current'], self.filename) + self.values['revision'] = stdout.strip() + self.type = 'git' + def parse_wrap(self, fname: str) -> None: try: self.config = configparser.ConfigParser(interpolation=None) |