From 618e2c7d72a8e46a14983e328e9d58d16b92867f Mon Sep 17 00:00:00 2001 From: linsui Date: Thu, 27 Oct 2022 19:11:37 +0800 Subject: [PATCH] change VercodeOperation to TYPE_LIST --- .gitlab-ci.yml | 2 ++ fdroidserver/checkupdates.py | 10 +++------- fdroidserver/lint.py | 7 +------ fdroidserver/metadata.py | 3 ++- tests/lint.TestCase | 4 ++-- tests/metadata/dump/com.politedroid.yaml | 2 +- tests/metadata/dump/org.adaway.yaml | 2 +- tests/metadata/dump/org.smssecure.smssecure.yaml | 2 +- tests/metadata/dump/org.videolan.vlc.yaml | 3 ++- tests/metadata/org.videolan.vlc.yml | 3 ++- tests/update.TestCase | 2 +- 11 files changed, 18 insertions(+), 22 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 46463e6b..a635b038 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -59,6 +59,8 @@ metadata_v0: -e "s/CurrentVersionCode:.'\([0-9]*\)'/CurrentVersionCode:\1/" -e "s/ versionCode:.'\([0-9]*\)'/ versionCode:\1/" -e "s/ timeout:.'\([0-9]*\)'/ timeout:\1/" + -e "/VercodeOperation/s/null/[]/" + -e 's/VercodeOperation:.\([^[]\+\)/VercodeOperation:\n- \1/' metadata/dump_*/*.yaml - diff -uw metadata/dump_* diff --git a/fdroidserver/checkupdates.py b/fdroidserver/checkupdates.py index 756a8064..c5318742 100644 --- a/fdroidserver/checkupdates.py +++ b/fdroidserver/checkupdates.py @@ -456,13 +456,9 @@ def checkupdates_app(app): raise FDroidException(_('no version information found')) if app.VercodeOperation: - if isinstance(app.VercodeOperation, str): - vercodes = [operate_vercode(app.VercodeOperation, vercode)] - else: - vercodes = sorted([ - operate_vercode(operation, vercode) - for operation in app.VercodeOperation - ]) + vercodes = sorted([ + operate_vercode(operation, vercode) for operation in app.VercodeOperation + ]) else: vercodes = [vercode] diff --git a/fdroidserver/lint.py b/fdroidserver/lint.py index c4c98143..6e11c8a6 100644 --- a/fdroidserver/lint.py +++ b/fdroidserver/lint.py @@ -264,13 +264,8 @@ def check_update_check_data_url(app): # noqa: D403 def check_vercode_operation(app): if not app.VercodeOperation: return - ops = ( - [app.VercodeOperation] - if isinstance(app.VercodeOperation, str) - else app.VercodeOperation - ) invalid_ops = [] - for op in ops: + for op in app.VercodeOperation: if not common.VERCODE_OPERATION_RE.match(op): invalid_ops += op if invalid_ops: diff --git a/fdroidserver/metadata.py b/fdroidserver/metadata.py index 9c08b584..43c2ca9d 100644 --- a/fdroidserver/metadata.py +++ b/fdroidserver/metadata.py @@ -153,7 +153,7 @@ class App(dict): self.AutoUpdateMode = 'None' self.UpdateCheckMode = 'None' self.UpdateCheckIgnore = None - self.VercodeOperation = None + self.VercodeOperation = [] self.UpdateCheckName = None self.UpdateCheckData = None self.CurrentVersion = '' @@ -204,6 +204,7 @@ fieldtypes = { 'AntiFeatures': TYPE_LIST, 'AllowedAPKSigningKeys': TYPE_LIST, 'Builds': TYPE_BUILD, + 'VercodeOperation': TYPE_LIST, 'CurrentVersionCode': TYPE_INT, } diff --git a/tests/lint.TestCase b/tests/lint.TestCase index 3cf6b857..07f775c4 100755 --- a/tests/lint.TestCase +++ b/tests/lint.TestCase @@ -222,7 +222,7 @@ class LintTest(unittest.TestCase): anywarns = False for good in good_fields: - app.VercodeOperation = good + app.VercodeOperation = [good] for warn in fdroidserver.lint.check_vercode_operation(app): anywarns = True logging.debug(warn) @@ -230,7 +230,7 @@ class LintTest(unittest.TestCase): for bad in bad_fields: anywarns = False - app.VercodeOperation = bad + app.VercodeOperation = [bad] for warn in fdroidserver.lint.check_vercode_operation(app): anywarns = True logging.debug(warn) diff --git a/tests/metadata/dump/com.politedroid.yaml b/tests/metadata/dump/com.politedroid.yaml index 01ea946e..aacff98c 100644 --- a/tests/metadata/dump/com.politedroid.yaml +++ b/tests/metadata/dump/com.politedroid.yaml @@ -178,7 +178,7 @@ UpdateCheckData: null UpdateCheckIgnore: null UpdateCheckMode: Tags UpdateCheckName: null -VercodeOperation: null +VercodeOperation: [] WebSite: '' added: null comments: {} diff --git a/tests/metadata/dump/org.adaway.yaml b/tests/metadata/dump/org.adaway.yaml index dd1fcd4f..7fe21c4d 100644 --- a/tests/metadata/dump/org.adaway.yaml +++ b/tests/metadata/dump/org.adaway.yaml @@ -1084,7 +1084,7 @@ UpdateCheckData: null UpdateCheckIgnore: null UpdateCheckMode: Tags UpdateCheckName: null -VercodeOperation: null +VercodeOperation: [] WebSite: http://sufficientlysecure.org/index.php/adaway added: null comments: {} diff --git a/tests/metadata/dump/org.smssecure.smssecure.yaml b/tests/metadata/dump/org.smssecure.smssecure.yaml index c3ad76b6..b010502b 100644 --- a/tests/metadata/dump/org.smssecure.smssecure.yaml +++ b/tests/metadata/dump/org.smssecure.smssecure.yaml @@ -360,7 +360,7 @@ UpdateCheckData: null UpdateCheckIgnore: null UpdateCheckMode: Tags UpdateCheckName: null -VercodeOperation: null +VercodeOperation: [] WebSite: http://www.smssecure.org added: null comments: {} diff --git a/tests/metadata/dump/org.videolan.vlc.yaml b/tests/metadata/dump/org.videolan.vlc.yaml index 652b5c2b..569724d8 100644 --- a/tests/metadata/dump/org.videolan.vlc.yaml +++ b/tests/metadata/dump/org.videolan.vlc.yaml @@ -2442,7 +2442,8 @@ UpdateCheckData: null UpdateCheckIgnore: null UpdateCheckMode: Tags UpdateCheckName: null -VercodeOperation: '%c + 5' +VercodeOperation: + - '%c + 5' WebSite: http://www.videolan.org/vlc/download-android.html added: null comments: {} diff --git a/tests/metadata/org.videolan.vlc.yml b/tests/metadata/org.videolan.vlc.yml index 62afe259..969c9674 100644 --- a/tests/metadata/org.videolan.vlc.yml +++ b/tests/metadata/org.videolan.vlc.yml @@ -804,6 +804,7 @@ ArchivePolicy: 9 versions AutoUpdateMode: None UpdateCheckMode: Tags # Only use higher vercode ops, if we do build those arches -VercodeOperation: "%c + 5" +VercodeOperation: + - "%c + 5" CurrentVersion: 1.2.6 CurrentVersionCode: 1030005 diff --git a/tests/update.TestCase b/tests/update.TestCase index 5b4e8142..59c1aac5 100755 --- a/tests/update.TestCase +++ b/tests/update.TestCase @@ -1447,7 +1447,7 @@ class UpdateTest(unittest.TestCase): 'UpdateCheckIgnore': '', 'UpdateCheckMode': '', 'UpdateCheckName': '', - 'VercodeOperation': '', + 'VercodeOperation': None, 'WebSite': '', }, )