-
Notifications
You must be signed in to change notification settings - Fork 84
github releases for onpremise installations #441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughImplements conditional construction of the GitHub releases API URL to support non-default GitHub hosts while keeping existing token handling, request execution, and JSON-to-Version parsing unchanged. Moves the pagination TODO comment to align with the new URL branch. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Caller
participant GH as GitHubReleasesFetcher
participant URL as URL Builder
participant HTTP as HTTP Client
participant JSON as Parser
Caller->>GH: fetch_releases(url, token)
GH->>URL: build_releases_api_url(owner, repo, netloc)
alt Default host (github.com/api.github.com)
URL-->>GH: https://api.github.com/repos/{owner}/{repo}/releases?per_page=100
else Non-default host (Enterprise)
URL-->>GH: https://{netloc}/api/v3/repos/{owner}/{repo}/releases?per_page=100
end
GH->>HTTP: GET releases (Authorization if token)
HTTP-->>GH: JSON response
GH->>JSON: parse releases into Version objects
JSON-->>Caller: [Version...]
note over GH,HTTP: TODO: pagination handling remains pending
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
SuperSandro2000
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested with GH
gh api --hostname github.some.domain repos/abc/def/releases?per_page=100
nix_update/version/github.py
Outdated
| # TODO: pagination? | ||
| github_url = f"https://api.github.com/repos/{owner}/{repo}/releases?per_page=100" | ||
| if url.netloc != "github.com" and url.netloc != "api.github.com": | ||
| github_url = f"https://{url.netloc}/api/v3/repos/{owner}/{repo}/releases?per_page=100" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the reason for still beeing in draft mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
nix_update/version/github.py (1)
91-91: Consider the pagination implementation for production use.The pagination TODO comment has been moved here, which aligns well with the new URL construction logic. However, for production use with large repositories or on-premise installations that may have many releases, pagination should be implemented to ensure all releases are fetched.
Here's a potential implementation approach for pagination:
def fetch_github_versions_from_releases( url: ParseResult, owner: str, repo: str, ) -> list[Version]: base_url = f"https://api.github.com/repos/{owner}/{repo}/releases" if url.netloc not in {"github.com", "api.github.com"}: base_url = f"https://{url.netloc}/api/v3/repos/{owner}/{repo}/releases" token = os.environ.get("GITHUB_TOKEN") extra_headers = {} if token is None else {"Authorization": f"Bearer {token}"} all_versions = [] page = 1 per_page = 100 while True: github_url = f"{base_url}?per_page={per_page}&page={page}" info(f"fetch {github_url}") resp = _dorequest(url, github_url, extra_headers) try: releases = json.loads(resp) except json.JSONDecodeError: info("unable to parse github response, ignoring") break if not releases: # No more releases break all_versions.extend([Version(r["tag_name"], r["prerelease"]) for r in releases]) if len(releases) < per_page: # Last page break page += 1 return all_versions
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
nix_update/version/github.py(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: tests
🔇 Additional comments (1)
nix_update/version/github.py (1)
86-89: LGTM! Proper conditional URL construction for on-premise GitHub installations.The logic correctly handles different GitHub hosts by checking if the netloc is not the default GitHub domains and constructs the appropriate API URL for on-premise installations using the
/api/v3/path.
Summary by CodeRabbit