Skip to content

Commit bb2e4d5

Browse files
hsbtmatzbot
authored andcommitted
[ruby/rubygems] Fixed checksums generation issue when no source is specified
ruby/rubygems@bb4d791cb4
1 parent 7bd80e7 commit bb2e4d5

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

lib/bundler/definition.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,8 @@ def unlocking?
539539
end
540540

541541
def add_checksums
542+
require "rubygems/package"
543+
542544
@locked_checksums = true
543545

544546
setup_domain!(add_checksums: true)

spec/bundler/commands/lock_spec.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,6 +2035,56 @@
20352035
L
20362036
end
20372037

2038+
it "adds checksums when source is not specified" do
2039+
system_gems(%w[myrack-1.0.0], path: default_bundle_path)
2040+
2041+
gemfile <<-G
2042+
gem "myrack"
2043+
G
2044+
2045+
lockfile <<~L
2046+
GEM
2047+
specs:
2048+
myrack (1.0.0)
2049+
2050+
PLATFORMS
2051+
ruby
2052+
x86_64-linux
2053+
2054+
DEPENDENCIES
2055+
myrack
2056+
2057+
BUNDLED WITH
2058+
#{Bundler::VERSION}
2059+
L
2060+
2061+
simulate_platform "x86_64-linux" do
2062+
bundle "lock --add-checksums"
2063+
end
2064+
2065+
# myrack is coming from gem_repo1
2066+
# but it's simulated to install in the system gems path
2067+
checksums = checksums_section do |c|
2068+
c.checksum gem_repo1, "myrack", "1.0.0"
2069+
end
2070+
2071+
expect(lockfile).to eq <<~L
2072+
GEM
2073+
specs:
2074+
myrack (1.0.0)
2075+
2076+
PLATFORMS
2077+
ruby
2078+
x86_64-linux
2079+
2080+
DEPENDENCIES
2081+
myrack
2082+
#{checksums}
2083+
BUNDLED WITH
2084+
#{Bundler::VERSION}
2085+
L
2086+
end
2087+
20382088
it "adds checksums to an existing lockfile, when gems are already installed" do
20392089
build_repo4 do
20402090
build_gem "nokogiri", "1.14.2"

0 commit comments

Comments
 (0)