From fb5c71b42223f9acf7b15c9a2af00a6ff3fc5615 Mon Sep 17 00:00:00 2001 From: emilylange Date: Sat, 20 Apr 2024 21:43:27 +0200 Subject: [PATCH] gitea: fix handling when `fetchFromGitea` falls back to `fetchgit` `fetchFromGitea` just re-uses `fetchFromGitHub`. The only difference is making `domain` a required attribute instead of defaulting to `"github.com"`. As such, it falls back to `fetchgit`, such like `fetchFromGitHub`, if any of the following is true: - fetchSubmodules - leaveDotGit - deepClose - sparseCheckout != [] - forceFetchGit When falling back to `fetchgit`, the `src.url` will end with `".git"`, which we then need to strip again from our parsed `repo` variable. `fetchFromGitHub` has the same logic to trim `".git"` unconditionally. --- nix_update/version/gitea.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nix_update/version/gitea.py b/nix_update/version/gitea.py index f4dc63a..f1eac0f 100644 --- a/nix_update/version/gitea.py +++ b/nix_update/version/gitea.py @@ -1,4 +1,5 @@ import json +import re from urllib.parse import ParseResult from urllib.request import urlopen @@ -10,6 +11,7 @@ def fetch_gitea_versions(url: ParseResult) -> list[Version]: return [] _, owner, repo, *_ = url.path.split("/") + repo = re.sub(r"\.git$", "", repo) tags_url = f"https://{url.netloc}/api/v1/repos/{owner}/{repo}/tags" resp = urlopen(tags_url) tags = json.loads(resp.read()) @@ -21,6 +23,7 @@ def fetch_gitea_snapshots(url: ParseResult, branch: str) -> list[Version]: return [] _, owner, repo, *_ = url.path.split("/") + repo = re.sub(r"\.git$", "", repo) commits_url = f"https://{url.netloc}/api/v1/repos/{owner}/{repo}/commits?sha={branch}&limit=1&stat=false&verification=false&files=false" resp = urlopen(commits_url) commits = json.loads(resp.read())