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
18 changes: 15 additions & 3 deletions Library/Homebrew/api/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def self.fetch(name)
Homebrew::API.fetch "formula/#{name}.json"
end

sig { params(formula: ::Formula).returns(::Formula) }
def self.source_download(formula)
sig { params(formula: ::Formula, download_queue: T.nilable(Homebrew::DownloadQueue)).returns(Homebrew::API::SourceDownload) }
def self.source_download(formula, download_queue: nil)
path = formula.ruby_source_path || "Formula/#{formula.name}.rb"
git_head = formula.tap_git_head || "HEAD"
tap = formula.tap&.full_name || "Homebrew/homebrew-core"
Expand All @@ -39,7 +39,19 @@ def self.source_download(formula)
formula.ruby_source_checksum,
cache: HOMEBREW_CACHE_API_SOURCE/"#{tap}/#{git_head}/Formula",
)
download.fetch

if download_queue
download_queue.enqueue(download)
elsif !download.cache.exist?
download.fetch
end

download
end

sig { params(formula: ::Formula).returns(::Formula) }
def self.source_download_formula(formula)
download = source_download(formula)

with_env(HOMEBREW_FORBID_PACKAGES_FROM_PATHS: nil) do
Formulary.factory(download.symlink_location,
Expand Down
10 changes: 7 additions & 3 deletions Library/Homebrew/formula_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,12 @@ def prelude_fetch
end
end

# Needs to be done before expand_dependencies for compute_dependencies
fetch_bottle_tab if pour_bottle?
if pour_bottle?
# Needs to be done before expand_dependencies for compute_dependencies
fetch_bottle_tab
elsif formula.loaded_from_api?
Homebrew::API::Formula.source_download(formula, download_queue:)
end

fetch_fetch_deps unless ignore_deps?

Expand Down Expand Up @@ -1446,7 +1450,7 @@ def fetch

!downloadable_object.cached_download.exist?
else
@formula = Homebrew::API::Formula.source_download(formula) if formula.loaded_from_api?
@formula = Homebrew::API::Formula.source_download_formula(formula) if formula.loaded_from_api?

if (download_queue = self.download_queue)
formula.enqueue_resources_and_patches(download_queue:)
Expand Down