From 946f8d6246c04bf2f5695f50b0de0843f12c3190 Mon Sep 17 00:00:00 2001 From: Daniel Braun Date: Sat, 6 Jan 2024 07:07:00 +0000 Subject: [PATCH] [Bug]: gh-release requires git as part of the install process, but does not install it itself. --- .../gh_release/resolvers/release_resolver.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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)