From bb638b1d613a256c50b5397ed6e8a4675a15f44a Mon Sep 17 00:00:00 2001 From: orhtej2 <2871798+orhtej2@users.noreply.github.com> Date: Wed, 24 Jan 2024 19:32:24 +0100 Subject: [PATCH] Support for GitLab upstream repos part 2. --- autoupdate_app_sources/autoupdate_app_sources.py | 2 +- autoupdate_app_sources/rest_api.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/autoupdate_app_sources/autoupdate_app_sources.py b/autoupdate_app_sources/autoupdate_app_sources.py index b8da97e..dfd15b7 100644 --- a/autoupdate_app_sources/autoupdate_app_sources.py +++ b/autoupdate_app_sources/autoupdate_app_sources.py @@ -171,7 +171,7 @@ class AppAutoUpdater: print(f"\n Checking {source} ...") - if strategy == "latest_github_release": + if strategy == "latest_github_release" or strategy == "latest_gitlab_release": ( new_version, new_asset_urls, diff --git a/autoupdate_app_sources/rest_api.py b/autoupdate_app_sources/rest_api.py index 8a79f33..d7da8a8 100644 --- a/autoupdate_app_sources/rest_api.py +++ b/autoupdate_app_sources/rest_api.py @@ -88,7 +88,9 @@ class GitlabAPI: def releases(self) -> List[str]: """Get a list of releases for project.""" releases = self.internal_api(f"projects/{self.project_id}/releases") - return [{ + retval = [] + for release in releases: + r = { "tag_name": release["tag_name"], "prerelease": False, "draft": False, @@ -97,7 +99,15 @@ class GitlabAPI: "name": asset["name"], "browser_download_url": asset["direct_asset_url"] } for asset in release["assets"]["links"]], - } for release in releases] + } + for source in release["assets"]["sources"]: + r["assets"].append({ + "name": f"source.{source['format']}", + "browser_download_url": source['url'] + }) + retval.append(r) + + 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}"