Skip to content
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

Build trusted publisher filter #5237

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

justinddaniel
Copy link

No description provided.

@@ -411,6 +411,10 @@ def gem_file_name
"#{full_name}.gem"
end

def pushed_by_trusted_publisher?
pusher_api_key&.trusted_publisher? ? true : false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't trusted_publisher? already return true/false? Is there any reason for explicit ? true: false?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The safe navigator means a nil value can be returned if the version has no pusher_api_key.

Copy link
Member

@simi simi Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would pusher_api_key? && pusher_api_key.trusted_publisher? work also?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but pusher_api_key.present? && pusher_api_key.trusted_publisher? would work. It is a matter of preference here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe pusher_api_key&.trusted_publisher? || false. Yes, just a nitpick indeed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I the only one that prefers !! to force boolean?

Copy link

codecov bot commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.19%. Comparing base (a86b845) to head (ecb6a85).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5237      +/-   ##
==========================================
- Coverage   96.85%   94.19%   -2.67%     
==========================================
  Files         456      456              
  Lines        9517     9578      +61     
==========================================
- Hits         9218     9022     -196     
- Misses        299      556     +257     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@justinddaniel
Copy link
Author

Linked issue: #4807

@simi
Copy link
Member

simi commented Nov 14, 2024

CI seems unhappy about this test.

expected_response = {
"name" => "gemsgemsgems",
"downloads" => 0,
"version" => "0.1.1",
"version_downloads" => 0,
"platform" => "ruby",
"authors" => "Joe User",
"info" => "Some awesome gem",
"licenses" => "MIT",
"metadata" => { "foo" => "bar" },
"sha" => "b5d4045c3f466fa91fe2cc6abe79232a1a57cdf104f7a26e716e0a1e2789df78",
"project_uri" => "http://localhost/gems/gemsgemsgems",
"gem_uri" => "http://localhost/gems/gemsgemsgems-0.1.1.gem",
"homepage_uri" => "http://example.com",
"wiki_uri" => "http://example.com",
"documentation_uri" => "http://example.com",
"mailing_list_uri" => "http://example.com",
"source_code_uri" => "http://example.com",
"bug_tracker_uri" => "http://example.com",
"changelog_uri" => nil,
"funding_uri" => nil,
"yanked" => false,
"summary" => "old summary",
"description" => "Some awesome gem",
"updated" => "2016-07-04T00:00:00.000Z",
"dependencies" => { "development" => [], "runtime" => [] },
"suggest" => { "input" => "gemsgemsgems", "weight" => 0, "contexts" => { "yanked" => false } }
}
Should be as simple fix as adding this new key in to the tested hash.

@@ -25,7 +25,8 @@ module RubygemSearchable
suggest: { type: "completion", contexts: { name: "yanked", type: "category" } },
yanked: { type: "boolean" },
downloads: { type: "long" },
updated: { type: "date" }
updated: { type: "date" },
trusted_publisher: { type: "boolean" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mapping change need full re-indexing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I would not think so, since there is no change to the database source schema, but I am not sure. It is my first time committing to this repo and I do not have full context, so I will wait for others to weigh in.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any new mappings do require a reindex, which is easy to do but needs some coordination when deployed.

@martinemde
Copy link
Member

@justinddaniel Thank you for contributing this! Pleasure working with you today.

@colby-swandale colby-swandale added the requires-reindex A change that requires reimporting rubygems.org search data label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
requires-reindex A change that requires reimporting rubygems.org search data
Projects
Development

Successfully merging this pull request may close these issues.

4 participants