Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch: add --bottle-tag flag #11691

Merged
merged 1 commit into from
Jul 13, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions Library/Homebrew/cmd/fetch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def fetch_args
Download a bottle (if available) or source packages for <formula>e
and binaries for <cask>s. For files, also print SHA-256 checksums.
EOS
flag "--bottle-tag",
description: "Download a bottle for given tag."
switch "--HEAD",
description: "Fetch HEAD version instead of stable version."
switch "-f", "--force",
Expand Down Expand Up @@ -47,12 +49,13 @@ def fetch_args
switch "--cask", "--casks",
description: "Treat all named arguments as casks."

conflicts "--build-from-source", "--build-bottle", "--force-bottle"
conflicts "--build-from-source", "--build-bottle", "--force-bottle", "--bottle-tag"
conflicts "--cask", "--HEAD"
conflicts "--cask", "--deps"
conflicts "--cask", "-s"
conflicts "--cask", "--build-bottle"
conflicts "--cask", "--force-bottle"
conflicts "--cask", "--bottle-tag"
conflicts "--formula", "--cask"

named_args [:formula, :cask], min: 1
Expand Down Expand Up @@ -90,7 +93,7 @@ def fetch
begin
f.clear_cache if args.force?
f.fetch_bottle_tab
fetch_formula(f.bottle, args: args)
fetch_formula(f.bottle_for_tag(args.bottle_tag), args: args)
rescue Interrupt
raise
rescue => e
Expand Down
7 changes: 7 additions & 0 deletions Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,13 @@ def bottle
@bottle ||= Bottle.new(self, bottle_specification) if bottled?
end

# The Bottle object for given tag.
# @private
sig { params(tag: T.nilable(String)).returns(T.nilable(Bottle)) }
def bottle_for_tag(tag = nil)
Bottle.new(self, bottle_specification, tag) if bottled?
end

# The description of the software.
# @!method desc
# @see .desc=
Expand Down
9 changes: 7 additions & 2 deletions Library/Homebrew/software_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,19 @@ def extname
def_delegators :resource, :url, :verify_download_integrity
def_delegators :resource, :cached_download

def initialize(formula, spec)
def initialize(formula, spec, tag = nil)
@name = formula.name
@resource = Resource.new
@resource.owner = formula
@resource.specs[:bottle] = true
@spec = spec

checksum, tag, cellar = spec.checksum_for(Utils::Bottles.tag)
bottle_tag = if tag.present?
Utils::Bottles::Tag.from_symbol(tag)
else
Utils::Bottles.tag
end
checksum, tag, cellar = spec.checksum_for(bottle_tag)

@prefix = spec.prefix
@tag = tag
Expand Down