[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 коммит произвёл git
Родитель 67612dadbc
Коммит c2e8e1f6a4
2 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -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}."

Просмотреть файл

@ -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