Merge branch 'master' into fix-gitlab-branch

This commit is contained in:
mergify[bot] 2024-04-23 10:41:22 +00:00 committed by GitHub
commit c3194df384
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 6 deletions

View File

@ -11,7 +11,6 @@ designed to work with nixpkgs but also other package sets.
- Gitea
- GitHub
- GitLab
- NotABug.org
- PyPi
- RubyGems.org
- Sourcehut

View File

@ -323,7 +323,7 @@ def update_version(
elif package.parsed_url.netloc == "github.com":
_, owner, repo, *_ = package.parsed_url.path.split("/")
package.diff_url = f"https://github.com/{owner}/{repo.removesuffix('.git')}/compare/{package.rev}...{new_version.rev or new_version.number}"
elif package.parsed_url.netloc in ["codeberg.org", "gitea.com", "notabug.org"]:
elif package.parsed_url.netloc in ["codeberg.org", "gitea.com"]:
_, owner, repo, *_ = package.parsed_url.path.split("/")
package.diff_url = f"https://{package.parsed_url.netloc}/{owner}/{repo}/compare/{package.rev}...{new_version.rev or new_version.number}"
elif GITLAB_API.match(package.parsed_url.geturl()) and package.src_homepage:

View File

@ -133,5 +133,5 @@ def fetch_latest_version(
)
raise VersionError(
"Please specify the version. We can only get the latest version from codeberg/crates.io/gitea/github/gitlab/notabug/pypi/savannah/sourcehut/rubygems projects right now"
"Please specify the version. We can only get the latest version from codeberg/crates.io/gitea/github/gitlab/pypi/savannah/sourcehut/rubygems projects right now"
)

View File

@ -1,4 +1,5 @@
import json
import re
from urllib.parse import ParseResult
from urllib.request import urlopen
@ -6,10 +7,11 @@ from .version import Version
def fetch_gitea_versions(url: ParseResult) -> list[Version]:
if url.netloc not in ["codeberg.org", "gitea.com", "notabug.org"]:
if url.netloc not in ["codeberg.org", "gitea.com"]:
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())
@ -17,11 +19,12 @@ def fetch_gitea_versions(url: ParseResult) -> list[Version]:
def fetch_gitea_snapshots(url: ParseResult, branch: str) -> list[Version]:
if url.netloc not in ["codeberg.org", "gitea.com", "notabug.org"]:
if url.netloc not in ["codeberg.org", "gitea.com"]:
return []
_, owner, repo, *_ = url.path.split("/")
commits_url = f"https://{url.netloc}/api/v1/repos/{owner}/{repo}/commits?sha={branch}&limit=1stat=false"
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())