Skip to content

Commit

Permalink
Merge pull request devcontainers-contrib#53 from devcontainers-contri…
Browse files Browse the repository at this point in the history
…b/danielbraun89/issue46

fix: filter bad release names
  • Loading branch information
danielbraun89 authored Sep 5, 2023
2 parents 7614b4f + 5af209e commit 73d95fa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions nanolayer/cli/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def install_aptitude_packages(
def install_apk_packages(
packages: str = typer.Argument(None, help="comma separated list of apk packages")
) -> None:
print("hoii", flush=True)
ApkInstaller.install(
packages=packages.split(","),
)
Expand Down
18 changes: 17 additions & 1 deletion nanolayer/installers/gh_release/resolvers/release_resolver.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import json
import logging
import re
import urllib
from typing import Any, Dict, List, Optional

import invoke
from natsort import natsorted

logger = logging.getLogger(__name__)


class ReleaseResolver:
class ReleaseResolverError(Exception):
Expand Down Expand Up @@ -44,13 +47,26 @@ def get_version_tags(
return stringified_matches
return []

@classmethod
def valid_version(cls, value: str) -> bool:
normalized_value = value.lstrip("v")
return normalized_value[0].isalpha() or normalized_value[0].isdigit()

@classmethod
def get_latest_git_version_tag(
cls, repo: str, release_tag_regex: Optional[str] = None
) -> str:
all_version_tags = cls.get_version_tags(repo, release_tag_regex)

return natsorted(all_version_tags)[-1]
valid_versions = list(filter(cls.valid_version, all_version_tags))

if len(valid_versions) != len(all_version_tags):
logger.warning(
"The following release versions were filtered out as invalid: %s",
str(set(all_version_tags) - set(valid_versions)),
)

return natsorted(valid_versions)[-1]

@classmethod
def get_latest_release_tag(
Expand Down

0 comments on commit 73d95fa

Please sign in to comment.