1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[rubygems/rubygems] Fix checksum

Calculate the checksum of the content, not the given pathname at
the build time itself.

https://github.com/rubygems/rubygems/commit/b60ee97ee9
This commit is contained in:
Nobuyoshi Nakada 2022-01-04 00:24:58 +09:00 committed by git
parent 67612dadbc
commit c2e8e1f6a4
2 changed files with 7 additions and 1 deletions

View file

@ -107,7 +107,7 @@ module Bundler
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.new.hexdigest(built_gem_path.to_s)
checksum = ::Digest::SHA512.file(built_gem_path).hexdigest
target = File.join(base, "checksums", file_name)
File.write(target, checksum)
Bundler.ui.confirm "#{name} #{version} checksum written to checksums/#{file_name}."

View file

@ -169,6 +169,12 @@ RSpec.describe Bundler::GemHelper do
end
describe "#build_checksum" do
it "calculates SHA512 of the content" do
subject.build_checksum(Pathname(IO::NULL))
sha_path = app_path.join("checksums", "#{File.basename(IO::NULL)}.sha512")
expect(File.read(sha_path)).to eql(Digest::SHA512.hexdigest(""))
end
context "when build was successful" do
it "creates .sha512 file" do
mock_build_message app_name, app_version