diff --git a/nanolayer/installers/gh_release/resolvers/release_resolver.py b/nanolayer/installers/gh_release/resolvers/release_resolver.py index 9e7f3c46..1a59ce86 100644 --- a/nanolayer/installers/gh_release/resolvers/release_resolver.py +++ b/nanolayer/installers/gh_release/resolvers/release_resolver.py @@ -3,6 +3,7 @@ import re import urllib from typing import Any, Dict, List, Optional +import distutils.spawn import invoke from natsort import natsorted @@ -81,6 +82,10 @@ def get_latest_release_tag( release_tags = cls._filter_tags_by_regex(release_tags, release_tag_regex) return natsorted(release_tags)[-1] + @classmethod + def _git_exists(cls) -> bool: + return distutils.spawn.find_executable("git") is not None + @classmethod def resolve( cls, @@ -90,9 +95,10 @@ def resolve( use_github_api: bool = False, ) -> str: if asked_version == "latest": - if use_github_api: + if use_github_api or not cls._git_exists(): return cls.get_latest_release_tag(repo, release_tag_regex) - return cls.get_latest_git_version_tag(repo, release_tag_regex) + else: + return cls.get_latest_git_version_tag(repo, release_tag_regex) else: versions = cls.get_version_tags(repo, release_tag_regex)