Always show source code on sidebar, even if duplicate link#6118
Open
mikeygough wants to merge 1 commit intorubygems:masterfrom
Open
Always show source code on sidebar, even if duplicate link#6118mikeygough wants to merge 1 commit intorubygems:masterfrom
mikeygough wants to merge 1 commit intorubygems:masterfrom
Conversation
72a99f6 to
1f163fd
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6118 +/- ##
==========================================
- Coverage 97.24% 94.46% -2.78%
==========================================
Files 476 476
Lines 9785 9851 +66
==========================================
- Hits 9515 9306 -209
- Misses 270 545 +275 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jenshenny
reviewed
Dec 3, 2025
Member
jenshenny
left a comment
There was a problem hiding this comment.
This change makes sense to me
| end | ||
|
|
||
| should "always include source code even when duplicate" do | ||
| metadata = { "homepage_uri" => "https://example.com", "source_code_uri" => "https://example.com" } |
Member
There was a problem hiding this comment.
Suggested change
| metadata = { "homepage_uri" => "https://example.com", "source_code_uri" => "https://example.com" } | |
| metadata = { "homepage_uri" => "https://example.code", "source_code_uri" => "https://example.code" } |
I think you mean this?
jenshenny
reviewed
Dec 3, 2025
Comment on lines
+38
to
+49
| seen_urls = {} | ||
| links.select do |short, long| | ||
| url = send(long) | ||
| # always include 'code' (source_code_uri) even if URL is duplicate | ||
| if short == "code" | ||
| true | ||
| elsif seen_urls[url] | ||
| false | ||
| else | ||
| seen_urls[url] = true | ||
| true | ||
| end |
Member
There was a problem hiding this comment.
This is slightly confusing to me since there's a lot of booleans and conditionals, how about this?
Have REQUIRED_INDEXED_LINK_KEYS
Suggested change
| seen_urls = {} | |
| links.select do |short, long| | |
| url = send(long) | |
| # always include 'code' (source_code_uri) even if URL is duplicate | |
| if short == "code" | |
| true | |
| elsif seen_urls[url] | |
| false | |
| else | |
| seen_urls[url] = true | |
| true | |
| end | |
| unique_links = links.uniq do |_short, long| | |
| send(long) | |
| end.to_h | |
| # always include certain URLs even if URL is a duplicate | |
| links.select do |short, _long| | |
| unique_links.key?(short) || REQUIRED_INDEXED_LINK_KEYS.include?(short) | |
| end |
Contributor
|
I'm not attached to the code. I picked it up as a "good first issue" at Railsconf a few years back. |
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.
Motivation / Background
Browsing rubygems.org recently I found it strange that some gems show a "Source Code" link in the sidebar while others do not, even if it is set in the gemspec's
source_code_urifield.For example:
Rake does not show "Source Code"
ActiveSupport does show "Source Code"
Both gems specify a
source_code_urivalue in their respective gemspec files.I dove into this and it looks like we are deduping links to declutter the sidebar.
I think this is generally a good idea but would like to propose we always show "Source Code" if it is set. Yes, users can always find the Github page for a gem by clicking the Github Star icon but it feels more intuitive to click "Source Code" if you're looking for the source code.
@etherbob Do you have a strong opinion about this? I don't want to completely revert your change but I also see that even you noted in your original PR, "There's probably also a question to be asked about gem author intent with the duplicate links and whether or not someone might get confused if they don't see a specific link to "source code" for instance if it's been superseded by the "home page" link." I think this is exactly what I'm experiencing and maybe others are as well 😅
Detail
This Pull Request modifies the
unique_linksmethod implementation to remove duplicate links but always includesource_code_uri.I decided to change the
unique_linksmethod to preserve most of the existing behavior. Given that I'm introducing a uniqueness exception tosource_code_uri, should we rename this method? It is still removing duplicate links so maybe it's fine but value others' opinions.