Skip to content

Commit 4ff04d6

Browse files
Make installer code more clear
I always found the `resolve_if_necessary` method pretty confusing because by reading it, it suggests that resolution always happens, and the point is whether that needs to be local or remote. This commit tries to make that more clear.
1 parent 25bcb6a commit 4ff04d6

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

bundler/lib/bundler/definition.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,24 @@ def check!
176176
resolve
177177
end
178178

179+
#
180+
# Setup sources according to the given options and the state of the
181+
# definition.
182+
#
183+
# @return [Boolean] Whether fetching remote information will be necessary or not
184+
#
185+
def setup_domain!(options)
186+
prefer_local! if options[:"prefer-local"]
187+
188+
if options[:local] || (no_resolve_needed? && !missing_specs?)
189+
with_cache!
190+
false
191+
else
192+
remotely!
193+
true
194+
end
195+
end
196+
179197
def resolve_with_cache!
180198
with_cache!
181199

bundler/lib/bundler/installer.rb

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def run(options)
7777
return
7878
end
7979

80-
if resolve_if_needed(options)
80+
if @definition.setup_domain!(options)
8181
ensure_specs_are_compatible!
8282
Bundler.load_plugins(@definition)
8383
options.delete(:jobs)
@@ -229,19 +229,6 @@ def ensure_specs_are_compatible!
229229
end
230230
end
231231

232-
# returns whether or not a re-resolve was needed
233-
def resolve_if_needed(options)
234-
@definition.prefer_local! if options[:"prefer-local"]
235-
236-
if options[:local] || (@definition.no_resolve_needed? && !@definition.missing_specs?)
237-
@definition.with_cache!
238-
false
239-
else
240-
@definition.remotely!
241-
true
242-
end
243-
end
244-
245232
def lock
246233
@definition.lock
247234
end

0 commit comments

Comments
 (0)