Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundler/lib/bundler/source/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Rubygems < Source
API_REQUEST_SIZE = 100
REQUIRE_MUTEX = Mutex.new

attr_accessor :remotes
attr_accessor :remotes, :remote_cooldowns

def initialize(options = {})
@options = options
Expand Down
4 changes: 4 additions & 0 deletions bundler/lib/bundler/source_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ def replace_rubygems_source(replacement_sources, gemfile_source)
# locked sources never include credentials so always prefer remotes from the gemfile
replacement_source.remotes = gemfile_source.remotes

# cooldowns are only ever declared in the Gemfile, so carry them over
# along with the remotes they apply to
replacement_source.remote_cooldowns = gemfile_source.remote_cooldowns

yield replacement_source if block_given?

replacement_source
Expand Down
58 changes: 58 additions & 0 deletions spec/install/cooldown_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,64 @@
expect(the_bundle).to include_gems("ripe_gem 1.0.0")
end

it "applies per-source Gemfile cooldown on bundle update when a lockfile exists" do
# Converging the Gemfile sources with the lockfile sources used to drop
# the per-source cooldown, so it only ever worked on a first resolve
# without a lockfile.
gemfile <<-G
source "https://gem.repo3", cooldown: 7
gem "ripe_gem"
G

lockfile <<-L
GEM
remote: https://gem.repo3/
specs:
ripe_gem (1.0.0)

PLATFORMS
#{lockfile_platforms}

DEPENDENCIES
ripe_gem

BUNDLED WITH
#{Bundler::VERSION}
L

bundle "update ripe_gem", artifice: "compact_index_cooldown"

expect(the_bundle).to include_gems("ripe_gem 1.0.0")
end

it "applies per-source Gemfile cooldown to gems added after the lockfile was written" do
gemfile <<-G
source "https://gem.repo3", cooldown: 7
gem "ripe_gem"
gem "child"
G

lockfile <<-L
GEM
remote: https://gem.repo3/
specs:
ripe_gem (1.0.0)

PLATFORMS
#{lockfile_platforms}

DEPENDENCIES
ripe_gem

BUNDLED WITH
#{Bundler::VERSION}
L

bundle "install", artifice: "compact_index_cooldown"

expect(the_bundle).to include_gems("ripe_gem 1.0.0", "child 1.0.0")
end

it "is overridden by CLI --cooldown when Gemfile sets a different per-source value" do
gemfile <<-G
source "https://gem.repo3", cooldown: 0
Expand Down
Loading