-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add sha256 checksum to rake build:checksum #6022
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,10 @@ | |
|
|
||
| module Bundler | ||
| class GemHelper | ||
| CHECKSUMS = { | ||
| "sha256" => "::Digest::SHA256", | ||
| "sha512" => "::Digest::SHA512", | ||
| }.freeze | ||
| include Rake::DSL if defined? Rake::DSL | ||
|
|
||
| class << self | ||
|
|
@@ -47,9 +51,9 @@ def install | |
| built_gem_path = build_gem | ||
| end | ||
|
|
||
| desc "Generate SHA512 checksum if #{name}-#{version}.gem into the checksums directory." | ||
| desc "Build #{name}-#{version}.gem into pkg directory, then generate SHA256 & SHA512 checksums in checksums directory." | ||
| task "build:checksum" => "build" do | ||
| build_checksum(built_gem_path) | ||
| build_checksums(built_gem_path) | ||
| end | ||
|
|
||
| desc "Build and install #{name}-#{version}.gem into system gems." | ||
|
|
@@ -102,19 +106,25 @@ def install_gem(built_gem_path = nil, local = false) | |
| Bundler.ui.confirm "#{name} (#{version}) installed." | ||
| end | ||
|
|
||
| def build_checksum(built_gem_path = nil) | ||
| def build_checksums(built_gem_path = nil) | ||
| built_gem_path ||= build_gem | ||
| SharedHelpers.filesystem_access(File.join(base, "checksums")) {|p| FileUtils.mkdir_p(p) } | ||
| file_name = "#{File.basename(built_gem_path)}.sha512" | ||
| require "digest/sha2" | ||
| checksum = ::Digest::SHA512.file(built_gem_path).hexdigest | ||
| CHECKSUMS.each do |extension, digest_klass| | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Super minor but I'm thinking, do you think the write_checksum(built_gem_path, "sha256", Digest::SHA256)
write_checksum(built_gem_path, "sha512", Digest::SHA512)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't get us much, agreed. |
||
| write_checksum(built_gem_path, extension, Object.const_get(digest_klass)) | ||
| end | ||
| end | ||
|
|
||
| protected | ||
|
|
||
| def write_checksum(built_gem_path, extension, type) | ||
| SharedHelpers.filesystem_access(File.join(base, "checksums")) {|p| FileUtils.mkdir_p(p) } | ||
| file_name = "#{File.basename(built_gem_path)}.#{extension}" | ||
| checksum = type.file(built_gem_path).hexdigest | ||
| target = File.join(base, "checksums", file_name) | ||
| File.write(target, checksum + "\n") | ||
| Bundler.ui.confirm "#{name} #{version} checksum written to checksums/#{file_name}." | ||
| end | ||
|
|
||
| protected | ||
|
|
||
| def rubygem_push(path) | ||
| cmd = [*gem_command, "push", path] | ||
| cmd << "--key" << gem_key if gem_key | ||
|
|
||
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
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
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
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
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
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
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.
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.
Why was this moved inside the
write_checksumsmethod? It should be enough to run it just once I think?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.
Good point. Oversight.