From 76aa4c9f0a0b9fbc319dd3060d1bfc8dbcdd3c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 14 Feb 2024 23:56:32 +0100 Subject: [PATCH] Fix typing for giteaforgejoapi, fix url_for_ref for gitlab --- autoupdate_app_sources/rest_api.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/autoupdate_app_sources/rest_api.py b/autoupdate_app_sources/rest_api.py index 269ba40..c612e48 100644 --- a/autoupdate_app_sources/rest_api.py +++ b/autoupdate_app_sources/rest_api.py @@ -32,11 +32,11 @@ class GithubAPI: """Get a list of tags for project.""" return self.internal_api(f"repos/{self.upstream_repo}/tags") - def commits(self) -> list[dict[str, ]]: + def commits(self) -> list[dict[str, Any]]: """Get a list of commits for project.""" return self.internal_api(f"repos/{self.upstream_repo}/commits") - def releases(self) -> list[dict[str]]: + def releases(self) -> list[dict[str, Any]]: """Get a list of releases for project.""" return self.internal_api(f"repos/{self.upstream_repo}/releases") @@ -113,12 +113,14 @@ class GitlabAPI: return retval def url_for_ref(self, ref: str, ref_type: RefType) -> str: - return f"{self.upstream}/api/v4/projects/{self.project_id}/repository/archive.tar.gz/?sha={ref}" + name = self.upstream_repo.split("/")[-1] + return f"{self.upstream}/{self.upstream_repo}/-/archive/{ref}/{name}-{ref}.tar.bz2" class GiteaForgejoAPI: def __init__(self, upstream: str): split = re.search("(?Phttps?://.+)/(?P[^/]+)/(?P[^/]+)/?$", upstream) + assert split is not None self.upstream = split.group("host") self.upstream_repo = f"{split.group('group')}/{split.group('project')}" @@ -128,15 +130,15 @@ class GiteaForgejoAPI: assert r.status_code == 200, r return r.json() - def tags(self) -> List[str]: + def tags(self) -> list[dict[str, Any]]: """Get a list of tags for project.""" return self.internal_api(f"repos/{self.upstream_repo}/tags") - def commits(self) -> List[str]: + def commits(self) -> list[dict[str, Any]]: """Get a list of commits for project.""" return self.internal_api(f"repos/{self.upstream_repo}/commits") - def releases(self) -> List[str]: + def releases(self) -> list[dict[str, Any]]: """Get a list of releases for project.""" return self.internal_api(f"repos/{self.upstream_repo}/releases")