Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If invalid value given to clone-recursive, raise exception #13839

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/markdown/Release-notes-for-0.48.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ files get exported.
To enable this, the following needs to be added to the `.wrap` file:

```ini
clone-recursive=true
clone-recursive = true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, I added a space on both sides of the = sign (to match the examples on the wrap manual page).

```

## `subproject()` function now supports the `required:` kwarg
Expand Down
2 changes: 1 addition & 1 deletion docs/markdown/Wrap-dependency-system-manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ case, the directory will be copied into `subprojects/` before applying patches.
- `push-url` - alternative url to configure as a git push-url. Useful if
the subproject will be developed and changes pushed upstream.
*(since 0.37.0)*
- `clone-recursive` - also clone submodules of the repository
- `clone-recursive = true` - also clone submodules of the repository
andy5995 marked this conversation as resolved.
Show resolved Hide resolved
*(since 0.48.0)*

## wrap-file with Meson build patch
Expand Down
5 changes: 4 additions & 1 deletion mesonbuild/wrap/wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,9 @@ def _get_git(self, packagename: str) -> None:
if self.wrap.values.get('depth', '') != '':
is_shallow = True
depth_option = ['--depth', self.wrap.values.get('depth')]
clone_recursive_val = self.wrap.values.get('clone-recursive', '').lower()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Placing this earlier in the function is an improvement. Now if there's an invalid value in the wrap file, meson will error out sooner. When the value is corrected, meson will clone the repository and the submodules.

Previously, after a failed attempt, meson would make no attempt to clone the submodules even after the value was corrected in the wrap file.

There is still a parser error if no value is provided to clone-recursive, which is the desired behavior. An exception will be raised if a value is given other than 'true' or 'false'. If 'clone-recursive' is not included in the wrap file at all, 'false' will be assumed.

if clone_recursive_val and clone_recursive_val not in ['false', 'true']:
raise WrapException(f"clone-recursive: invalid value '{clone_recursive_val}' (use 'true' or 'false')")
# for some reason git only allows commit ids to be shallowly fetched by fetch not with clone
if is_shallow and self.is_git_full_commit_id(revno):
# git doesn't support directly cloning shallowly for commits,
Expand All @@ -622,7 +625,7 @@ def _get_git(self, packagename: str) -> None:
args += ['--branch', revno]
args += [self.wrap.get('url'), self.directory]
verbose_git(args, self.subdir_root, check=True)
if self.wrap.values.get('clone-recursive', '').lower() == 'true':
if clone_recursive_val == 'true':
verbose_git(['submodule', 'update', '--init', '--checkout', '--recursive', *depth_option],
self.dirname, check=True)
push_url = self.wrap.values.get('push-url')
Expand Down
Loading