Skip to content

Commit f7acfeb

Browse files
deivid-rodriguezmatzbot
authored andcommitted
[rubygems/rubygems] Fix credentials being readded when re-resolving without a full unlock
rubygems/rubygems@a8670e43f8
1 parent bf6b8dd commit f7acfeb

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

lib/bundler/source/rubygems.rb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Rubygems < Source
1010
# Ask for X gems per API request
1111
API_REQUEST_SIZE = 50
1212

13-
attr_reader :remotes
13+
attr_accessor :remotes
1414

1515
def initialize(options = {})
1616
@options = options
@@ -20,9 +20,10 @@ def initialize(options = {})
2020
@allow_cached = false
2121
@allow_local = options["allow_local"] || false
2222
@checksum_store = Checksum::Store.new
23-
@original_remotes = nil
2423

2524
Array(options["remotes"]).reverse_each {|r| add_remote(r) }
25+
26+
@lockfile_remotes = @remotes if options["from_lockfile"]
2627
end
2728

2829
def caches
@@ -92,12 +93,7 @@ def options
9293

9394
def self.from_lock(options)
9495
options["remotes"] = Array(options.delete("remote")).reverse
95-
new(options)
96-
end
97-
98-
def remotes=(new_remotes)
99-
@original_remotes = @remotes
100-
@remotes = new_remotes
96+
new(options.merge("from_lockfile" => true))
10197
end
10298

10399
def to_lock
@@ -470,7 +466,7 @@ def cache_path
470466
private
471467

472468
def lockfile_remotes
473-
@original_remotes || credless_remotes
469+
@lockfile_remotes || credless_remotes
474470
end
475471

476472
# Checks if the requested spec exists in the global cache. If it does,

spec/bundler/lock/lockfile_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,16 @@
419419

420420
lockfile lockfile_without_credentials
421421

422+
# when not re-resolving
422423
bundle "install", artifice: "endpoint_strict_basic_authentication", quiet: true
424+
expect(lockfile).to eq lockfile_without_credentials
425+
426+
# when re-resolving with full unlock
427+
bundle "update", artifice: "endpoint_strict_basic_authentication"
428+
expect(lockfile).to eq lockfile_without_credentials
423429

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

0 commit comments

Comments
 (0)