metadata: validate STRING and INT build field types

This converts float/int to string for things like commit: or versionName:.
For versionCode, which must be an integer, it throws an exception if the
data is any other type.
This commit is contained in:
Hans-Christoph Steiner 2020-01-03 14:17:03 +01:00
parent b2daf96284
commit 13d9a122bf
2 changed files with 55 additions and 1 deletions

View file

@ -1159,10 +1159,19 @@ def post_parse_yaml_metadata(yamldata):
for flag in build.keys():
_flagtype = flagtype(flag)
# concatenate script flags into a single string if they are stored as list
if _flagtype is TYPE_SCRIPT:
# concatenate script flags into a single string if they are stored as list
if isinstance(build[flag], list):
build[flag] = ' && '.join(build[flag])
elif _flagtype is TYPE_STRING:
# things like versionNames are strings, but without quotes can be numbers
if isinstance(build[flag], float) or isinstance(build[flag], int):
build[flag] = str(build[flag])
elif _flagtype is TYPE_INT:
# versionCode must be int
if not isinstance(build[flag], int):
warn_or_exception(_('{build_flag} must be an integer, found: {value}')
.format(build_flag=flag, value=build[flag]))
def write_yaml(mf, app):