1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-19 21:30:10 +01:00

yaml metadata: split prebuild build field to list

This commit is contained in:
Michael Pöhn 2018-08-28 10:16:13 +02:00 committed by Michael Pöhn
parent 35225a973f
commit 942de28fa5
2 changed files with 58 additions and 0 deletions

View File

@ -1091,6 +1091,10 @@ def parse_yaml_metadata(mf, app):
_("Unrecognised build flag '{build_flag}' "
"in '{path}'").format(build_flag=build_flag,
path=mf.name))
if 'prebuild' in build and type(build['prebuild']) == list:
build['prebuild'] = ' && '.join(build['prebuild'])
app.update(yamldata)
return app
@ -1194,6 +1198,8 @@ def write_yaml(mf, app):
continue
elif value == 'yes':
value = 'yes'
if field == 'prebuild':
value = value.split(' && ')
b.update({field: _field_to_yaml(flagtype(field), value)})
builds.append(b)

View File

@ -209,6 +209,58 @@ class MetadataTest(unittest.TestCase):
UpdateCheckMode: Tags
"""))
def test_parse_yaml_metadata_prebuild(self):
mf = io.StringIO(textwrap.dedent("""\
AutoName: F-Droid
RepoType: git
Builds:
- versionCode: 1
versionName: v0.1.0
prebuild:
- a
- b
- c
"""))
mf.name = 'mock_filename.yaml'
mf.seek(0)
result = {}
with mock.patch('fdroidserver.metadata.warnings_action', 'error'):
fdroidserver.metadata.parse_yaml_metadata(mf, result)
self.assertDictEqual(result, {'AutoName': 'F-Droid',
'RepoType': 'git',
'Builds': [{'versionCode': 1,
'versionName': 'v0.1.0',
'prebuild': 'a && b && c'}]})
def test_write_yaml_prebuild(self):
mf = io.StringIO()
app = fdroidserver.metadata.App()
app.builds = []
build = fdroidserver.metadata.Build()
build.versionCode = 102030
build.versionName = 'v1.2.3'
build.prebuild = 'a && b % c && d `echo \'$e\'` && f'
app.builds.append(build)
fdroidserver.metadata.write_yaml(mf, app)
mf.seek(0)
self.assertEqual(mf.read(), textwrap.dedent("""\
Categories:
- None
License: Unknown
Builds:
- versionName: v1.2.3
versionCode: 102030
prebuild:
- a
- b % c
- d `echo '$e'`
- f
AutoUpdateMode: None
UpdateCheckMode: None
"""))
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))