manifest: fix incorrect parsing with url + default remote
Manifests which use both default remotes and projects with URL elements may incorrectly be rejected as invalid. Fix this and add a regression test. Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
5ccbbbada3
commit
a4af95471a
|
@ -256,11 +256,15 @@ class Manifest:
|
|||
name = mp['name']
|
||||
|
||||
# Validate the project remote or URL.
|
||||
remote_name = mp.get('remote', default_remote_name)
|
||||
remote_name = mp.get('remote')
|
||||
url = mp.get('url')
|
||||
if remote_name is None and url is None:
|
||||
self._malformed('project {} does not specify a remote or URL'.
|
||||
format(name))
|
||||
if default_remote_name is None:
|
||||
self._malformed(
|
||||
'project {} has no remote or URL (no default is set)'.
|
||||
format(name))
|
||||
else:
|
||||
remote_name = default_remote_name
|
||||
if remote_name:
|
||||
if remote_name not in remotes_dict:
|
||||
self._malformed('project {} remote {} is not defined'.
|
||||
|
|
|
@ -105,6 +105,24 @@ def test_no_remote_ok(west_topdir):
|
|||
manifest = Manifest.from_data(yaml.safe_load(content))
|
||||
assert manifest.projects[1].url == 'https://example.com/my-project'
|
||||
|
||||
@patch('west.util.west_topdir', return_value='/west_top')
|
||||
def test_defaults_and_url(west_topdir):
|
||||
# an explicit URL overrides the defaults attribute.
|
||||
|
||||
content = '''\
|
||||
manifest:
|
||||
defaults:
|
||||
remote: remote1
|
||||
remotes:
|
||||
- name: remote1
|
||||
url-base: https://url1.com/
|
||||
projects:
|
||||
- name: testproject
|
||||
url: https://url2.com/testproject
|
||||
'''
|
||||
manifest = Manifest.from_data(yaml.safe_load(content))
|
||||
assert manifest.projects[1].url == 'https://url2.com/testproject'
|
||||
|
||||
def test_no_defaults(config_file_project_setup):
|
||||
# Manifests with no defaults should work.
|
||||
content = '''\
|
||||
|
|
Loading…
Reference in New Issue