From c19f46b706adaed10c7d296439f93e964c844e15 Mon Sep 17 00:00:00 2001 From: Jochen Sprickerhof Date: Thu, 14 Apr 2022 12:47:27 +0200 Subject: [PATCH] [checkupdates] move gradle var check to parser 3638acddc added a check if the version name string is actually a unresolved gradle variable. This moves the check into the common.parse_androidmanifests() as it is the only where the it could happen. This also resolves the case where checkupdates returns "Unknown". Closes: #751 --- fdroidserver/checkupdates.py | 6 ------ fdroidserver/common.py | 25 +++++++++++++++++++------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/fdroidserver/checkupdates.py b/fdroidserver/checkupdates.py index 69b2f544..86a18c2e 100644 --- a/fdroidserver/checkupdates.py +++ b/fdroidserver/checkupdates.py @@ -455,12 +455,6 @@ def checkupdates_app(app): vercode = str(common.calculate_math_string(op)) logging.debug("Applied vercode operation: %s -> %s" % (oldvercode, vercode)) - if version and any(version.startswith(s) for s in [ - '${', # Gradle variable names - '@string/', # Strings we could not resolve - ]): - version = "Unknown" - updating = False if version is None: raise FDroidException(_('no version information found')) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index bf3e5ff2..61285c08 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -1703,6 +1703,18 @@ def parse_androidmanifests(paths, app): max_vercode = None max_package = None + def vnsearch(line): + matches = vnsearch_g(line) + if matches and not any( + matches.group(2).startswith(s) + for s in [ + '${', # Gradle variable names + '@string/', # Strings we could not resolve + ] + ): + return matches.group(2) + return None + for path in paths: # TODO: Remove this in Python3.6 path = str(path) @@ -1735,9 +1747,9 @@ def parse_androidmanifests(paths, app): temp_app_id = matches.group(2) if "versionName" in line and not temp_version_name: - matches = vnsearch_g(line) + matches = vnsearch(line) if matches: - temp_version_name = matches.group(2) + temp_version_name = matches if inside_flavour_group > 0: if inside_required_flavour > 1: @@ -1755,9 +1767,10 @@ def parse_androidmanifests(paths, app): if app_matches_packagename(app, temp_app_id): package = temp_app_id - matches = vnsearch_g(line) + matches = vnsearch(line) if matches: - version = matches.group(2) + version = matches + else: # If build.gradle contains applicationNameSuffix add it to the end of version name matches = vnssearch_g(line) @@ -1799,9 +1812,9 @@ def parse_androidmanifests(paths, app): if app_matches_packagename(app, s): package = s if not version: - matches = vnsearch_g(line) + matches = vnsearch(line) if matches: - version = matches.group(2) + version = matches if not vercode: matches = vcsearch_g(line) if matches: