Fix RubyGems package metadata - #55
Open
andrew wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the RubyGems registry integration to pick a more accurate repository URL from RubyGems metadata (prioritizing source_code_uri, with a controlled fallback to forge homepages) and to populate LatestVersion directly from the gem API response, addressing issue #54 where Repository could incorrectly point at documentation pages.
Changes:
- Prefer
source_code_uriforPackage.Repository, falling back tohomepage_urionly when it canonicalizes to a known forge host. - Populate
Package.LatestVersionfrom the RubyGems gem API response (version). - Add test coverage for
LatestVersionand the forge-homepage fallback behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/rubygems/rubygems.go | Changes repository URL selection logic and fills LatestVersion from the gem API response. |
| internal/rubygems/rubygems_test.go | Adds tests for LatestVersion, homepage fallback behavior, and extractRepoURL precedence. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| } | ||
|
|
||
| repoURL := extractRepoURL(resp.SourceCodeURI, resp.WikiURI, resp.DocumentURI, resp.BugTrackerURI, resp.ChangelogURI, resp.HomepageURI) | ||
| repoURL := extractRepoURL(resp.SourceCodeURI, resp.HomepageURI) |
Comment on lines
+57
to
+68
| server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| resp := gemResponse{ | ||
| Name: "octokit", | ||
| Version: "10.0.0", | ||
| HomepageURI: "https://github.com/octokit/octokit.rb", | ||
| DocumentURI: "https://www.rubydoc.info/gems/octokit/10.0.0", | ||
| SourceCodeURI: "", | ||
| } | ||
|
|
||
| w.Header().Set("Content-Type", "application/json") | ||
| _ = json.NewEncoder(w).Encode(resp) | ||
| })) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use
source_code_urifor RubyGems repository metadata and only fall back tohomepage_uriwhen it points to a known forge. PopulateLatestVersionfrom the API response.Fixes #54