Skip to content

Commit

Permalink
Merge branch 'master' into fix-gitlab-branch
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Apr 23, 2024
2 parents 46218bd + fb5c71b commit c3194df
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ designed to work with nixpkgs but also other package sets.
- Gitea
- GitHub
- GitLab
- NotABug.org
- PyPi
- RubyGems.org
- Sourcehut
Expand Down
2 changes: 1 addition & 1 deletion nix_update/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion nix_update/version/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
9 changes: 6 additions & 3 deletions nix_update/version/gitea.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import json
import re
from urllib.parse import ParseResult
from urllib.request import urlopen

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())
return [Version(tag["name"]) for tag in tags]


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())

Expand Down

0 comments on commit c3194df

Please sign in to comment.