Skip to content

Commit

Permalink
Merge pull request #15778 from Bo98/dep-source-fix
Browse files Browse the repository at this point in the history
formula_installer: use cached fetched formula instance when available
  • Loading branch information
MikeMcQuaid committed Aug 15, 2023
2 parents 0d29831 + dcbdc73 commit d7268ae
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Library/Homebrew/formula_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def initialize(
@requirement_messages = []
@poured_bottle = false
@start_time = nil

# Take the original formula instance, which might have been swapped from an API instance to a source instance
@formula = previously_fetched_formula if previously_fetched_formula
end

def self.attempted
Expand Down Expand Up @@ -1182,9 +1185,17 @@ def fetch_dependencies
deps.each { |dep, _options| fetch_dependency(dep) }
end

sig { returns(T.nilable(Formula)) }
def previously_fetched_formula
# We intentionally don't compare classes here.
self.class.fetched.find do |fetched_formula|
fetched_formula.full_name == formula.full_name && fetched_formula.active_spec_sym == formula.active_spec_sym
end
end

sig { void }
def fetch
return if self.class.fetched.include?(formula)
return if previously_fetched_formula

fetch_dependencies

Expand Down

0 comments on commit d7268ae

Please sign in to comment.