Merge pull request #11691 from dawidd6/fetch-bottle-tag

fetch: add --bottle-tag flag
This commit is contained in:
Dawid Dziurla 2021-07-13 18:51:42 +02:00 committed by GitHub
commit 2a9f962747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 4 deletions

View File

@ -20,6 +20,8 @@ module Homebrew
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",
@ -47,12 +49,13 @@ module Homebrew
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
@ -90,7 +93,7 @@ module Homebrew
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

View File

@ -369,6 +369,13 @@ class Formula
@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=

View File

@ -299,14 +299,19 @@ class Bottle
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