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

change VercodeOperation to TYPE_LIST

This commit is contained in:
linsui 2022-10-27 19:11:37 +08:00
parent 747fa13591
commit 618e2c7d72
11 changed files with 18 additions and 22 deletions

View File

@ -59,6 +59,8 @@ metadata_v0:
-e "s/CurrentVersionCode:.'\([0-9]*\)'/CurrentVersionCode:\1/" -e "s/CurrentVersionCode:.'\([0-9]*\)'/CurrentVersionCode:\1/"
-e "s/ versionCode:.'\([0-9]*\)'/ versionCode:\1/" -e "s/ versionCode:.'\([0-9]*\)'/ versionCode:\1/"
-e "s/ timeout:.'\([0-9]*\)'/ timeout:\1/" -e "s/ timeout:.'\([0-9]*\)'/ timeout:\1/"
-e "/VercodeOperation/s/null/[]/"
-e 's/VercodeOperation:.\([^[]\+\)/VercodeOperation:\n- \1/'
metadata/dump_*/*.yaml metadata/dump_*/*.yaml
- diff -uw metadata/dump_* - diff -uw metadata/dump_*

View File

@ -456,13 +456,9 @@ def checkupdates_app(app):
raise FDroidException(_('no version information found')) raise FDroidException(_('no version information found'))
if app.VercodeOperation: if app.VercodeOperation:
if isinstance(app.VercodeOperation, str): vercodes = sorted([
vercodes = [operate_vercode(app.VercodeOperation, vercode)] operate_vercode(operation, vercode) for operation in app.VercodeOperation
else: ])
vercodes = sorted([
operate_vercode(operation, vercode)
for operation in app.VercodeOperation
])
else: else:
vercodes = [vercode] vercodes = [vercode]

View File

@ -264,13 +264,8 @@ def check_update_check_data_url(app): # noqa: D403
def check_vercode_operation(app): def check_vercode_operation(app):
if not app.VercodeOperation: if not app.VercodeOperation:
return return
ops = (
[app.VercodeOperation]
if isinstance(app.VercodeOperation, str)
else app.VercodeOperation
)
invalid_ops = [] invalid_ops = []
for op in ops: for op in app.VercodeOperation:
if not common.VERCODE_OPERATION_RE.match(op): if not common.VERCODE_OPERATION_RE.match(op):
invalid_ops += op invalid_ops += op
if invalid_ops: if invalid_ops:

View File

@ -153,7 +153,7 @@ class App(dict):
self.AutoUpdateMode = 'None' self.AutoUpdateMode = 'None'
self.UpdateCheckMode = 'None' self.UpdateCheckMode = 'None'
self.UpdateCheckIgnore = None self.UpdateCheckIgnore = None
self.VercodeOperation = None self.VercodeOperation = []
self.UpdateCheckName = None self.UpdateCheckName = None
self.UpdateCheckData = None self.UpdateCheckData = None
self.CurrentVersion = '' self.CurrentVersion = ''
@ -204,6 +204,7 @@ fieldtypes = {
'AntiFeatures': TYPE_LIST, 'AntiFeatures': TYPE_LIST,
'AllowedAPKSigningKeys': TYPE_LIST, 'AllowedAPKSigningKeys': TYPE_LIST,
'Builds': TYPE_BUILD, 'Builds': TYPE_BUILD,
'VercodeOperation': TYPE_LIST,
'CurrentVersionCode': TYPE_INT, 'CurrentVersionCode': TYPE_INT,
} }

View File

@ -222,7 +222,7 @@ class LintTest(unittest.TestCase):
anywarns = False anywarns = False
for good in good_fields: for good in good_fields:
app.VercodeOperation = good app.VercodeOperation = [good]
for warn in fdroidserver.lint.check_vercode_operation(app): for warn in fdroidserver.lint.check_vercode_operation(app):
anywarns = True anywarns = True
logging.debug(warn) logging.debug(warn)
@ -230,7 +230,7 @@ class LintTest(unittest.TestCase):
for bad in bad_fields: for bad in bad_fields:
anywarns = False anywarns = False
app.VercodeOperation = bad app.VercodeOperation = [bad]
for warn in fdroidserver.lint.check_vercode_operation(app): for warn in fdroidserver.lint.check_vercode_operation(app):
anywarns = True anywarns = True
logging.debug(warn) logging.debug(warn)

View File

@ -178,7 +178,7 @@ UpdateCheckData: null
UpdateCheckIgnore: null UpdateCheckIgnore: null
UpdateCheckMode: Tags UpdateCheckMode: Tags
UpdateCheckName: null UpdateCheckName: null
VercodeOperation: null VercodeOperation: []
WebSite: '' WebSite: ''
added: null added: null
comments: {} comments: {}

View File

@ -1084,7 +1084,7 @@ UpdateCheckData: null
UpdateCheckIgnore: null UpdateCheckIgnore: null
UpdateCheckMode: Tags UpdateCheckMode: Tags
UpdateCheckName: null UpdateCheckName: null
VercodeOperation: null VercodeOperation: []
WebSite: http://sufficientlysecure.org/index.php/adaway WebSite: http://sufficientlysecure.org/index.php/adaway
added: null added: null
comments: {} comments: {}

View File

@ -360,7 +360,7 @@ UpdateCheckData: null
UpdateCheckIgnore: null UpdateCheckIgnore: null
UpdateCheckMode: Tags UpdateCheckMode: Tags
UpdateCheckName: null UpdateCheckName: null
VercodeOperation: null VercodeOperation: []
WebSite: http://www.smssecure.org WebSite: http://www.smssecure.org
added: null added: null
comments: {} comments: {}

View File

@ -2442,7 +2442,8 @@ UpdateCheckData: null
UpdateCheckIgnore: null UpdateCheckIgnore: null
UpdateCheckMode: Tags UpdateCheckMode: Tags
UpdateCheckName: null UpdateCheckName: null
VercodeOperation: '%c + 5' VercodeOperation:
- '%c + 5'
WebSite: http://www.videolan.org/vlc/download-android.html WebSite: http://www.videolan.org/vlc/download-android.html
added: null added: null
comments: {} comments: {}

View File

@ -804,6 +804,7 @@ ArchivePolicy: 9 versions
AutoUpdateMode: None AutoUpdateMode: None
UpdateCheckMode: Tags UpdateCheckMode: Tags
# Only use higher vercode ops, if we do build those arches # Only use higher vercode ops, if we do build those arches
VercodeOperation: "%c + 5" VercodeOperation:
- "%c + 5"
CurrentVersion: 1.2.6 CurrentVersion: 1.2.6
CurrentVersionCode: 1030005 CurrentVersionCode: 1030005

View File

@ -1447,7 +1447,7 @@ class UpdateTest(unittest.TestCase):
'UpdateCheckIgnore': '', 'UpdateCheckIgnore': '',
'UpdateCheckMode': '', 'UpdateCheckMode': '',
'UpdateCheckName': '', 'UpdateCheckName': '',
'VercodeOperation': '', 'VercodeOperation': None,
'WebSite': '', 'WebSite': '',
}, },
) )