edopro: Fix passthru.updateScript

GitHub REST API currently returns a tag called "old-core" from 2015 as the first result. Filter that out.

Co-authored-by: Redhawk18 <redhawk76767676@gmail.com>
This commit is contained in:
OPNA2608
2026-07-25 22:32:08 +02:00
co-authored by Redhawk18
parent 2252d3e2ad
commit 5b0fc7e18d
+24 -7
View File
@@ -1,20 +1,37 @@
#!/usr/bin/env nix-shell
#! nix-shell -i python -p nix-prefetch-github python3Packages.githubkit
#! nix-shell -i python -p nix-prefetch-github python3Packages.githubkit python3Packages.packaging
import json
import subprocess
import sys
from githubkit import GitHub, UnauthAuthStrategy
from githubkit.versions.latest.models import (
Commit,
ContentSubmodule,
Tag,
)
from githubkit.versions.latest.models import Commit, ContentSubmodule, Tag
from packaging.version import InvalidVersion, Version
DEPS_PATH: str = "./pkgs/by-name/ed/edopro/deps.nix"
def parse_tag(parsed_tag_data) -> Version | None:
# The GitHub REST API does not guarantee that tags are returned newest-first,
# and it also returns non-version tags such as "old-core" from 2015. Parse each
# tag as a version so we can drop the ones that aren't versions and sort the rest.
try:
return Version(parsed_tag_data.name)
except InvalidVersion:
return None
with GitHub(UnauthAuthStrategy()) as github:
edopro: Tag = github.rest.repos.list_tags("edo9300", "edopro").parsed_data[0]
edopro_tags: list[Tag] = github.rest.repos.list_tags(
"edo9300", "edopro"
).parsed_data
versioned_tags: list[Tag] = [
tag for tag in edopro_tags if parse_tag(tag) is not None
]
if not versioned_tags:
print("Error: No valid version tags found.", file=sys.stderr)
exit(3)
edopro: Tag = max(versioned_tags, key=lambda tag: Version(tag.name))
# This dep is not versioned in any way and is why we check below to see if this is a new version.
irrlicht: Commit = github.rest.repos.list_commits(