mirror of
https://github.com/Mic92/nix-update.git
synced 2024-11-03 21:04:49 +03:00
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.
This commit is contained in:
parent
b03e9dc75a
commit
fb5c71b422
@ -1,4 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
|
import re
|
||||||
from urllib.parse import ParseResult
|
from urllib.parse import ParseResult
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
|
||||||
@ -10,6 +11,7 @@ def fetch_gitea_versions(url: ParseResult) -> list[Version]:
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
_, owner, repo, *_ = url.path.split("/")
|
_, owner, repo, *_ = url.path.split("/")
|
||||||
|
repo = re.sub(r"\.git$", "", repo)
|
||||||
tags_url = f"https://{url.netloc}/api/v1/repos/{owner}/{repo}/tags"
|
tags_url = f"https://{url.netloc}/api/v1/repos/{owner}/{repo}/tags"
|
||||||
resp = urlopen(tags_url)
|
resp = urlopen(tags_url)
|
||||||
tags = json.loads(resp.read())
|
tags = json.loads(resp.read())
|
||||||
@ -21,6 +23,7 @@ def fetch_gitea_snapshots(url: ParseResult, branch: str) -> list[Version]:
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
_, owner, repo, *_ = url.path.split("/")
|
_, 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"
|
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)
|
resp = urlopen(commits_url)
|
||||||
commits = json.loads(resp.read())
|
commits = json.loads(resp.read())
|
||||||
|
Loading…
Reference in New Issue
Block a user