Skip to content

Commit

Permalink
[rubygems/rubygems] Fix credentials being readded when re-resolving w…
Browse files Browse the repository at this point in the history
…ithout a full unlock

rubygems/rubygems@a8670e43f8
  • Loading branch information
deivid-rodriguez authored and matzbot committed Jun 20, 2024
1 parent bf6b8dd commit f7acfeb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/bundler/source/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Rubygems < Source
# Ask for X gems per API request
API_REQUEST_SIZE = 50

attr_reader :remotes
attr_accessor :remotes

def initialize(options = {})
@options = options
Expand All @@ -20,9 +20,10 @@ def initialize(options = {})
@allow_cached = false
@allow_local = options["allow_local"] || false
@checksum_store = Checksum::Store.new
@original_remotes = nil

Array(options["remotes"]).reverse_each {|r| add_remote(r) }

@lockfile_remotes = @remotes if options["from_lockfile"]
end

def caches
Expand Down Expand Up @@ -92,12 +93,7 @@ def options

def self.from_lock(options)
options["remotes"] = Array(options.delete("remote")).reverse
new(options)
end

def remotes=(new_remotes)
@original_remotes = @remotes
@remotes = new_remotes
new(options.merge("from_lockfile" => true))
end

def to_lock
Expand Down Expand Up @@ -470,7 +466,7 @@ def cache_path
private

def lockfile_remotes
@original_remotes || credless_remotes
@lockfile_remotes || credless_remotes
end

# Checks if the requested spec exists in the global cache. If it does,
Expand Down
8 changes: 8 additions & 0 deletions spec/bundler/lock/lockfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,16 @@

lockfile lockfile_without_credentials

# when not re-resolving
bundle "install", artifice: "endpoint_strict_basic_authentication", quiet: true
expect(lockfile).to eq lockfile_without_credentials

# when re-resolving with full unlock
bundle "update", artifice: "endpoint_strict_basic_authentication"
expect(lockfile).to eq lockfile_without_credentials

# when re-resolving without ful unlocking
bundle "update rack-obama", artifice: "endpoint_strict_basic_authentication"
expect(lockfile).to eq lockfile_without_credentials
end

Expand Down

0 comments on commit f7acfeb

Please sign in to comment.