From a5560c30359a46a71445108b9cc6d9f70fb14f75 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Thu, 11 Apr 2024 21:19:14 +0200 Subject: [PATCH] Update resources.py: fix edge case when parsing app ustream version from resource manager --- src/utils/resources.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/utils/resources.py b/src/utils/resources.py index dfb6d48ed..ce2454efe 100644 --- a/src/utils/resources.py +++ b/src/utils/resources.py @@ -148,16 +148,19 @@ class AppResource: self.manager = manager properties = self.default_properties | properties + # It's not guaranteed that this info will be defined, e.g. during unit tests, only small resource snippets are used, not proper manifests + app_upstream_version = "" + if manager and manager.wanted and "version" in manager.wanted: + app_upstream_version = manager.wanted["version"].split("~")[0] + elif maanger and manager.current and "version" in manager.current: + app_upstream_version = manager.current["version"].split("~")[0] + replacements: dict[str, str] = { "__APP__": self.app, "__YNH_ARCH__": system_arch(), "__YNH_DEBIAN_VERSION__": debian_version(), "__YNH_DEBIAN_VERSION_ID__": debian_version_id(), - "__YNH_APP_UPSTREAM_VERSION__": ( - manager.wanted["version"].split("~")[0] - if "version" in manager.wanted - else manager.current["version"].split("~")[0] - ), + "__YNH_APP_UPSTREAM_VERSION__": app_upstream_version, } def recursive_apply(function: Callable, data: Any) -> Any: