language stringclasses 1
value | owner stringlengths 2 15 | repo stringlengths 2 21 | sha stringlengths 45 45 | message stringlengths 7 36.3k | path stringlengths 1 199 | patch stringlengths 15 102k | is_multipart bool 2
classes |
|---|---|---|---|---|---|---|---|
Other | Homebrew | brew | cee86846ce1115fc4fd85010526104c292280d7f.json | Fix Sorbet violations. | Library/Homebrew/cli/args.rb | @@ -68,7 +68,7 @@ def no_named?
def build_from_source_formulae
if build_from_source? || self[:HEAD?] || self[:build_bottle?]
- named.to_formulae_and_casks.select { |f| f.is_a?(Formula) }.map(&:full_name)
+ named.to_formulae.map(&:full_name)
else
[]
end | true |
Other | Homebrew | brew | cee86846ce1115fc4fd85010526104c292280d7f.json | Fix Sorbet violations. | Library/Homebrew/cmd/home.rb | @@ -36,7 +36,9 @@ def home
return
end
- homepages = args.named.to_formulae_and_casks.map do |formula_or_cask|
+ # to_formulae_and_casks is typed to possibly return Kegs (but won't without explicitly asking)
+ formulae_or_casks = T.cast(args.named.to_formulae_and_casks, T::Array[T.any(Formula, Cask::Cask)])
+ homepages = formulae_or_casks.map do |formula_or_cask|
puts "Opening homepage for #{name_of(formula_or_cask)}"
formula_or_cask.homepage
end | true |
Other | Homebrew | brew | cee86846ce1115fc4fd85010526104c292280d7f.json | Fix Sorbet violations. | Library/Homebrew/sorbet/parlour.rb | @@ -1,25 +1,27 @@
-# frozen_string_literal: true
# typed: true
+# frozen_string_literal: true
require_relative "../warnings"
Warnings.ignore :parser_syntax do
require "parser/current"
end
module Homebrew
+ # Parlour type signature generator helper class for Homebrew.
module Parlour
extend T::Sig
- ROOT_DIR = T.let(Pathname(__dir__).parent.realpath.freeze, Pathname)
+ ROOT_DIR = T.let(Pathname(__dir__).parent.realpath.freeze, Pathname).freeze
sig { returns(T::Array[Parser::AST::Node]) }
def self.ast_list
- @@ast_list ||= begin
+ @ast_list ||= begin
ast_list = []
parser = Parser::CurrentRuby.new
+ prune_dirs = %w[sorbet shims test vendor].freeze
ROOT_DIR.find do |path|
- Find.prune if path.directory? && %w[sorbet shims test vendor].any? { |subdir| path == ROOT_DIR/subdir }
+ Find.prune if path.directory? && prune_dirs.any? { |subdir| path == ROOT_DIR/subdir }
Find.prune if path.file? && path.extname != ".rb"
| true |
Other | Homebrew | brew | cee86846ce1115fc4fd85010526104c292280d7f.json | Fix Sorbet violations. | Library/Homebrew/sorbet/parlour/attr.rb | @@ -1,6 +1,7 @@
-# frozen_string_literal: true
# typed: strict
+# frozen_string_literal: true
+# Parlour type signature generator plugin for Homebrew DSL attributes.
class Attr < Parlour::Plugin
sig { override.params(root: Parlour::RbiGenerator::Namespace).void }
def generate(root)
@@ -13,7 +14,7 @@ def generate(root)
sig { override.returns(T.nilable(String)) }
def strictness
- return "strict"
+ "strict"
end
private
@@ -32,7 +33,7 @@ def extract_module_name(node)
traverse_module_name(node).join("::")
end
-
+
sig { params(node: Parser::AST::Node).returns(T::Array[T.untyped]) }
def find_custom_attr(node)
tree = T.let([], T::Array[T.untyped])
@@ -46,15 +47,16 @@ def find_custom_attr(node)
elsif node.type == :sclass
subtree = find_custom_attr(node.children[1])
return tree if subtree.empty?
-
+
tree << [:sclass, subtree]
elsif node.type == :class || node.type == :module
element = []
- if node.type == :class
+ case node.type
+ when :class
element << :class
element << extract_module_name(children.shift)
element << extract_module_name(children.shift)
- elsif node.type == :module
+ when :module
element << :module
element << extract_module_name(children.shift)
end
@@ -69,7 +71,7 @@ def find_custom_attr(node)
tree << element
elsif node.type == :send && children.shift.nil?
method_name = children.shift
- if method_name == :attr_rw || method_name == :attr_predicate
+ if [:attr_rw, :attr_predicate].include?(method_name)
children.each do |name_node|
tree << [method_name, name_node.children.first.to_s]
end
@@ -96,7 +98,7 @@ def process_custom_attr(tree, namespace, sclass: false)
name = node.shift
name = "self.#{name}" if sclass
namespace.create_method(name, parameters: [
- Parlour::RbiGenerator::Parameter.new("arg", type: "T.untyped", default: "T.unsafe(nil)")
+ Parlour::RbiGenerator::Parameter.new("arg", type: "T.untyped", default: "T.unsafe(nil)"),
], return_type: "T.untyped")
when :attr_predicate
name = node.shift | true |
Other | Homebrew | brew | cee86846ce1115fc4fd85010526104c292280d7f.json | Fix Sorbet violations. | Library/Homebrew/version.rb | @@ -39,6 +39,7 @@ def self.create(val)
when /\A#{PostToken::PATTERN}\z/o then PostToken
when /\A#{NumericToken::PATTERN}\z/o then NumericToken
when /\A#{StringToken::PATTERN}\z/o then StringToken
+ else raise "Cannot find a matching token pattern"
end.new(val)
end
| true |
Other | Homebrew | brew | cee86846ce1115fc4fd85010526104c292280d7f.json | Fix Sorbet violations. | Library/Homebrew/yard/ignore_directives.rbi | @@ -0,0 +1,6 @@
+# typed: strict
+
+module YARD
+ class Docstring; end
+ class DocstringParser; end
+end | true |
Other | Homebrew | brew | f84265f9a200c693525b16260386f9c2b523aa48.json | Remove extra type signatures | Library/Homebrew/extend/os/linux/api/analytics.rb | @@ -5,7 +5,6 @@ module Homebrew
module API
module Analytics
class << self
- sig { returns(String) }
def analytics_api_path
return generic_analytics_api_path if Homebrew::EnvConfig.force_homebrew_on_linux?
| true |
Other | Homebrew | brew | f84265f9a200c693525b16260386f9c2b523aa48.json | Remove extra type signatures | Library/Homebrew/extend/os/linux/api/bottle.rb | @@ -5,7 +5,6 @@ module Homebrew
module API
module Bottle
class << self
- sig { returns(String) }
def bottle_api_path
return generic_bottle_api_path if Homebrew::EnvConfig.force_homebrew_on_linux?
| true |
Other | Homebrew | brew | f84265f9a200c693525b16260386f9c2b523aa48.json | Remove extra type signatures | Library/Homebrew/extend/os/linux/api/formula.rb | @@ -5,7 +5,6 @@ module Homebrew
module API
module Formula
class << self
- sig { returns(String) }
def formula_api_path
return generic_formula_api_path if Homebrew::EnvConfig.force_homebrew_on_linux?
| true |
Other | Homebrew | brew | 2afbd38dde4f371ec4a120aa46f77e7738bce5f2.json | Remove extra comment | Library/Homebrew/api/bottle.rb | @@ -5,7 +5,7 @@
module Homebrew
module API
- # Helper functions for using the Bottle JSON API.
+ # Helper functions for using the bottle JSON API.
#
# @api private
module Bottle | true |
Other | Homebrew | brew | 2afbd38dde4f371ec4a120aa46f77e7738bce5f2.json | Remove extra comment | Library/Homebrew/test/api/bottle_spec.rb | @@ -4,10 +4,6 @@
require "api"
describe Homebrew::API::Bottle do
- # before do
- # ENV["HOMEBREW_JSON_CORE"] = "1"
- # end
-
let(:bottle_json) {
<<~EOS
{ | true |
Other | Homebrew | brew | faeb8942490c16fc99de34b0fc496664a40277da.json | Update RBI files for tapioca. | Library/Homebrew/sorbet/rbi/gems/tapioca@0.4.24.rbi | @@ -1615,7 +1615,7 @@ class Tapioca::RBI::Rewriters::SortNodes < ::Tapioca::RBI::Visitor
private
sig { params(kind: Tapioca::RBI::Group::Kind).returns(Integer) }
- def kind_rank(kind); end
+ def group_rank(kind); end
sig { params(node: Tapioca::RBI::Node).returns(T.nilable(String)) }
def node_name(node); end | false |
Other | Homebrew | brew | 285513fd6517d9d408793d31b02af81f2cc514ad.json | Allow anonymous access in private registries | Library/Homebrew/download_strategy.rb | @@ -568,8 +568,7 @@ class CurlGitHubPackagesDownloadStrategy < CurlDownloadStrategy
def initialize(url, name, version, **meta)
meta ||= {}
meta[:headers] ||= []
- token = Homebrew::EnvConfig.docker_registry_token
- token ||= "QQ=="
+ token = Homebrew::EnvConfig.artifact_domain ? Homebrew::EnvConfig.docker_registry_token : "QQ=="
meta[:headers] << ["Authorization: Bearer #{token}"] if token.present?
super(url, name, version, meta)
end | false |
Other | Homebrew | brew | 1e737dbe2cffc0c19fa8a4a1529d84c16a9cc418.json | cmd/shellenv.sh: apply suggestions from code review | Library/Homebrew/cmd/shellenv.sh | @@ -3,7 +3,7 @@
#: Print export statements. When run in a shell, this installation of Homebrew will be added to your `PATH`, `MANPATH`, and `INFOPATH`.
#:
#: The variables `HOMEBREW_PREFIX`, `HOMEBREW_CELLAR` and `HOMEBREW_REPOSITORY` are also exported to avoid querying them multiple times.
-#: The variables and `HOMEBREW_SHELLENV_PREFIX` and `HOMEBREW_SHELLENV_SET` will be exported to avoid adding duplicate entries to the environment variables.
+#: The variable `HOMEBREW_SHELLENV_PREFIX` will be exported to avoid adding duplicate entries to the environment variables.
#: Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.profile`, `~/.bash_profile`, or `~/.zprofile`) with: `eval $(brew shellenv)`
# HOMEBREW_CELLAR and HOMEBREW_PREFIX are set by extend/ENV/super.rb
@@ -19,32 +19,26 @@ homebrew-shellenv() {
echo "set -gx HOMEBREW_REPOSITORY \"${HOMEBREW_REPOSITORY}\";"
echo "set -gx HOMEBREW_SHELLENV_PREFIX \"${HOMEBREW_PREFIX}\";"
echo "set -q PATH; or set PATH ''; set -gx PATH \"${HOMEBREW_PREFIX}/bin\" \"${HOMEBREW_PREFIX}/sbin\" \$PATH;"
- [[ ":${HOMEBREW_SHELLENV_SET}:" == *":${HOMEBREW_PREFIX}:"* ]] && return
echo "set -q MANPATH; or set MANPATH ''; set -gx MANPATH \"${HOMEBREW_PREFIX}/share/man\" \$MANPATH;"
echo "set -q INFOPATH; or set INFOPATH ''; set -gx INFOPATH \"${HOMEBREW_PREFIX}/share/info\" \$INFOPATH;"
- echo "set -q HOMEBREW_SHELLENV_SET; or set HOMEBREW_SHELLENV_SET ''; set -gx HOMEBREW_SHELLENV_SET \"${HOMEBREW_PREFIX}\" \$HOMEBREW_SHELLENV_SET;"
;;
csh | -csh | tcsh | -tcsh)
echo "setenv HOMEBREW_PREFIX ${HOMEBREW_PREFIX};"
echo "setenv HOMEBREW_CELLAR ${HOMEBREW_CELLAR};"
echo "setenv HOMEBREW_REPOSITORY ${HOMEBREW_REPOSITORY};"
echo "setenv HOMEBREW_SHELLENV_PREFIX ${HOMEBREW_PREFIX};"
echo "setenv PATH ${HOMEBREW_PREFIX}/bin:${HOMEBREW_PREFIX}/sbin:\$PATH;"
- [[ ":${HOMEBREW_SHELLENV_SET}:" == *":${HOMEBREW_PREFIX}:"* ]] && return
echo "setenv MANPATH ${HOMEBREW_PREFIX}/share/man\`[ \${?MANPATH} == 1 ] && echo \":\${MANPATH}\"\`:;"
echo "setenv INFOPATH ${HOMEBREW_PREFIX}/share/info\`[ \${?INFOPATH} == 1 ] && echo \":\${INFOPATH}\"\`;"
- echo "setenv HOMEBREW_SHELLENV_SET ${HOMEBREW_PREFIX}\`[ \${?HOMEBREW_SHELLENV_SET} == 1 ] && echo \":\${HOMEBREW_SHELLENV_SET}\"\`;"
;;
*)
echo "export HOMEBREW_PREFIX=\"${HOMEBREW_PREFIX}\";"
echo "export HOMEBREW_CELLAR=\"${HOMEBREW_CELLAR}\";"
echo "export HOMEBREW_REPOSITORY=\"${HOMEBREW_REPOSITORY}\";"
echo "export HOMEBREW_SHELLENV_PREFIX=\"${HOMEBREW_PREFIX}\";"
echo "export PATH=\"${HOMEBREW_PREFIX}/bin:${HOMEBREW_PREFIX}/sbin\${PATH+:\$PATH}\";"
- [[ ":${HOMEBREW_SHELLENV_SET}:" == *":${HOMEBREW_PREFIX}:"* ]] && return
echo "export MANPATH=\"${HOMEBREW_PREFIX}/share/man\${MANPATH+:\$MANPATH}:\";"
echo "export INFOPATH=\"${HOMEBREW_PREFIX}/share/info:\${INFOPATH:-}\";"
- echo "export HOMEBREW_SHELLENV_SET=\"${HOMEBREW_PREFIX}\${HOMEBREW_SHELLENV_SET+:\$HOMEBREW_SHELLENV_SET}\";"
;;
esac
} | true |
Other | Homebrew | brew | 1e737dbe2cffc0c19fa8a4a1529d84c16a9cc418.json | cmd/shellenv.sh: apply suggestions from code review | Library/Homebrew/env_config.rb | @@ -305,14 +305,6 @@ module EnvConfig
"useful to avoid long-running Homebrew commands being killed due to no output.",
boolean: true,
},
- HOMEBREW_SHELLENV_PREFIX: {
- description: "The lastest Homebrew prefix initialized by `brew shellenv`. If it is equal to " \
- "the current Homebrew prefix, `brew shellenv` will skip all export statements.",
- },
- HOMEBREW_SHELLENV_SET: {
- description: "A colon separated list of Homebrew prefixes. If it is set and contains the current " \
- "Homebrew prefix, `brew shellenv` will skip export statements for paths.",
- },
all_proxy: {
description: "Use this SOCKS5 proxy for `curl`(1), `git`(1) and `svn`(1) when downloading through Homebrew.",
}, | true |
Other | Homebrew | brew | 1e737dbe2cffc0c19fa8a4a1529d84c16a9cc418.json | cmd/shellenv.sh: apply suggestions from code review | docs/Manpage.md | @@ -565,7 +565,7 @@ The search for *`text`* is extended online to `homebrew/core` and `homebrew/cask
Print export statements. When run in a shell, this installation of Homebrew will be added to your `PATH`, `MANPATH`, and `INFOPATH`.
The variables `HOMEBREW_PREFIX`, `HOMEBREW_CELLAR` and `HOMEBREW_REPOSITORY` are also exported to avoid querying them multiple times.
-The variables and `HOMEBREW_SHELLENV_PREFIX` and `HOMEBREW_SHELLENV_SET` will be exported to avoid adding duplicate entries to the environment variables.
+The variable `HOMEBREW_SHELLENV_PREFIX` will be exported to avoid adding duplicate entries to the environment variables.
Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.profile`, `~/.bash_profile`, or `~/.zprofile`) with: `eval $(brew shellenv)`
### `tap` [*`options`*] [*`user`*`/`*`repo`*] [*`URL`*]
@@ -2088,12 +2088,6 @@ example, run `export HOMEBREW_NO_INSECURE_REDIRECT=1` rather than just
- `HOMEBREW_VERBOSE_USING_DOTS`
<br>If set, verbose output will print a `.` no more than once a minute. This can be useful to avoid long-running Homebrew commands being killed due to no output.
-- `HOMEBREW_SHELLENV_PREFIX`
- <br>The lastest Homebrew prefix initialized by `brew shellenv`. If it is equal to the current Homebrew prefix, `brew shellenv` will skip all export statements.
-
-- `HOMEBREW_SHELLENV_SET`
- <br>A colon separated list of Homebrew prefixes. If it is set and contains the current Homebrew prefix, `brew shellenv` will skip export statements for paths.
-
- `all_proxy`
<br>Use this SOCKS5 proxy for `curl`(1), `git`(1) and `svn`(1) when downloading through Homebrew.
| true |
Other | Homebrew | brew | 1e737dbe2cffc0c19fa8a4a1529d84c16a9cc418.json | cmd/shellenv.sh: apply suggestions from code review | manpages/brew.1 | @@ -784,7 +784,7 @@ Search for \fItext\fR in the given database\.
Print export statements\. When run in a shell, this installation of Homebrew will be added to your \fBPATH\fR, \fBMANPATH\fR, and \fBINFOPATH\fR\.
.
.P
-The variables \fBHOMEBREW_PREFIX\fR, \fBHOMEBREW_CELLAR\fR and \fBHOMEBREW_REPOSITORY\fR are also exported to avoid querying them multiple times\. The variables and \fBHOMEBREW_SHELLENV_PREFIX\fR and \fBHOMEBREW_SHELLENV_SET\fR will be exported to avoid adding duplicate entries to the environment variables\. Consider adding evaluation of this command\'s output to your dotfiles (e\.g\. \fB~/\.profile\fR, \fB~/\.bash_profile\fR, or \fB~/\.zprofile\fR) with: \fBeval $(brew shellenv)\fR
+The variables \fBHOMEBREW_PREFIX\fR, \fBHOMEBREW_CELLAR\fR and \fBHOMEBREW_REPOSITORY\fR are also exported to avoid querying them multiple times\. The variable \fBHOMEBREW_SHELLENV_PREFIX\fR will be exported to avoid adding duplicate entries to the environment variables\. Consider adding evaluation of this command\'s output to your dotfiles (e\.g\. \fB~/\.profile\fR, \fB~/\.bash_profile\fR, or \fB~/\.zprofile\fR) with: \fBeval $(brew shellenv)\fR
.
.SS "\fBtap\fR [\fIoptions\fR] [\fIuser\fR\fB/\fR\fIrepo\fR] [\fIURL\fR]"
Tap a formula repository\.
@@ -3040,18 +3040,6 @@ If set, always assume \fB\-\-debug\fR when running commands\.
If set, verbose output will print a \fB\.\fR no more than once a minute\. This can be useful to avoid long\-running Homebrew commands being killed due to no output\.
.
.TP
-\fBHOMEBREW_SHELLENV_PREFIX\fR
-.
-.br
-The lastest Homebrew prefix initialized by \fBbrew shellenv\fR\. If it is equal to the current Homebrew prefix, \fBbrew shellenv\fR will skip all export statements\.
-.
-.TP
-\fBHOMEBREW_SHELLENV_SET\fR
-.
-.br
-A colon separated list of Homebrew prefixes\. If it is set and contains the current Homebrew prefix, \fBbrew shellenv\fR will skip export statements for paths\.
-.
-.TP
\fBall_proxy\fR
.
.br | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/livecheck/strategy/apache.rb | @@ -52,7 +52,9 @@ def self.match?(url)
url: String,
regex: T.nilable(Regexp),
cask: T.nilable(Cask::Cask),
- block: T.nilable(T.proc.params(arg0: String).returns(T.any(T::Array[String], String))),
+ block: T.nilable(
+ T.proc.params(arg0: String, arg1: Regexp).returns(T.any(String, T::Array[String], NilClass)),
+ ),
).returns(T::Hash[Symbol, T.untyped])
}
def self.find_versions(url, regex, cask: nil, &block) | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/livecheck/strategy/bitbucket.rb | @@ -59,7 +59,9 @@ def self.match?(url)
url: String,
regex: T.nilable(Regexp),
cask: T.nilable(Cask::Cask),
- block: T.nilable(T.proc.params(arg0: String).returns(T.any(T::Array[String], String))),
+ block: T.nilable(
+ T.proc.params(arg0: String, arg1: Regexp).returns(T.any(String, T::Array[String], NilClass)),
+ ),
).returns(T::Hash[Symbol, T.untyped])
}
def self.find_versions(url, regex, cask: nil, &block) | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/livecheck/strategy/cpan.rb | @@ -50,7 +50,9 @@ def self.match?(url)
url: String,
regex: T.nilable(Regexp),
cask: T.nilable(Cask::Cask),
- block: T.nilable(T.proc.params(arg0: String).returns(T.any(T::Array[String], String))),
+ block: T.nilable(
+ T.proc.params(arg0: String, arg1: Regexp).returns(T.any(String, T::Array[String], NilClass)),
+ ),
).returns(T::Hash[Symbol, T.untyped])
}
def self.find_versions(url, regex, cask: nil, &block) | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/livecheck/strategy/electron_builder.rb | @@ -37,19 +37,24 @@ def self.match?(url)
sig {
params(
content: String,
- block: T.nilable(T.proc.params(arg0: Hash).returns(String)),
+ block: T.nilable(T.proc.params(arg0: T::Hash[String, T.untyped]).returns(T.nilable(String))),
).returns(T.nilable(String))
}
def self.version_from_content(content, &block)
require "yaml"
- return unless (yaml = YAML.safe_load(content))
+ yaml = YAML.safe_load(content)
+ return if yaml.blank?
if block
- value = block.call(yaml)
- return value if value.is_a?(String)
-
- raise TypeError, "Return value of `strategy :electron_builder` block must be a string."
+ case (value = block.call(yaml))
+ when String
+ return value
+ when nil
+ return
+ else
+ raise TypeError, "Return value of `strategy :electron_builder` block must be a string."
+ end
end
yaml["version"]
@@ -65,7 +70,7 @@ def self.version_from_content(content, &block)
url: String,
regex: T.nilable(Regexp),
cask: T.nilable(Cask::Cask),
- block: T.nilable(T.proc.params(arg0: Hash).returns(String)),
+ block: T.nilable(T.proc.params(arg0: T::Hash[String, T.untyped]).returns(T.nilable(String))),
).returns(T::Hash[Symbol, T.untyped])
}
def self.find_versions(url, regex, cask: nil, &block) | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/livecheck/strategy/extract_plist.rb | @@ -56,7 +56,7 @@ def self.match?(url)
url: String,
regex: T.nilable(Regexp),
cask: Cask::Cask,
- block: T.nilable(T.proc.params(arg0: T::Hash[String, Item]).returns(String)),
+ block: T.nilable(T.proc.params(arg0: T::Hash[String, Item]).returns(T.nilable(String))),
).returns(T::Hash[Symbol, T.untyped])
}
def self.find_versions(url, regex, cask:, &block)
@@ -69,13 +69,14 @@ def self.find_versions(url, regex, cask:, &block)
versions = unversioned_cask_checker.all_versions.transform_values { |v| Item.new(bundle_version: v) }
if block
- match = block.call(versions)
-
- unless T.unsafe(match).is_a?(String)
+ case (value = block.call(versions))
+ when String
+ match_data[:matches][value] = Version.new(value)
+ when nil
+ return match_data
+ else
raise TypeError, "Return value of `strategy :extract_plist` block must be a string."
end
-
- match_data[:matches][match] = Version.new(match) if match
elsif versions.any?
versions.each_value do |item|
version = item.bundle_version.nice_version | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/livecheck/strategy/git.rb | @@ -81,8 +81,9 @@ def self.match?(url)
url: String,
regex: T.nilable(Regexp),
cask: T.nilable(Cask::Cask),
- block: T.nilable(T.proc.params(arg0: T::Array[String])
- .returns(T.any(T::Array[String], String))),
+ block: T.nilable(
+ T.proc.params(arg0: T::Array[String]).returns(T.any(String, T::Array[String], NilClass)),
+ ),
).returns(T::Hash[Symbol, T.untyped])
}
def self.find_versions(url, regex, cask: nil, &block)
@@ -105,6 +106,8 @@ def self.find_versions(url, regex, cask: nil, &block)
value.each do |tag|
match_data[:matches][tag] = Version.new(tag)
end
+ when nil
+ return match_data
else
raise TypeError, "Return value of `strategy :git` block must be a string or array of strings."
end | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/livecheck/strategy/github_latest.rb | @@ -67,7 +67,9 @@ def self.match?(url)
url: String,
regex: T.nilable(Regexp),
cask: T.nilable(Cask::Cask),
- block: T.nilable(T.proc.params(arg0: String).returns(T.any(T::Array[String], String))),
+ block: T.nilable(
+ T.proc.params(arg0: String, arg1: Regexp).returns(T.any(String, T::Array[String], NilClass)),
+ ),
).returns(T::Hash[Symbol, T.untyped])
}
def self.find_versions(url, regex, cask: nil, &block) | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/livecheck/strategy/gnome.rb | @@ -55,7 +55,9 @@ def self.match?(url)
url: String,
regex: T.nilable(Regexp),
cask: T.nilable(Cask::Cask),
- block: T.nilable(T.proc.params(arg0: String).returns(T.any(T::Array[String], String))),
+ block: T.nilable(
+ T.proc.params(arg0: String, arg1: Regexp).returns(T.any(String, T::Array[String], NilClass)),
+ ),
).returns(T::Hash[Symbol, T.untyped])
}
def self.find_versions(url, regex, cask: nil, &block) | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/livecheck/strategy/gnu.rb | @@ -59,7 +59,9 @@ def self.match?(url)
url: String,
regex: T.nilable(Regexp),
cask: T.nilable(Cask::Cask),
- block: T.nilable(T.proc.params(arg0: String).returns(T.any(T::Array[String], String))),
+ block: T.nilable(
+ T.proc.params(arg0: String, arg1: Regexp).returns(T.any(String, T::Array[String], NilClass)),
+ ),
).returns(T::Hash[Symbol, T.untyped])
}
def self.find_versions(url, regex, cask: nil, &block) | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/livecheck/strategy/hackage.rb | @@ -52,7 +52,9 @@ def self.match?(url)
url: String,
regex: T.nilable(Regexp),
cask: T.nilable(Cask::Cask),
- block: T.nilable(T.proc.params(arg0: String).returns(T.any(T::Array[String], String))),
+ block: T.nilable(
+ T.proc.params(arg0: String, arg1: Regexp).returns(T.any(String, T::Array[String], NilClass)),
+ ),
).returns(T::Hash[Symbol, T.untyped])
}
def self.find_versions(url, regex, cask: nil, &block) | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/livecheck/strategy/header_match.rb | @@ -40,8 +40,7 @@ def self.match?(url)
url: String,
regex: T.nilable(Regexp),
cask: T.nilable(Cask::Cask),
- block: T.nilable(T.proc.params(arg0: T::Hash[String, String])
- .returns(T.any(T::Array[String], String))),
+ block: T.nilable(T.proc.params(arg0: T::Hash[String, String]).returns(T.nilable(String))),
).returns(T::Hash[Symbol, T.untyped])
}
def self.find_versions(url, regex, cask: nil, &block)
@@ -52,31 +51,40 @@ def self.find_versions(url, regex, cask: nil, &block)
# Merge the headers from all responses into one hash
merged_headers = headers.reduce(&:merge)
- if block
- match = yield merged_headers, regex
+ version = if block
+ case (value = block.call(merged_headers, regex))
+ when String
+ value
+ when nil
+ return match_data
+ else
+ raise TypeError, "Return value of `strategy :header_match` block must be a string."
+ end
else
- match = nil
+ value = nil
if (filename = merged_headers["content-disposition"])
if regex
- match ||= filename[regex, 1]
+ value ||= filename[regex, 1]
else
v = Version.parse(filename, detected_from_url: true)
- match ||= v.to_s unless v.null?
+ value ||= v.to_s unless v.null?
end
end
if (location = merged_headers["location"])
if regex
- match ||= location[regex, 1]
+ value ||= location[regex, 1]
else
v = Version.parse(location, detected_from_url: true)
- match ||= v.to_s unless v.null?
+ value ||= v.to_s unless v.null?
end
end
+
+ value
end
- match_data[:matches][match] = Version.new(match) if match
+ match_data[:matches][version] = Version.new(version) if version
match_data
end | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/livecheck/strategy/launchpad.rb | @@ -50,7 +50,9 @@ def self.match?(url)
url: String,
regex: T.nilable(Regexp),
cask: T.nilable(Cask::Cask),
- block: T.nilable(T.proc.params(arg0: String).returns(T.any(T::Array[String], String))),
+ block: T.nilable(
+ T.proc.params(arg0: String, arg1: Regexp).returns(T.any(String, T::Array[String], NilClass)),
+ ),
).returns(T::Hash[Symbol, T.untyped])
}
def self.find_versions(url, regex, cask: nil, &block) | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/livecheck/strategy/npm.rb | @@ -46,7 +46,9 @@ def self.match?(url)
url: String,
regex: T.nilable(Regexp),
cask: T.nilable(Cask::Cask),
- block: T.nilable(T.proc.params(arg0: String).returns(T.any(T::Array[String], String))),
+ block: T.nilable(
+ T.proc.params(arg0: String, arg1: Regexp).returns(T.any(String, T::Array[String], NilClass)),
+ ),
).returns(T::Hash[Symbol, T.untyped])
}
def self.find_versions(url, regex, cask: nil, &block) | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/livecheck/strategy/page_match.rb | @@ -45,13 +45,24 @@ def self.match?(url)
# @param regex [Regexp] a regex used for matching versions in the
# content
# @return [Array]
+ sig {
+ params(
+ content: String,
+ regex: Regexp,
+ block: T.nilable(
+ T.proc.params(arg0: String, arg1: Regexp).returns(T.any(String, T::Array[String], NilClass)),
+ ),
+ ).returns(T::Array[String])
+ }
def self.page_matches(content, regex, &block)
if block
case (value = block.call(content, regex))
when String
return [value]
when Array
- return value
+ return value.compact.uniq
+ when nil
+ return []
else
raise TypeError, "Return value of `strategy :page_match` block must be a string or array of strings."
end
@@ -61,10 +72,10 @@ def self.page_matches(content, regex, &block)
case match
when String
match
- else
+ when Array
match.first
end
- end.uniq
+ end.compact.uniq
end
# Checks the content at the URL for new versions, using the provided
@@ -78,10 +89,12 @@ def self.page_matches(content, regex, &block)
sig {
params(
url: String,
- regex: T.nilable(Regexp),
+ regex: Regexp,
cask: T.nilable(Cask::Cask),
provided_content: T.nilable(String),
- block: T.nilable(T.proc.params(arg0: String).returns(T.any(T::Array[String], String))),
+ block: T.nilable(
+ T.proc.params(arg0: String, arg1: Regexp).returns(T.any(String, T::Array[String], NilClass)),
+ ),
).returns(T::Hash[Symbol, T.untyped])
}
def self.find_versions(url, regex, cask: nil, provided_content: nil, &block) | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/livecheck/strategy/pypi.rb | @@ -56,7 +56,9 @@ def self.match?(url)
url: String,
regex: T.nilable(Regexp),
cask: T.nilable(Cask::Cask),
- block: T.nilable(T.proc.params(arg0: String).returns(T.any(T::Array[String], String))),
+ block: T.nilable(
+ T.proc.params(arg0: String, arg1: Regexp).returns(T.any(String, T::Array[String], NilClass)),
+ ),
).returns(T::Hash[Symbol, T.untyped])
}
def self.find_versions(url, regex, cask: nil, &block) | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/livecheck/strategy/sourceforge.rb | @@ -62,7 +62,9 @@ def self.match?(url)
url: String,
regex: T.nilable(Regexp),
cask: T.nilable(Cask::Cask),
- block: T.nilable(T.proc.params(arg0: String).returns(T.any(T::Array[String], String))),
+ block: T.nilable(
+ T.proc.params(arg0: String, arg1: Regexp).returns(T.any(String, T::Array[String], NilClass)),
+ ),
).returns(T::Hash[Symbol, T.untyped])
}
def self.find_versions(url, regex, cask: nil, &block) | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/livecheck/strategy/sparkle.rb | @@ -144,7 +144,7 @@ def self.item_from_content(content)
url: String,
regex: T.nilable(Regexp),
cask: T.nilable(Cask::Cask),
- block: T.nilable(T.proc.params(arg0: Item).returns(String)),
+ block: T.nilable(T.proc.params(arg0: Item).returns(T.nilable(String))),
).returns(T::Hash[Symbol, T.untyped])
}
def self.find_versions(url, regex, cask: nil, &block)
@@ -156,19 +156,20 @@ def self.find_versions(url, regex, cask: nil, &block)
content = match_data.delete(:content)
if (item = item_from_content(content))
- match = if block
- value = block.call(item)
-
- unless T.unsafe(value).is_a?(String)
+ version = if block
+ case (value = block.call(item))
+ when String
+ value
+ when nil
+ return match_data
+ else
raise TypeError, "Return value of `strategy :sparkle` block must be a string."
end
-
- value
else
item.bundle_version&.nice_version
end
- match_data[:matches][match] = Version.new(match) if match
+ match_data[:matches][version] = Version.new(version) if version
end
match_data | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/livecheck/strategy/xorg.rb | @@ -85,7 +85,9 @@ def self.match?(url)
url: String,
regex: T.nilable(Regexp),
cask: T.nilable(Cask::Cask),
- block: T.nilable(T.proc.params(arg0: String).returns(T.any(T::Array[String], String))),
+ block: T.nilable(
+ T.proc.params(arg0: String, arg1: Regexp).returns(T.any(String, T::Array[String], NilClass)),
+ ),
).returns(T::Hash[Symbol, T.untyped])
}
def self.find_versions(url, regex, cask: nil, &block) | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/test/livecheck/strategy/electron_builder_spec.rb | @@ -54,5 +54,14 @@
expect(version).to eq "1.2.4"
end
+
+ it "allows a nil return from a strategy block" do
+ expect(electron_builder.version_from_content(electron_builder_yaml) { next }).to eq(nil)
+ end
+
+ it "errors on an invalid return type from a strategy block" do
+ expect { electron_builder.version_from_content(electron_builder_yaml) { 123 } }
+ .to raise_error(TypeError, "Return value of `strategy :electron_builder` block must be a string.")
+ end
end
end | true |
Other | Homebrew | brew | a970780851dc048be35323b4798406b82528609e.json | livecheck: allow nil return from strategy blocks | Library/Homebrew/test/livecheck/strategy/page_match_spec.rb | @@ -72,9 +72,13 @@
end
it "finds matching text in page content using a strategy block" do
- expect(page_match.page_matches(page_content, regex) { |content| content.scan(regex).map(&:first).uniq })
+ expect(page_match.page_matches(page_content, regex) { |content, regex| content.scan(regex).map(&:first).uniq })
.to eq(page_content_matches)
end
+
+ it "allows a nil return from a strategy block" do
+ expect(page_match.page_matches(page_content, regex) { next }).to eq([])
+ end
end
describe "::find_versions?" do | true |
Other | Homebrew | brew | 0bc3d6cf4b8134120be2d1aff2af86eaf0f3aaf8.json | docs: add livecheck formula/cask reference example | docs/Brew-Livecheck.md | @@ -96,6 +96,18 @@ end
If tags include the software name as a prefix (e.g. `example-1.2.3`), it's easy to modify the regex accordingly: `/^example[._-]v?(\d+(?:\.\d+)+)$/i`
+### Referenced formula/cask
+
+A formula/cask can use the same check as another by using `formula` or `cask`.
+
+```ruby
+livecheck do
+ formula "another-formula"
+end
+```
+
+The referenced formula/cask should be in the same tap, as a reference to a formula/cask from another tap will generate an error if the user doesn't already have it tapped.
+
### `strategy` blocks
If the upstream version format needs to be manipulated to match the formula/cask format, a `strategy` block can be used instead of a `regex`. | false |
Other | Homebrew | brew | ddde0f7589b9c04f53869cf39f4c5e01f772b3d7.json | livecheck: allow inheriting from a formula/cask | Library/Homebrew/livecheck.rb | @@ -18,13 +18,51 @@ class Livecheck
def initialize(formula_or_cask)
@formula_or_cask = formula_or_cask
+ @referenced_cask_name = nil
+ @referenced_formula_name = nil
@regex = nil
@skip = false
@skip_msg = nil
@strategy = nil
@url = nil
end
+ # Sets the `@referenced_cask_name` instance variable to the provided `String`
+ # or returns the `@referenced_cask_name` instance variable when no argument
+ # is provided. Inherited livecheck values from the referenced cask
+ # (e.g. regex) can be overridden in the livecheck block.
+ #
+ # @param cask_name [String] name of cask to inherit livecheck info from
+ # @return [String, nil]
+ def cask(cask_name = nil)
+ case cask_name
+ when nil
+ @referenced_cask_name
+ when String
+ @referenced_cask_name = cask_name
+ else
+ raise TypeError, "Livecheck#cask expects a String"
+ end
+ end
+
+ # Sets the `@referenced_formula_name` instance variable to the provided
+ # `String` or returns the `@referenced_formula_name` instance variable when
+ # no argument is provided. Inherited livecheck values from the referenced
+ # formula (e.g. regex) can be overridden in the livecheck block.
+ #
+ # @param formula_name [String] name of formula to inherit livecheck info from
+ # @return [String, nil]
+ def formula(formula_name = nil)
+ case formula_name
+ when nil
+ @referenced_formula_name
+ when String
+ @referenced_formula_name = formula_name
+ else
+ raise TypeError, "Livecheck#formula expects a String"
+ end
+ end
+
# Sets the `@regex` instance variable to the provided `Regexp` or returns the
# `@regex` instance variable when no argument is provided.
#
@@ -109,6 +147,8 @@ def url(val = nil)
# @return [Hash]
def to_hash
{
+ "cask" => @referenced_cask_name,
+ "formula" => @referenced_formula_name,
"regex" => @regex,
"skip" => @skip,
"skip_msg" => @skip_msg, | true |
Other | Homebrew | brew | ddde0f7589b9c04f53869cf39f4c5e01f772b3d7.json | livecheck: allow inheriting from a formula/cask | Library/Homebrew/livecheck/livecheck.rb | @@ -9,6 +9,8 @@
require "uri"
module Homebrew
+ # rubocop:disable Metrics/ModuleLength
+
# The {Livecheck} module consists of methods used by the `brew livecheck`
# command. These methods print the requested livecheck information
# for formulae.
@@ -82,6 +84,74 @@ def load_other_tap_strategies(formulae_and_casks_to_check)
end
end
+ # Resolve formula/cask references in `livecheck` blocks to a final formula
+ # or cask.
+ sig {
+ params(
+ formula_or_cask: T.any(Formula, Cask::Cask),
+ first_formula_or_cask: T.any(Formula, Cask::Cask),
+ references: T::Array[T.any(Formula, Cask::Cask)],
+ full_name: T::Boolean,
+ debug: T::Boolean,
+ ).returns(T.nilable(T::Array[T.untyped]))
+ }
+ def resolve_livecheck_reference(
+ formula_or_cask,
+ first_formula_or_cask = formula_or_cask,
+ references = [],
+ full_name: false,
+ debug: false
+ )
+ # Check the livecheck block for a formula or cask reference
+ livecheck = formula_or_cask.livecheck
+ livecheck_formula = livecheck.formula
+ livecheck_cask = livecheck.cask
+ return [nil, references] if livecheck_formula.blank? && livecheck_cask.blank?
+
+ # Load the referenced formula or cask
+ referenced_formula_or_cask = if livecheck_formula
+ Formulary.factory(livecheck_formula)
+ elsif livecheck_cask
+ Cask::CaskLoader.load(livecheck_cask)
+ end
+
+ # Error if a `livecheck` block references a formula/cask that was already
+ # referenced (or itself)
+ if referenced_formula_or_cask == first_formula_or_cask ||
+ referenced_formula_or_cask == formula_or_cask ||
+ references.include?(referenced_formula_or_cask)
+ if debug
+ # Print the chain of references for debugging
+ puts "Reference Chain:"
+ puts formula_or_cask_name(first_formula_or_cask, full_name: full_name)
+
+ references << referenced_formula_or_cask
+ references.each do |ref_formula_or_cask|
+ puts formula_or_cask_name(ref_formula_or_cask, full_name: full_name)
+ end
+ end
+
+ raise "Circular formula/cask reference encountered"
+ end
+ references << referenced_formula_or_cask
+
+ # Check the referenced formula/cask for a reference
+ next_referenced_formula_or_cask, next_references = resolve_livecheck_reference(
+ referenced_formula_or_cask,
+ first_formula_or_cask,
+ references,
+ full_name: full_name,
+ debug: debug,
+ )
+
+ # Returning references along with the final referenced formula/cask
+ # allows us to print the chain of references in the debug output
+ [
+ next_referenced_formula_or_cask || referenced_formula_or_cask,
+ next_references,
+ ]
+ end
+
# Executes the livecheck logic for each formula/cask in the
# `formulae_and_casks_to_check` array and prints the results.
sig {
@@ -139,13 +209,17 @@ def run_checks(
)
end
+ # rubocop:disable Metrics/BlockLength
formulae_checked = formulae_and_casks_to_check.map.with_index do |formula_or_cask, i|
formula = formula_or_cask if formula_or_cask.is_a?(Formula)
cask = formula_or_cask if formula_or_cask.is_a?(Cask::Cask)
use_full_name = full_name || ambiguous_names.include?(formula_or_cask)
name = formula_or_cask_name(formula_or_cask, full_name: use_full_name)
+ referenced_formula_or_cask, livecheck_references =
+ resolve_livecheck_reference(formula_or_cask, full_name: use_full_name, debug: debug)
+
if debug && i.positive?
puts <<~EOS
@@ -156,7 +230,17 @@ def run_checks(
puts
end
- skip_info = SkipConditions.skip_information(formula_or_cask, full_name: use_full_name, verbose: verbose)
+ # Check skip conditions for a referenced formula/cask
+ if referenced_formula_or_cask
+ skip_info = SkipConditions.referenced_skip_information(
+ referenced_formula_or_cask,
+ name,
+ full_name: use_full_name,
+ verbose: verbose,
+ )
+ end
+
+ skip_info ||= SkipConditions.skip_information(formula_or_cask, full_name: use_full_name, verbose: verbose)
if skip_info.present?
next skip_info if json
@@ -188,7 +272,9 @@ def run_checks(
else
version_info = latest_version(
formula_or_cask,
- json: json, full_name: use_full_name, verbose: verbose, debug: debug,
+ referenced_formula_or_cask: referenced_formula_or_cask,
+ livecheck_references: livecheck_references,
+ json: json, full_name: use_full_name, verbose: verbose, debug: debug
)
version_info[:latest] if version_info.present?
end
@@ -262,6 +348,7 @@ def run_checks(
nil
end
end
+ # rubocop:enable Metrics/BlockLength
puts "No newer upstream versions." if newer_only && !has_a_newer_upstream_version && !debug && !json
@@ -444,27 +531,40 @@ def preprocess_url(url)
# the version information. Returns nil if a latest version couldn't be found.
sig {
params(
- formula_or_cask: T.any(Formula, Cask::Cask),
- json: T::Boolean,
- full_name: T::Boolean,
- verbose: T::Boolean,
- debug: T::Boolean,
+ formula_or_cask: T.any(Formula, Cask::Cask),
+ referenced_formula_or_cask: T.nilable(T.any(Formula, Cask::Cask)),
+ livecheck_references: T::Array[T.any(Formula, Cask::Cask)],
+ json: T::Boolean,
+ full_name: T::Boolean,
+ verbose: T::Boolean,
+ debug: T::Boolean,
).returns(T.nilable(Hash))
}
- def latest_version(formula_or_cask, json: false, full_name: false, verbose: false, debug: false)
+ def latest_version(
+ formula_or_cask,
+ referenced_formula_or_cask: nil,
+ livecheck_references: [],
+ json: false, full_name: false, verbose: false, debug: false
+ )
formula = formula_or_cask if formula_or_cask.is_a?(Formula)
cask = formula_or_cask if formula_or_cask.is_a?(Cask::Cask)
has_livecheckable = formula_or_cask.livecheckable?
livecheck = formula_or_cask.livecheck
- livecheck_url = livecheck.url
- livecheck_regex = livecheck.regex
- livecheck_strategy = livecheck.strategy
+ referenced_livecheck = referenced_formula_or_cask&.livecheck
- livecheck_url_string = livecheck_url_to_string(livecheck_url, formula_or_cask)
+ livecheck_url = livecheck.url || referenced_livecheck&.url
+ livecheck_regex = livecheck.regex || referenced_livecheck&.regex
+ livecheck_strategy = livecheck.strategy || referenced_livecheck&.strategy
+ livecheck_strategy_block = livecheck.strategy_block || referenced_livecheck&.strategy_block
+
+ livecheck_url_string = livecheck_url_to_string(
+ livecheck_url,
+ referenced_formula_or_cask || formula_or_cask,
+ )
urls = [livecheck_url_string] if livecheck_url_string
- urls ||= checkable_urls(formula_or_cask)
+ urls ||= checkable_urls(referenced_formula_or_cask || formula_or_cask)
if debug
if formula
@@ -474,8 +574,18 @@ def latest_version(formula_or_cask, json: false, full_name: false, verbose: fals
puts "Cask: #{cask_name(formula_or_cask, full_name: full_name)}"
end
puts "Livecheckable?: #{has_livecheckable ? "Yes" : "No"}"
+
+ livecheck_references.each do |ref_formula_or_cask|
+ case ref_formula_or_cask
+ when Formula
+ puts "Formula Ref: #{formula_name(ref_formula_or_cask, full_name: full_name)}"
+ when Cask::Cask
+ puts "Cask Ref: #{cask_name(ref_formula_or_cask, full_name: full_name)}"
+ end
+ end
end
+ # rubocop:disable Metrics/BlockLength
urls.each_with_index do |original_url, i|
if debug
puts
@@ -499,7 +609,7 @@ def latest_version(formula_or_cask, json: false, full_name: false, verbose: fals
livecheck_strategy: livecheck_strategy,
url_provided: livecheck_url.present?,
regex_provided: livecheck_regex.present?,
- block_provided: livecheck.strategy_block.present?,
+ block_provided: livecheck_strategy_block.present?,
)
strategy = Strategy.from_symbol(livecheck_strategy) || strategies.first
strategy_name = livecheck_strategy_names[strategy]
@@ -514,7 +624,7 @@ def latest_version(formula_or_cask, json: false, full_name: false, verbose: fals
end
if livecheck_strategy.present?
- if livecheck_strategy == :page_match && (livecheck_regex.blank? && livecheck.strategy_block.blank?)
+ if livecheck_strategy == :page_match && (livecheck_regex.blank? && livecheck_strategy_block.blank?)
odebug "#{strategy_name} strategy requires a regex or block"
next
elsif livecheck_url.blank?
@@ -529,7 +639,7 @@ def latest_version(formula_or_cask, json: false, full_name: false, verbose: fals
next if strategy.blank?
strategy_data = begin
- strategy.find_versions(url, livecheck_regex, cask: cask, &livecheck.strategy_block)
+ strategy.find_versions(url, livecheck_regex, cask: cask, &livecheck_strategy_block)
rescue ArgumentError => e
raise unless e.message.include?("unknown keyword: cask")
@@ -584,6 +694,17 @@ def latest_version(formula_or_cask, json: false, full_name: false, verbose: fals
if json && verbose
version_info[:meta] = {}
+ if livecheck_references.present?
+ version_info[:meta][:references] = livecheck_references.map do |ref_formula_or_cask|
+ case ref_formula_or_cask
+ when Formula
+ { formula: formula_name(ref_formula_or_cask, full_name: full_name) }
+ when Cask::Cask
+ { cask: cask_name(ref_formula_or_cask, full_name: full_name) }
+ end
+ end
+ end
+
version_info[:meta][:url] = {}
version_info[:meta][:url][:symbol] = livecheck_url if livecheck_url.is_a?(Symbol) && livecheck_url_string
version_info[:meta][:url][:original] = original_url
@@ -599,8 +720,10 @@ def latest_version(formula_or_cask, json: false, full_name: false, verbose: fals
return version_info
end
+ # rubocop:enable Metrics/BlockLength
nil
end
end
+ # rubocop:enable Metrics/ModuleLength
end | true |
Other | Homebrew | brew | ddde0f7589b9c04f53869cf39f4c5e01f772b3d7.json | livecheck: allow inheriting from a formula/cask | Library/Homebrew/livecheck/skip_conditions.rb | @@ -201,6 +201,54 @@ def skip_information(formula_or_cask, full_name: false, verbose: false)
{}
end
+ # Skip conditions for formulae/casks referenced in a `livecheck` block
+ # are treated differently than normal. We only respect certain skip
+ # conditions (returning the related hash) and others are treated as
+ # errors.
+ sig {
+ params(
+ livecheck_formula_or_cask: T.any(Formula, Cask::Cask),
+ original_formula_or_cask_name: String,
+ full_name: T::Boolean,
+ verbose: T::Boolean,
+ ).returns(T.nilable(Hash))
+ }
+ def referenced_skip_information(
+ livecheck_formula_or_cask,
+ original_formula_or_cask_name,
+ full_name: false,
+ verbose: false
+ )
+ skip_info = SkipConditions.skip_information(
+ livecheck_formula_or_cask,
+ full_name: full_name,
+ verbose: verbose,
+ )
+ return if skip_info.blank?
+
+ referenced_name = Livecheck.formula_or_cask_name(livecheck_formula_or_cask, full_name: full_name)
+ referenced_type = case livecheck_formula_or_cask
+ when Formula
+ :formula
+ when Cask::Cask
+ :cask
+ end
+
+ if skip_info[:status] != "error" &&
+ !(skip_info[:status] == "skipped" && livecheck_formula_or_cask.livecheck.skip?)
+ error_msg_end = if skip_info[:status] == "skipped"
+ "automatically skipped"
+ else
+ "skipped as #{skip_info[:status]}"
+ end
+
+ raise "Referenced #{referenced_type} (#{referenced_name}) is #{error_msg_end}"
+ end
+
+ skip_info[referenced_type] = original_formula_or_cask_name
+ skip_info
+ end
+
# Prints default livecheck output in relation to skip conditions.
sig { params(skip_hash: Hash).void }
def print_skip_information(skip_hash) | true |
Other | Homebrew | brew | ddde0f7589b9c04f53869cf39f4c5e01f772b3d7.json | livecheck: allow inheriting from a formula/cask | Library/Homebrew/rubocops/livecheck.rb | @@ -50,6 +50,10 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node)
skip = find_every_method_call_by_name(livecheck_node, :skip).first
return if skip.present?
+ formula_node = find_every_method_call_by_name(livecheck_node, :formula).first
+ cask_node = find_every_method_call_by_name(livecheck_node, :cask).first
+ return if formula_node.present? || cask_node.present?
+
livecheck_url = find_every_method_call_by_name(livecheck_node, :url).first
return if livecheck_url.present?
| true |
Other | Homebrew | brew | ddde0f7589b9c04f53869cf39f4c5e01f772b3d7.json | livecheck: allow inheriting from a formula/cask | Library/Homebrew/test/livecheck/livecheck_spec.rb | @@ -44,6 +44,15 @@
RUBY
end
+ describe "::resolve_livecheck_reference" do
+ context "when a formula/cask has a livecheck block without formula/cask methods" do
+ it "returns [nil, []]" do
+ expect(livecheck.resolve_livecheck_reference(f)).to eq([nil, []])
+ expect(livecheck.resolve_livecheck_reference(c)).to eq([nil, []])
+ end
+ end
+ end
+
describe "::formula_name" do
it "returns the name of the formula" do
expect(livecheck.formula_name(f)).to eq("test") | true |
Other | Homebrew | brew | ddde0f7589b9c04f53869cf39f4c5e01f772b3d7.json | livecheck: allow inheriting from a formula/cask | Library/Homebrew/test/livecheck/skip_conditions_spec.rb | @@ -264,7 +264,7 @@
}
end
- describe "::skip_conditions" do
+ describe "::skip_information" do
context "when a formula without a livecheckable is deprecated" do
it "skips" do
expect(skip_conditions.skip_information(formulae[:deprecated]))
@@ -293,21 +293,21 @@
end
end
- context "when a formula has a GitHub Gist stable URL" do
+ context "when a formula without a livecheckable has a GitHub Gist stable URL" do
it "skips" do
expect(skip_conditions.skip_information(formulae[:gist]))
.to eq(status_hashes[:formula][:gist])
end
end
- context "when a formula has a Google Code Archive stable URL" do
+ context "when a formula without a livecheckable has a Google Code Archive stable URL" do
it "skips" do
expect(skip_conditions.skip_information(formulae[:google_code_archive]))
.to eq(status_hashes[:formula][:google_code_archive])
end
end
- context "when a formula has an Internet Archive stable URL" do
+ context "when a formula without a livecheckable has an Internet Archive stable URL" do
it "skips" do
expect(skip_conditions.skip_information(formulae[:internet_archive]))
.to eq(status_hashes[:formula][:internet_archive])
@@ -364,6 +364,108 @@
end
end
+ describe "::referenced_skip_information" do
+ let(:original_name) { "original" }
+
+ context "when a formula without a livecheckable is deprecated" do
+ it "errors" do
+ expect { skip_conditions.referenced_skip_information(formulae[:deprecated], original_name) }
+ .to raise_error(RuntimeError, "Referenced formula (test_deprecated) is skipped as deprecated")
+ end
+ end
+
+ context "when a formula without a livecheckable is disabled" do
+ it "errors" do
+ expect { skip_conditions.referenced_skip_information(formulae[:disabled], original_name) }
+ .to raise_error(RuntimeError, "Referenced formula (test_disabled) is skipped as disabled")
+ end
+ end
+
+ context "when a formula without a livecheckable is versioned" do
+ it "errors" do
+ expect { skip_conditions.referenced_skip_information(formulae[:versioned], original_name) }
+ .to raise_error(RuntimeError, "Referenced formula (test@0.0.1) is skipped as versioned")
+ end
+ end
+
+ context "when a formula is HEAD-only and not installed" do
+ it "skips " do
+ expect(skip_conditions.referenced_skip_information(formulae[:head_only], original_name))
+ .to eq(status_hashes[:formula][:head_only].merge({ formula: original_name }))
+ end
+ end
+
+ context "when a formula without a livecheckable has a GitHub Gist stable URL" do
+ it "errors" do
+ expect { skip_conditions.referenced_skip_information(formulae[:gist], original_name) }
+ .to raise_error(RuntimeError, "Referenced formula (test_gist) is automatically skipped")
+ end
+ end
+
+ context "when a formula without a livecheckable has a Google Code Archive stable URL" do
+ it "errors" do
+ expect { skip_conditions.referenced_skip_information(formulae[:google_code_archive], original_name) }
+ .to raise_error(RuntimeError, "Referenced formula (test_google_code_archive) is automatically skipped")
+ end
+ end
+
+ context "when a formula without a livecheckable has an Internet Archive stable URL" do
+ it "errors" do
+ expect { skip_conditions.referenced_skip_information(formulae[:internet_archive], original_name) }
+ .to raise_error(RuntimeError, "Referenced formula (test_internet_archive) is automatically skipped")
+ end
+ end
+
+ context "when a formula has a `livecheck` block containing `skip`" do
+ it "skips" do
+ expect(skip_conditions.referenced_skip_information(formulae[:skip], original_name))
+ .to eq(status_hashes[:formula][:skip].merge({ formula: original_name }))
+
+ expect(skip_conditions.referenced_skip_information(formulae[:skip_with_message], original_name))
+ .to eq(status_hashes[:formula][:skip_with_message].merge({ formula: original_name }))
+ end
+ end
+
+ context "when a cask without a livecheckable is discontinued" do
+ it "errors" do
+ expect { skip_conditions.referenced_skip_information(casks[:discontinued], original_name) }
+ .to raise_error(RuntimeError, "Referenced cask (test_discontinued) is skipped as discontinued")
+ end
+ end
+
+ context "when a cask without a livecheckable has `version :latest`" do
+ it "errors" do
+ expect { skip_conditions.referenced_skip_information(casks[:latest], original_name) }
+ .to raise_error(RuntimeError, "Referenced cask (test_latest) is skipped as latest")
+ end
+ end
+
+ context "when a cask without a livecheckable has an unversioned URL" do
+ it "errors" do
+ expect { skip_conditions.referenced_skip_information(casks[:unversioned], original_name) }
+ .to raise_error(RuntimeError, "Referenced cask (test_unversioned) is skipped as unversioned")
+ end
+ end
+
+ context "when a cask has a `livecheck` block containing `skip`" do
+ it "skips" do
+ expect(skip_conditions.referenced_skip_information(casks[:skip], original_name))
+ .to eq(status_hashes[:cask][:skip].merge({ cask: original_name }))
+
+ expect(skip_conditions.referenced_skip_information(casks[:skip_with_message], original_name))
+ .to eq(status_hashes[:cask][:skip_with_message].merge({ cask: original_name }))
+ end
+ end
+
+ it "returns an empty hash for a non-skippable formula" do
+ expect(skip_conditions.referenced_skip_information(formulae[:basic], original_name)).to eq(nil)
+ end
+
+ it "returns an empty hash for a non-skippable cask" do
+ expect(skip_conditions.referenced_skip_information(casks[:basic], original_name)).to eq(nil)
+ end
+ end
+
describe "::print_skip_information" do
context "when a formula without a livecheckable is deprecated" do
it "prints skip information" do | true |
Other | Homebrew | brew | ddde0f7589b9c04f53869cf39f4c5e01f772b3d7.json | livecheck: allow inheriting from a formula/cask | Library/Homebrew/test/livecheck_spec.rb | @@ -28,6 +28,40 @@
end
let(:livecheckable_c) { described_class.new(c) }
+ describe "#formula" do
+ it "returns nil if not set" do
+ expect(livecheckable_f.formula).to be nil
+ end
+
+ it "returns the String if set" do
+ livecheckable_f.formula("other-formula")
+ expect(livecheckable_f.formula).to eq("other-formula")
+ end
+
+ it "raises a TypeError if the argument isn't a String" do
+ expect {
+ livecheckable_f.formula(123)
+ }.to raise_error(TypeError, "Livecheck#formula expects a String")
+ end
+ end
+
+ describe "#cask" do
+ it "returns nil if not set" do
+ expect(livecheckable_c.cask).to be nil
+ end
+
+ it "returns the String if set" do
+ livecheckable_c.cask("other-cask")
+ expect(livecheckable_c.cask).to eq("other-cask")
+ end
+
+ it "raises a TypeError if the argument isn't a String" do
+ expect {
+ livecheckable_c.cask(123)
+ }.to raise_error(TypeError, "Livecheck#cask expects a String")
+ end
+ end
+
describe "#regex" do
it "returns nil if not set" do
expect(livecheckable_f.regex).to be nil
@@ -128,6 +162,8 @@
it "returns a Hash of all instance variables" do
expect(livecheckable_f.to_hash).to eq(
{
+ "cask" => nil,
+ "formula" => nil,
"regex" => nil,
"skip" => false,
"skip_msg" => nil, | true |
Other | Homebrew | brew | 7cc37fb7f869971b1c3efe82730274d48063c89a.json | cmd/shellenv.sh: support multi-instance installation | Library/Homebrew/cmd/shellenv.sh | @@ -15,31 +15,31 @@ homebrew-shellenv() {
echo "set -gx HOMEBREW_PREFIX \"${HOMEBREW_PREFIX}\";"
echo "set -gx HOMEBREW_CELLAR \"${HOMEBREW_CELLAR}\";"
echo "set -gx HOMEBREW_REPOSITORY \"${HOMEBREW_REPOSITORY}\";"
- [[ -n "${HOMEBREW_SHELLENV_SET}" ]] && return
+ [[ ":${HOMEBREW_SHELLENV_SET}:" == *":${HOMEBREW_PREFIX}:"* ]] && return
echo "set -q PATH; or set PATH ''; set -gx PATH \"${HOMEBREW_PREFIX}/bin\" \"${HOMEBREW_PREFIX}/sbin\" \$PATH;"
echo "set -q MANPATH; or set MANPATH ''; set -gx MANPATH \"${HOMEBREW_PREFIX}/share/man\" \$MANPATH;"
echo "set -q INFOPATH; or set INFOPATH ''; set -gx INFOPATH \"${HOMEBREW_PREFIX}/share/info\" \$INFOPATH;"
- echo "set -gx HOMEBREW_SHELLENV_SET 1;"
+ echo "set -q HOMEBREW_SHELLENV_SET; or set HOMEBREW_SHELLENV_SET ''; set -gx HOMEBREW_SHELLENV_SET \"${HOMEBREW_PREFIX}\" \$HOMEBREW_SHELLENV_SET;"
;;
csh | -csh | tcsh | -tcsh)
echo "setenv HOMEBREW_PREFIX ${HOMEBREW_PREFIX};"
echo "setenv HOMEBREW_CELLAR ${HOMEBREW_CELLAR};"
echo "setenv HOMEBREW_REPOSITORY ${HOMEBREW_REPOSITORY};"
- [[ -n "${HOMEBREW_SHELLENV_SET}" ]] && return
+ [[ ":${HOMEBREW_SHELLENV_SET}:" == *":${HOMEBREW_PREFIX}:"* ]] && return
echo "setenv PATH ${HOMEBREW_PREFIX}/bin:${HOMEBREW_PREFIX}/sbin:\$PATH;"
echo "setenv MANPATH ${HOMEBREW_PREFIX}/share/man\`[ \${?MANPATH} == 1 ] && echo \":\${MANPATH}\"\`:;"
echo "setenv INFOPATH ${HOMEBREW_PREFIX}/share/info\`[ \${?INFOPATH} == 1 ] && echo \":\${INFOPATH}\"\`;"
- echo "setenv HOMEBREW_SHELLENV_SET 1;"
+ echo "setenv HOMEBREW_SHELLENV_SET ${HOMEBREW_PREFIX}\`[ \${?HOMEBREW_SHELLENV_SET} == 1 ] && echo \":\${HOMEBREW_SHELLENV_SET}\"\`;"
;;
*)
echo "export HOMEBREW_PREFIX=\"${HOMEBREW_PREFIX}\";"
echo "export HOMEBREW_CELLAR=\"${HOMEBREW_CELLAR}\";"
echo "export HOMEBREW_REPOSITORY=\"${HOMEBREW_REPOSITORY}\";"
- [[ -n "${HOMEBREW_SHELLENV_SET}" ]] && return
+ [[ ":${HOMEBREW_SHELLENV_SET}:" == *":${HOMEBREW_PREFIX}:"* ]] && return
echo "export PATH=\"${HOMEBREW_PREFIX}/bin:${HOMEBREW_PREFIX}/sbin\${PATH+:\$PATH}\";"
echo "export MANPATH=\"${HOMEBREW_PREFIX}/share/man\${MANPATH+:\$MANPATH}:\";"
echo "export INFOPATH=\"${HOMEBREW_PREFIX}/share/info:\${INFOPATH:-}\";"
- echo "export HOMEBREW_SHELLENV_SET=1;"
+ echo "export HOMEBREW_SHELLENV_SET=\"${HOMEBREW_PREFIX}\${HOMEBREW_SHELLENV_SET+:\$HOMEBREW_SHELLENV_SET}\";"
;;
esac
} | true |
Other | Homebrew | brew | 7cc37fb7f869971b1c3efe82730274d48063c89a.json | cmd/shellenv.sh: support multi-instance installation | Library/Homebrew/env_config.rb | @@ -306,8 +306,8 @@ module EnvConfig
boolean: true,
},
HOMEBREW_SHELLENV_SET: {
- description: "If set, `brew shellenv` skips export statements for paths.",
- boolean: true,
+ description: "A colon separated list of brew prefixes. If it is set and contains the current brew prefix, " \
+ "`brew shellenv` skips export statements for paths.",
},
all_proxy: {
description: "Use this SOCKS5 proxy for `curl`(1), `git`(1) and `svn`(1) when downloading through Homebrew.", | true |
Other | Homebrew | brew | 7cc37fb7f869971b1c3efe82730274d48063c89a.json | cmd/shellenv.sh: support multi-instance installation | docs/Manpage.md | @@ -2089,7 +2089,7 @@ example, run `export HOMEBREW_NO_INSECURE_REDIRECT=1` rather than just
<br>If set, verbose output will print a `.` no more than once a minute. This can be useful to avoid long-running Homebrew commands being killed due to no output.
- `HOMEBREW_SHELLENV_SET`
- <br>If set, `brew shellenv` skips export statements for paths.
+ <br>A colon separated list of brew prefixes. If it is set and contains the current brew prefix, `brew shellenv` skips export statements for paths.
- `all_proxy`
<br>Use this SOCKS5 proxy for `curl`(1), `git`(1) and `svn`(1) when downloading through Homebrew. | true |
Other | Homebrew | brew | 7cc37fb7f869971b1c3efe82730274d48063c89a.json | cmd/shellenv.sh: support multi-instance installation | manpages/brew.1 | @@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
-.TH "BREW" "1" "July 2021" "Homebrew" "brew"
+.TH "BREW" "1" "August 2021" "Homebrew" "brew"
.
.SH "NAME"
\fBbrew\fR \- The Missing Package Manager for macOS (or Linux)
@@ -3043,7 +3043,7 @@ If set, verbose output will print a \fB\.\fR no more than once a minute\. This c
\fBHOMEBREW_SHELLENV_SET\fR
.
.br
-If set, \fBbrew shellenv\fR skips export statements for paths\.
+A colon separated list of brew prefixes\. If it is set and contains the current brew prefix, \fBbrew shellenv\fR skips export statements for paths\.
.
.TP
\fBall_proxy\fR | true |
Other | Homebrew | brew | 34c1a6f850261022ceca4c09faef1e3124bfcf40.json | gist-logs: grab files in subdirectories too | Library/Homebrew/cmd/gist-logs.rb | @@ -92,15 +92,19 @@ def noecho_gets
result
end
- def load_logs(dir)
+ def load_logs(dir, basedir = dir)
logs = {}
if dir.exist?
dir.children.sort.each do |file|
- contents = file.size? ? file.read : "empty log"
- # small enough to avoid GitHub "unicorn" page-load-timeout errors
- max_file_size = 1_000_000
- contents = truncate_text_to_approximate_size(contents, max_file_size, front_weight: 0.2)
- logs[file.basename.to_s] = { content: contents }
+ if file.directory?
+ logs.merge! load_logs(file, basedir)
+ else
+ contents = file.size? ? file.read : "empty log"
+ # small enough to avoid GitHub "unicorn" page-load-timeout errors
+ max_file_size = 1_000_000
+ contents = truncate_text_to_approximate_size(contents, max_file_size, front_weight: 0.2)
+ logs[file.relative_path_from(basedir).to_s.tr("/", ":")] = { content: contents }
+ end
end
end
odie "No logs." if logs.empty? | false |
Other | Homebrew | brew | 29e648dd8954442c5dc4cbc08921c34acb664ad1.json | .github/ISSUE_TEMPLATE/bug.yml: add instructions for mirror sites bug reporting | .github/ISSUE_TEMPLATE/bug.yml | @@ -11,6 +11,9 @@ body:
label: "`brew config` output"
validations:
required: true
+ - type: markdown
+ attributes:
+ value: If you are using `HOMEBREW_BOTTLE_DOMAIN` or `HOMEBREW_ARTIFACT_DOMAIN` to configure Homebrew mirrors, please first try unsetting those variables. If this bug is related to mirror sites themselves, please report the bug to the respective mirror sites. See https://github.com/Homebrew/discussions/discussions/1917 for more information.
- type: textarea
attributes:
render: shell | false |
Other | Homebrew | brew | c1f68c70536fe15e20678fef61c093b25ef99685.json | sorbet: Update RBI files.
Autogenerated by the [sorbet](https://github.com/Homebrew/brew/blob/master/.github/workflows/sorbet.yml) workflow. | Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi | @@ -8361,6 +8361,8 @@ module Homebrew::EnvConfig
def self.display_install_times?(); end
+ def self.docker_registry_token(); end
+
def self.editor(); end
def self.fail_log_lines(); end | false |
Other | Homebrew | brew | 391b02f870e7db3d3208729ab636372f6677daf4.json | formula_installer: install service after linking | Library/Homebrew/formula_installer.rb | @@ -754,11 +754,11 @@ def finish
ohai "Finishing up" if verbose?
- install_service
-
keg = Keg.new(formula.prefix)
link(keg)
+ install_service
+
fix_dynamic_linkage(keg) if !@poured_bottle || !formula.bottle_specification.skip_relocation?
if build_bottle? | false |
Other | Homebrew | brew | 869b0ea519ce1d18303d62c75a136a09a30361a8.json | Formula: use opt_prefix for service helpers | Library/Homebrew/formula.rb | @@ -986,13 +986,13 @@ def service_name
# The generated launchd {.plist} file path.
sig { returns(Pathname) }
def plist_path
- prefix/"#{plist_name}.plist"
+ opt_prefix/"#{plist_name}.plist"
end
# The generated systemd {.service} file path.
sig { returns(Pathname) }
def systemd_service_path
- prefix/"#{service_name}.service"
+ opt_prefix/"#{service_name}.service"
end
# The service specification of the software. | true |
Other | Homebrew | brew | 869b0ea519ce1d18303d62c75a136a09a30361a8.json | Formula: use opt_prefix for service helpers | Library/Homebrew/test/formula_installer_spec.rb | @@ -223,7 +223,7 @@ class #{Formulary.class_s(dep_name)} < Formula
it "works if plist is set" do
formula = Testball.new
path = formula.plist_path
- formula.prefix.mkpath
+ formula.opt_prefix.mkpath
expect(formula).to receive(:plist).twice.and_return("PLIST")
expect(formula).to receive(:plist_path).and_call_original
@@ -241,7 +241,7 @@ class #{Formulary.class_s(dep_name)} < Formula
plist_path = formula.plist_path
service_path = formula.systemd_service_path
service = Homebrew::Service.new(formula)
- formula.prefix.mkpath
+ formula.opt_prefix.mkpath
expect(formula).to receive(:plist).and_return(nil)
expect(formula).to receive(:service?).exactly(3).and_return(true)
@@ -264,7 +264,7 @@ class #{Formulary.class_s(dep_name)} < Formula
it "returns without definition" do
formula = Testball.new
path = formula.plist_path
- formula.prefix.mkpath
+ formula.opt_prefix.mkpath
expect(formula).to receive(:plist).and_return(nil)
expect(formula).to receive(:service?).exactly(3).and_return(nil)
@@ -282,7 +282,7 @@ class #{Formulary.class_s(dep_name)} < Formula
it "errors with duplicate definition" do
formula = Testball.new
path = formula.plist_path
- formula.prefix.mkpath
+ formula.opt_prefix.mkpath
expect(formula).to receive(:plist).and_return("plist")
expect(formula).to receive(:service?).and_return(true) | true |
Other | Homebrew | brew | 869b0ea519ce1d18303d62c75a136a09a30361a8.json | Formula: use opt_prefix for service helpers | Library/Homebrew/test/formula_spec.rb | @@ -701,31 +701,52 @@
end
end
- specify "#service" do
- f = formula do
- url "https://brew.sh/test-1.0.tbz"
+ describe "#service" do
+ specify "no service defined" do
+ f = formula do
+ url "https://brew.sh/test-1.0.tbz"
+ end
+
+ expect(f.service).to eq(nil)
end
- f.class.service do
- run [opt_bin/"beanstalkd"]
- run_type :immediate
- error_log_path var/"log/beanstalkd.error.log"
- log_path var/"log/beanstalkd.log"
- working_dir var
- keep_alive true
+ specify "service complicated" do
+ f = formula do
+ url "https://brew.sh/test-1.0.tbz"
+ end
+
+ f.class.service do
+ run [opt_bin/"beanstalkd"]
+ run_type :immediate
+ error_log_path var/"log/beanstalkd.error.log"
+ log_path var/"log/beanstalkd.log"
+ working_dir var
+ keep_alive true
+ end
+ expect(f.service).not_to eq(nil)
end
- expect(f.service).not_to eq(nil)
- end
- specify "service uses simple run" do
- f = formula do
- url "https://brew.sh/test-1.0.tbz"
- service do
- run opt_bin/"beanstalkd"
+ specify "service uses simple run" do
+ f = formula do
+ url "https://brew.sh/test-1.0.tbz"
+ service do
+ run opt_bin/"beanstalkd"
+ end
end
+
+ expect(f.service).not_to eq(nil)
end
- expect(f.service).not_to eq(nil)
+ specify "service helpers return data" do
+ f = formula do
+ url "https://brew.sh/test-1.0.tbz"
+ end
+
+ expect(f.plist_name).to eq("homebrew.mxcl.formula_name")
+ expect(f.service_name).to eq("homebrew.formula_name")
+ expect(f.plist_path).to eq(HOMEBREW_PREFIX/"opt/formula_name/homebrew.mxcl.formula_name.plist")
+ expect(f.systemd_service_path).to eq(HOMEBREW_PREFIX/"opt/formula_name/homebrew.formula_name.service")
+ end
end
specify "dependencies" do | true |
Other | Homebrew | brew | cc12738f8e31b5a674057a2945fdbda7c2c12825.json | Allow anonymous access in private registries | Library/Homebrew/download_strategy.rb | @@ -566,8 +566,8 @@ class CurlGitHubPackagesDownloadStrategy < CurlDownloadStrategy
def initialize(url, name, version, **meta)
meta ||= {}
meta[:headers] ||= []
- token = ENV.fetch("HOMEBREW_REGISTRY_ACCESS_TOKEN", "QQ==")
- meta[:headers] << ["Authorization: Bearer #{token}"]
+ token = Homebrew::EnvConfig.artifact_domain ? ENV.fetch("HOMEBREW_REGISTRY_ACCESS_TOKEN", "") : "QQ=="
+ meta[:headers] << ["Authorization: Bearer #{token}"] unless token.empty?
super(url, name, version, meta)
end
| false |
Other | Homebrew | brew | b8954030e36b69508f3aa6747b9af04f1efaad92.json | Add support for private registry | Library/Homebrew/download_strategy.rb | @@ -449,7 +449,7 @@ def resolve_url_basename_time_file_size(url, timeout: nil)
return @resolved_info_cache[url] if @resolved_info_cache.include?(url)
if (domain = Homebrew::EnvConfig.artifact_domain)
- url = url.sub(%r{^((ht|f)tps?://)?}, "#{domain.chomp("/")}/")
+ url = url.sub(%r{^((ht|f)tps?://ghcr.io/)?}, "#{domain.chomp("/")}/")
end
out, _, status= curl_output("--location", "--silent", "--head", "--request", "GET", url.to_s, timeout: timeout)
@@ -528,6 +528,8 @@ def _fetch(url:, resolved_url:, timeout:)
def _curl_args
args = []
+ args += ["-L"] if Homebrew::EnvConfig.artifact_domain
+
args += ["-b", meta.fetch(:cookies).map { |k, v| "#{k}=#{v}" }.join(";")] if meta.key?(:cookies)
args += ["-e", meta.fetch(:referer)] if meta.key?(:referer)
@@ -564,7 +566,8 @@ class CurlGitHubPackagesDownloadStrategy < CurlDownloadStrategy
def initialize(url, name, version, **meta)
meta ||= {}
meta[:headers] ||= []
- meta[:headers] << ["Authorization: Bearer QQ=="]
+ token = ENV.fetch("HOMEBREW_REGISTRY_ACCESS_TOKEN", "QQ==")
+ meta[:headers] << ["Authorization: Bearer #{token}"]
super(url, name, version, meta)
end
| true |
Other | Homebrew | brew | b8954030e36b69508f3aa6747b9af04f1efaad92.json | Add support for private registry | Library/Homebrew/env_config.rb | @@ -170,6 +170,10 @@ module EnvConfig
description: "Use this GitHub personal access token when accessing the GitHub Packages Registry "\
"(where bottles may be stored).",
},
+ HOMEBREW_REGISTRY_ACCESS_TOKEN: {
+ description: "Use this bearer token for authenticating with a private registry proxying GitHub "\
+ "Packages Registry.",
+ },
HOMEBREW_GITHUB_PACKAGES_USER: {
description: "Use this username when accessing the GitHub Packages Registry (where bottles may be stored).",
}, | true |
Other | Homebrew | brew | a8527f4c16d7df419f6539fd583302635ec98a4a.json | Ensure writability, handle errors | Library/Homebrew/formula.rb | @@ -1582,6 +1582,10 @@ def time
end
end
+ # Replaces a universal binary with its native slice.
+ #
+ # If called with no parameters, does this with all compatible
+ # universal binaries in a {Formula}'s {Keg}.
sig { params(targets: T.nilable(T.any(Pathname, String))).void }
def deuniversalize_machos(*targets)
if targets.blank?
@@ -1590,10 +1594,23 @@ def deuniversalize_machos(*targets)
end
end
- targets.each do |t|
- macho = MachO::FatFile.new(t)
+ targets.each { |t| extract_slice_from(Pathname.new(t), Hardware::CPU.arch) }
+ end
+
+ # @private
+ sig { params(file: Pathname, arch: T.nilable(Symbol)).void }
+ def extract_slice_from(file, arch = Hardware::CPU.arch)
+ odebug "Extracting #{arch} slice from #{file}"
+ file.ensure_writable do
+ macho = MachO::FatFile.new(file)
native_slice = macho.extract(Hardware::CPU.arch)
- native_slice.write t
+ native_slice.write file
+ rescue MachO::MachOBinaryError
+ onoe "#{file} is not a universal binary"
+ raise
+ rescue NoMethodError
+ onoe "#{file} does not contain an #{arch} slice"
+ raise
end
end
| false |
Other | Homebrew | brew | 485c9777d30a2635da4ac096e6db188c1923722b.json | Update RBI files for rubocop. | Library/Homebrew/sorbet/rbi/gems/rubocop@1.18.4.rbi | @@ -793,6 +793,7 @@ class RuboCop::ConfigValidator
def msg_not_boolean(parent, key, value); end
def reject_conflicting_safe_settings; end
def reject_mutually_exclusive_defaults; end
+ def suggestion(name); end
def target_ruby; end
def validate_enforced_styles(valid_cop_names); end
def validate_new_cops_parameter; end
@@ -2222,6 +2223,7 @@ class RuboCop::Cop::Layout::ClassStructure < ::RuboCop::Cop::Base
def source_range_with_comment(node); end
def start_line_position(node); end
def walk_over_nested_class_definition(class_node); end
+ def whole_line_comment_at_line?(line); end
end
RuboCop::Cop::Layout::ClassStructure::HUMANIZED_NODE_TYPE = T.let(T.unsafe(nil), Hash)
@@ -2731,6 +2733,7 @@ class RuboCop::Cop::Layout::EndAlignment < ::RuboCop::Cop::Base
def alignment_node(node); end
def alignment_node_for_variable_style(node); end
def asgn_variable_align_with(outer_node, inner_node); end
+ def assignment_or_operator_method(node); end
def autocorrect(corrector, node); end
def check_asgn_alignment(outer_node, inner_node); end
def check_assignment(node, rhs); end
@@ -2933,16 +2936,16 @@ class RuboCop::Cop::Layout::HashAlignment < ::RuboCop::Cop::Base
def column_deltas; end
def column_deltas=(_arg0); end
- def offences_by; end
- def offences_by=(_arg0); end
+ def offenses_by; end
+ def offenses_by=(_arg0); end
def on_hash(node); end
def on_send(node); end
def on_super(node); end
def on_yield(node); end
private
- def add_offences; end
+ def add_offenses; end
def adjust(corrector, delta, range); end
def alignment_for(pair); end
def alignment_for_colons; end
@@ -2959,7 +2962,7 @@ class RuboCop::Cop::Layout::HashAlignment < ::RuboCop::Cop::Base
def good_alignment?(column_deltas); end
def ignore_hash_argument?(node); end
def new_alignment(key); end
- def register_offences_with_format(offences, format); end
+ def register_offenses_with_format(offenses, format); end
def reset!; end
end
@@ -3070,7 +3073,7 @@ class RuboCop::Cop::Layout::IndentationStyle < ::RuboCop::Cop::Base
def autocorrect(corrector, range); end
def autocorrect_lambda_for_spaces(corrector, range); end
def autocorrect_lambda_for_tabs(corrector, range); end
- def find_offence(line, lineno); end
+ def find_offense(line, lineno); end
def in_string_literal?(ranges, tabs_range); end
def message(_node); end
def string_literal_ranges(ast); end
@@ -4414,6 +4417,7 @@ class RuboCop::Cop::Lint::DuplicateBranch < ::RuboCop::Cop::Base
def on_branching_statement(node); end
def on_case(node); end
+ def on_case_match(node); end
def on_if(node); end
def on_rescue(node); end
@@ -9538,7 +9542,6 @@ class RuboCop::Cop::Style::MutableConstant < ::RuboCop::Cop::Base
extend ::RuboCop::Cop::AutoCorrector
def on_casgn(node); end
- def on_or_asgn(node); end
def operation_produces_immutable_object?(param0 = T.unsafe(nil)); end
def range_enclosed_in_parentheses?(param0 = T.unsafe(nil)); end
def splat_value(param0 = T.unsafe(nil)); end
@@ -10918,6 +10921,7 @@ class RuboCop::Cop::Style::SingleLineMethods < ::RuboCop::Cop::Base
def allow_empty?; end
def autocorrect(corrector, node); end
+ def break_line_before(corrector, node, range, indent_steps: T.unsafe(nil)); end
def correct_to_endless(corrector, node); end
def correct_to_endless?(body_node); end
def correct_to_multiline(corrector, node); end | false |
Other | Homebrew | brew | 778d5df6d4bf44b832a4d15ade004227cac1b328.json | add qlplugins check to guess_cask_version | Library/Homebrew/unversioned_cask_checker.rb | @@ -122,8 +122,8 @@ def all_versions
sig { returns(T.nilable(String)) }
def guess_cask_version
- if apps.empty? && pkgs.empty?
- opoo "Cask #{cask} does not contain any apps or PKG installers."
+ if apps.empty? && pkgs.empty? && qlplugins.empty?
+ opoo "Cask #{cask} does not contain any apps, qlplugins or PKG installers."
return
end
| false |
Other | Homebrew | brew | 5e0b786da21564011be7df165ce20a61d639de77.json | formula: add `deuniversalize_machos` method
This method takes an optional array of `Pathnames`s or `Strings`s and
extracts the native slice from the specified universal binary. If no
parameter is supplied, this is done on all compatible universal binaries
in a formula's keg.
`deuniversalize_machos` is a no-op on Linux.
I still need to look into a) error handling, and b) whether using this
method requires codesigning on ARM.
I've also added signatures to the methods in `extend/os/linux/formula`. | Library/Homebrew/extend/os/linux/formula.rb | @@ -4,7 +4,9 @@
class Formula
undef shared_library
undef rpath
+ undef deuniversalize_machos
+ sig { params(name: String, version: T.nilable(T.any(String, Integer))).returns(String) }
def shared_library(name, version = nil)
suffix = if version == "*" || (name == "*" && version.blank?)
"{,.*}"
@@ -14,10 +16,14 @@ def shared_library(name, version = nil)
"#{name}.so#{suffix}"
end
+ sig { returns(String) }
def rpath
"'$ORIGIN/../lib'"
end
+ sig { params(targets: T.nilable(T.any(Pathname, String))).void }
+ def deuniversalize_machos(*targets); end
+
class << self
undef ignore_missing_libraries
| true |
Other | Homebrew | brew | 5e0b786da21564011be7df165ce20a61d639de77.json | formula: add `deuniversalize_machos` method
This method takes an optional array of `Pathnames`s or `Strings`s and
extracts the native slice from the specified universal binary. If no
parameter is supplied, this is done on all compatible universal binaries
in a formula's keg.
`deuniversalize_machos` is a no-op on Linux.
I still need to look into a) error handling, and b) whether using this
method requires codesigning on ARM.
I've also added signatures to the methods in `extend/os/linux/formula`. | Library/Homebrew/formula.rb | @@ -1582,6 +1582,21 @@ def time
end
end
+ sig { params(targets: T.nilable(T.any(Pathname, String))).void }
+ def deuniversalize_machos(*targets)
+ if targets.blank?
+ targets = any_installed_keg.mach_o_files.select do |file|
+ file.arch == :universal && file.archs.include?(Hardware::CPU.arch)
+ end
+ end
+
+ targets.each do |t|
+ macho = MachO::FatFile.new(t)
+ native_slice = macho.extract(Hardware::CPU.arch)
+ native_slice.write t
+ end
+ end
+
# an array of all core {Formula} names
# @private
def self.core_names | true |
Other | Homebrew | brew | 78ad5a870cee79255cc24fb632734e7a700548dd.json | formula_installer: add `tap_audit_exception` stub
`FormulaInstaller` calls `audit_installed` at install time, which
invokes methods in `FormulaCellarChecks`. One of these methods makes a
call to `tap_audit_exception` (cf. #11750), but this method isn't
visible in `FormulaInstaller`.
Instead of trying to replicate the logic of `tap_audit_exception` in
`FormulaAuditor` (or trying to initialise an instance of one to make the
call to `FormulaAuditor`'s implementation of it), let's just implement a
stub that assumes an exception always exists.
I'll need to think a bit about whether this is the right fix for this,
but currently the missing method error is blocking PRs in Homebrew/core,
so let's go with this for now. [1]
[1] e.g. Homebrew/homebrew-core#81388, Homebrew/homebrew-core#81582 | Library/Homebrew/formula_installer.rb | @@ -1196,6 +1196,12 @@ def audit_installed
super
end
+ # This is a stub for calls made to this method at install time.
+ # Exceptions are correctly identified when doing `brew audit`.
+ def tap_audit_exception(*)
+ true
+ end
+
def self.locked
@locked ||= []
end | false |
Other | Homebrew | brew | 2fe77f52717e9b688a2e2f4c57c0404022a3afee.json | Formula: Allow configuration of std_cargo_args | Library/Homebrew/formula.rb | @@ -1479,9 +1479,9 @@ def std_configure_args
end
# Standard parameters for cargo builds.
- sig { returns(T::Array[T.any(String, Pathname)]) }
- def std_cargo_args
- ["--locked", "--root", prefix, "--path", "."]
+ sig { params(root: String, path: String).returns(T::Array[T.any(String, Pathname)]) }
+ def std_cargo_args(root: prefix, path: ".")
+ ["--locked", "--root", root, "--path", path]
end
# Standard parameters for CMake builds. | false |
Other | Homebrew | brew | 81d89803db83510f58360993176c3719449364c6.json | Remove extra `HOMEBREW_NO_DEV_CMD_MESSAGE` line | Library/Homebrew/dev-cmd/tests.rb | @@ -87,7 +87,6 @@ def tests
ENV.delete(env)
end
- ENV["HOMEBREW_NO_DEV_CMD_MESSAGE"] = "1"
ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"
ENV["HOMEBREW_NO_COMPAT"] = "1" if args.no_compat?
ENV["HOMEBREW_TEST_GENERIC_OS"] = "1" if args.generic? | false |
Other | Homebrew | brew | 27ba803bb593a6c07e4dd36634660e8d6881aa48.json | Remove need for `HOMEBREW_NO_DEV_CMD_MESSAGE` | Library/Homebrew/brew.rb | @@ -93,7 +93,7 @@ class MissingEnvironmentVariables < RuntimeError; end
internal_cmd ||= begin
internal_dev_cmd = Commands.valid_internal_dev_cmd?(cmd)
if internal_dev_cmd && !Homebrew::EnvConfig.developer?
- if ENV["HOMEBREW_DEV_CMD_RUN"].blank? && !Homebrew::EnvConfig.no_dev_cmd_message?
+ if ENV["HOMEBREW_DEV_CMD_RUN"].blank?
opoo <<~MESSAGE
#{Tty.bold}#{cmd}#{Tty.reset} is a developer command, so
Homebrew's developer mode has been automatically turned on. | true |
Other | Homebrew | brew | 27ba803bb593a6c07e4dd36634660e8d6881aa48.json | Remove need for `HOMEBREW_NO_DEV_CMD_MESSAGE` | Library/Homebrew/brew.sh | @@ -645,7 +645,7 @@ elif [[ -f "${HOMEBREW_LIBRARY}/Homebrew/dev-cmd/${HOMEBREW_COMMAND}.sh" ]]
then
if [[ -z "${HOMEBREW_DEVELOPER}" ]]
then
- if [[ -z "${HOMEBREW_DEV_CMD_RUN}" ]] && [[ -z "${HOMEBREW_NO_DEV_CMD_MESSAGE}" ]]
+ if [[ -z "${HOMEBREW_DEV_CMD_RUN}" ]]
then
message="$(bold "${HOMEBREW_COMMAND}") is a developer command, so
Homebrew's developer mode has been automatically turned on. | true |
Other | Homebrew | brew | 27ba803bb593a6c07e4dd36634660e8d6881aa48.json | Remove need for `HOMEBREW_NO_DEV_CMD_MESSAGE` | Library/Homebrew/env_config.rb | @@ -235,10 +235,6 @@ module EnvConfig
description: "If set, disable all use of legacy compatibility code.",
boolean: true,
},
- HOMEBREW_NO_DEV_CMD_MESSAGE: {
- description: "If set, do not display a warning message when running a developer command for the first time.",
- boolean: true,
- },
HOMEBREW_NO_EMOJI: {
description: "If set, do not print `HOMEBREW_INSTALL_BADGE` on a successful build." \
"\n\n *Note:* Will only try to print emoji on OS X Lion or newer.", | true |
Other | Homebrew | brew | 27ba803bb593a6c07e4dd36634660e8d6881aa48.json | Remove need for `HOMEBREW_NO_DEV_CMD_MESSAGE` | Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb | @@ -83,6 +83,7 @@ def brew(*args)
"HOMEBREW_INTEGRATION_TEST" => command_id_from_args(args),
"HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR,
"HOMEBREW_DEVELOPER" => ENV["HOMEBREW_DEVELOPER"],
+ "HOMEBREW_DEV_CMD_RUN" => "true",
"GEM_HOME" => nil,
)
| true |
Other | Homebrew | brew | 27ba803bb593a6c07e4dd36634660e8d6881aa48.json | Remove need for `HOMEBREW_NO_DEV_CMD_MESSAGE` | docs/Manpage.md | @@ -2027,9 +2027,6 @@ example, run `export HOMEBREW_NO_INSECURE_REDIRECT=1` rather than just
- `HOMEBREW_NO_COMPAT`
<br>If set, disable all use of legacy compatibility code.
-- `HOMEBREW_NO_DEV_CMD_MESSAGE`
- <br>If set, do not display a warning message when running a developer command for the first time.
-
- `HOMEBREW_NO_EMOJI`
<br>If set, do not print `HOMEBREW_INSTALL_BADGE` on a successful build.
| true |
Other | Homebrew | brew | 27ba803bb593a6c07e4dd36634660e8d6881aa48.json | Remove need for `HOMEBREW_NO_DEV_CMD_MESSAGE` | manpages/brew.1 | @@ -2923,12 +2923,6 @@ If set, do not print text with colour added\.
If set, disable all use of legacy compatibility code\.
.
.TP
-\fBHOMEBREW_NO_DEV_CMD_MESSAGE\fR
-.
-.br
-If set, do not display a warning message when running a developer command for the first time\.
-.
-.TP
\fBHOMEBREW_NO_EMOJI\fR
.
.br | true |
Other | Homebrew | brew | 55cc1eb8b098283cd280cf91974890fadcf808f4.json | Check `tap_audit_exception` only if tap is present | Library/Homebrew/formula_cellar_checks.rb | @@ -330,7 +330,8 @@ def check_binary_arches(formula)
end
mismatches -= compatible_universal_binaries
- universal_binaries_expected = tap_audit_exception(:universal_binary_allowlist, formula.name)
+ universal_binaries_expected =
+ formula.tap.present? && tap_audit_exception(:universal_binary_allowlist, formula.name)
return if mismatches.empty? && universal_binaries_expected
s = "" | false |
Other | Homebrew | brew | 1678a3785e1e04a6976e723a9e176defd2ab41f4.json | Fix logic in `check_binary_arches` | Library/Homebrew/formula_cellar_checks.rb | @@ -323,14 +323,15 @@ def check_binary_arches(formula)
mismatches = keg.binary_executable_or_library_files.reject do |file|
file.arch == Hardware::CPU.arch
end
+ return if mismatches.empty?
compatible_universal_binaries = mismatches.select do |file|
file.arch == :universal && file.archs.include?(Hardware::CPU.arch)
end
mismatches -= compatible_universal_binaries
- return if mismatches.empty? && compatible_universal_binaries.empty?
- return if mismatches.empty? && tap_audit_exception(:universal_binary_allowlist, formula.name)
+ universal_binaries_expected = tap_audit_exception(:universal_binary_allowlist, formula.name)
+ return if mismatches.empty? && universal_binaries_expected
s = ""
@@ -342,7 +343,7 @@ def check_binary_arches(formula)
EOS
end
- unless compatible_universal_binaries.empty?
+ if !compatible_universal_binaries.empty? && !universal_binaries_expected
s += <<~EOS
Unexpected universal binaries were found.
The offending files are: | false |
Other | Homebrew | brew | a14d8924de63afbbd44dce7fabaa4411cb5e7837.json | extract: ignore syntax errors during load | Library/Homebrew/dev-cmd/extract.rb | @@ -226,6 +226,6 @@ def formula_at_revision(repo, name, file, rev)
contents = Utils::Git.last_revision_of_file(repo, file, before_commit: rev)
contents.gsub!("@url=", "url ")
contents.gsub!("require 'brewkit'", "require 'formula'")
- with_monkey_patch { Formulary.from_contents(name, file, contents) }
+ with_monkey_patch { Formulary.from_contents(name, file, contents, ignore_errors: true) }
end
end | true |
Other | Homebrew | brew | a14d8924de63afbbd44dce7fabaa4411cb5e7837.json | extract: ignore syntax errors during load | Library/Homebrew/test/dev-cmd/extract_spec.rb | @@ -14,9 +14,17 @@
core_tap = CoreTap.new
core_tap.path.cd do
system "git", "init"
- formula_file = setup_test_formula "testball"
+ # Start with deprecated bottle syntax
+ setup_test_formula "testball", bottle_block: <<~EOS
+
+ bottle do
+ cellar :any
+ end
+ EOS
system "git", "add", "--all"
system "git", "commit", "-m", "testball 0.1"
+ # Replace with a valid formula for the next version
+ formula_file = setup_test_formula "testball"
contents = File.read(formula_file)
contents.gsub!("testball-0.1", "testball-0.2")
File.write(formula_file, contents) | true |
Other | Homebrew | brew | ae788550f9b5599e308b7f3b7ff8bef96c4387e6.json | Show replacement command in `odeprecated`
Co-authored-by: Rylan Polster <rslpolster@gmail.com> | Library/Homebrew/dev-cmd/pr-automerge.rb | @@ -43,7 +43,7 @@ def pr_automerge_args
def pr_automerge
args = pr_automerge_args.parse
- odeprecated "`brew pr-automerge --autosquash`" if args.autosquash?
+ odeprecated "`brew pr-automerge --autosquash`", "`brew pr-automerge`" if args.autosquash?
without_labels = args.without_labels || [
"do not merge", | true |
Other | Homebrew | brew | ae788550f9b5599e308b7f3b7ff8bef96c4387e6.json | Show replacement command in `odeprecated`
Co-authored-by: Rylan Polster <rslpolster@gmail.com> | Library/Homebrew/dev-cmd/pr-publish.rb | @@ -43,7 +43,7 @@ def pr_publish
workflow = args.workflow || "publish-commit-bottles.yml"
ref = args.branch || "master"
- odeprecated "`brew pr-publish --autosquash`" if args.autosquash?
+ odeprecated "`brew pr-publish --autosquash`", "`brew pr-publish`" if args.autosquash?
extra_args = []
extra_args << "--autosquash" unless args.no_autosquash? | true |
Other | Homebrew | brew | 9370c7cca702b9535b78f328b60a14bb70bbc15d.json | Fix logic error in pr-automerge
Co-authored-by: Rylan Polster <rslpolster@gmail.com> | Library/Homebrew/dev-cmd/pr-automerge.rb | @@ -76,7 +76,7 @@ def pr_automerge
publish_args = ["pr-publish"]
publish_args << "--tap=#{tap}" if tap
- publish_args << "--autosquash" unless args.no_autosquash?
+ publish_args << "--no-autosquash" if args.no_autosquash?
if args.publish?
safe_system HOMEBREW_BREW_FILE, *publish_args, *pr_urls
else | false |
Other | Homebrew | brew | 75a38b7187788b61461a0b76b7033bf96a33c1c1.json | refactor the format | Library/Homebrew/cask/quarantine.rb | @@ -31,7 +31,7 @@ def xattr
def check_quarantine_support
odebug "Checking quarantine support"
- if !system_command(xattr, args:[ "-h" ], print_stderr: false).success?
+ if !system_command(xattr, args: ["-h"], print_stderr: false).success?
odebug "There's no working version of `xattr` on this system."
:xattr_broken
elsif swift.nil? | true |
Other | Homebrew | brew | 75a38b7187788b61461a0b76b7033bf96a33c1c1.json | refactor the format | Library/Homebrew/diagnostic.rb | @@ -1000,7 +1000,7 @@ def check_cask_environment_variables
end
def check_cask_xattr
- result = system_command "/usr/bin/xattr", args: [ "-h" ]
+ result = system_command "/usr/bin/xattr", args: ["-h"]
return if result.status.success?
| true |
Other | Homebrew | brew | 654d10d6d3bec8775d836ae04266cdbac224e0dc.json | Fix more typos
Co-authored-by: Rylan Polster <rslpolster@gmail.com> | Library/Homebrew/dev-cmd/pr-automerge.rb | @@ -31,7 +31,7 @@ def pr_automerge_args
description: "Instruct `brew pr-publish` to automatically reformat and reword commits "\
"in the pull request to our preferred format."
switch "--no-autosquash",
- description: "Instruct `brew pr-publish` to skip automatically reformattin and rewording commits "\
+ description: "Instruct `brew pr-publish` to skip automatically reformatting and rewording commits "\
"in the pull request to the preferred format."
switch "--ignore-failures",
description: "Include pull requests that have failing status checks." | false |
Other | Homebrew | brew | 5b7921ff68abcd3a4f9063cd8671299ffcf8f2d1.json | Add support for GitHub Oauth tokens from keychain | Library/Homebrew/utils/github/api.rb | @@ -21,7 +21,7 @@ module GitHub
#{ALL_SCOPES_URL}
#{Utils::Shell.set_variable_in_profile("HOMEBREW_GITHUB_API_TOKEN", "your_token_here")}
EOS
- GITHUB_PERSONAL_ACCESS_TOKEN_REGEX = /^(?:[a-f0-9]{40}|ghp_\w{36,251})$/.freeze
+ GITHUB_PERSONAL_ACCESS_TOKEN_REGEX = /^(?:[a-f0-9]{40}|gh[po]_\w{36,251})$/.freeze
# Helper functions to access the GitHub API.
# | false |
Other | Homebrew | brew | 488ccfdf70762127bd21f36492748d407b3e9fc6.json | formula_cellar_checks: check keg for mismatched arches
There have been a few instances I've noticed that we've been silently
installing binaries built for x86_64 on ARM. There's probably more that
I haven't found yet, so it seems useful to check this with an audit. | Library/Homebrew/formula_cellar_checks.rb | @@ -314,6 +314,22 @@ def check_cpuid_instruction(formula)
"No `cpuid` instruction detected. #{formula} should not use `ENV.runtime_cpu_detection`."
end
+ def check_binary_arches(formula)
+ return unless formula.prefix.directory?
+
+ keg = Keg.new(formula.prefix)
+ mismatches = keg.binary_executable_or_library_files.reject do |file|
+ file.arch == Hardware::CPU.arch
+ end
+ return if mismatches.empty?
+
+ <<~EOS
+ Binaries built for a non-native architecture were installed into #{formula}'s prefix.
+ The offending files are:
+ #{mismatches * "\n "}
+ EOS
+ end
+
def audit_installed
@new_formula ||= false
@@ -334,6 +350,7 @@ def audit_installed
problem_if_output(check_plist(formula.prefix, formula.plist))
problem_if_output(check_python_symlinks(formula.name, formula.keg_only?))
problem_if_output(check_cpuid_instruction(formula))
+ problem_if_output(check_binary_arches(formula))
end
alias generic_audit_installed audit_installed
| true |
Other | Homebrew | brew | 488ccfdf70762127bd21f36492748d407b3e9fc6.json | formula_cellar_checks: check keg for mismatched arches
There have been a few instances I've noticed that we've been silently
installing binaries built for x86_64 on ARM. There's probably more that
I haven't found yet, so it seems useful to check this with an audit. | Library/Homebrew/os/mac/mach.rb | @@ -29,7 +29,7 @@ def mach_data
machos.each do |m|
arch = case m.cputype
- when :x86_64, :i386, :ppc64 then m.cputype
+ when :x86_64, :i386, :ppc64, :arm64, :arm then m.cputype
when :ppc then :ppc7400
else :dunno
end | true |
Other | Homebrew | brew | 2888d050f78f047fb82ec97709483978b6d74728.json | reject build and test dependency | Library/Homebrew/cask_dependent.rb | @@ -16,8 +16,9 @@ def full_name
end
def runtime_dependencies(ignore_missing: false)
- recursive_dependencies(ignore_missing: ignore_missing).select do |dependency|
- dependency.tags.blank?
+ recursive_dependencies(ignore_missing: ignore_missing).reject do |dependency|
+ tags = dependency.tags
+ tags.include?(:build) || tags.include?(:test)
end
end
| false |
Other | Homebrew | brew | 5de162f71a288c7c4b2e02a7c1b99f720036d930.json | installed_dependents: reject build formula | Library/Homebrew/installed_dependents.rb | @@ -51,7 +51,9 @@ def find_some_installed_dependents(kegs, casks: [])
dependent.missing_dependencies(hide: keg_names)
when Cask::Cask
# When checking for cask dependents, we don't care about missing dependencies
- CaskDependent.new(dependent).runtime_dependencies(ignore_missing: true).map(&:to_formula)
+ CaskDependent.new(dependent).runtime_dependencies(ignore_missing: true).reject do |dependency|
+ dependency.tags.include?(:build)
+ end.map(&:to_formula)
end
required_kegs = required.map do |f| | false |
Other | Homebrew | brew | c9ddbc3780d76966fd410b662df1438c9aa4561f.json | Update RBI files for rubocop-ast. | Library/Homebrew/sorbet/rbi/gems/rubocop-ast@1.8.0.rbi | @@ -364,6 +364,7 @@ RuboCop::AST::Builder::NODE_MAP = T.let(T.unsafe(nil), Hash)
class RuboCop::AST::CaseMatchNode < ::RuboCop::AST::Node
include ::RuboCop::AST::ConditionalNode
+ def branches; end
def each_in_pattern(&block); end
def else?; end
def else_branch; end
@@ -1637,10 +1638,12 @@ RuboCop::AST::NodePattern::Sets::SET_ATTR_READER_ATTR_WRITER_ATTR_ACCESSOR = T.l
RuboCop::AST::NodePattern::Sets::SET_ATTR_READER_ATTR_WRITER_ATTR_ACCESSOR_ATTR = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_BACKGROUND_SCENARIO_XSCENARIO_ETC = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_BEFORE_AFTER = T.let(T.unsafe(nil), Set)
+RuboCop::AST::NodePattern::Sets::SET_BEGINNING_OF_DAY_BEGINNING_OF_WEEK_BEGINNING_OF_MONTH_ETC = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_BELONGS_TO_HAS_ONE_HAS_MANY_HAS_AND_BELONGS_TO_MANY = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_BE_EQ_EQL_EQUAL = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_BE_TRUTHY_BE_FALSEY_BE_FALSY_ETC = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_BINWRITE_SYSWRITE_WRITE_WRITE_NONBLOCK = T.let(T.unsafe(nil), Set)
+RuboCop::AST::NodePattern::Sets::SET_BRANCH_REF_TAG = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_CALLER_CALLER_LOCATIONS = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_CALL_RUN = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_CAPTURE2_CAPTURE2E_CAPTURE3_ETC = T.let(T.unsafe(nil), Set)
@@ -1662,14 +1665,15 @@ RuboCop::AST::NodePattern::Sets::SET_DOWNCASE_UPCASE = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_EACH_EXAMPLE = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_EACH_WITH_INDEX_WITH_INDEX = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_EACH_WITH_OBJECT_WITH_OBJECT = T.let(T.unsafe(nil), Set)
+RuboCop::AST::NodePattern::Sets::SET_END_OF_DAY_END_OF_WEEK_END_OF_MONTH_ETC = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_ENUMERATOR_RATIONAL_COMPLEX_THREAD = T.let(T.unsafe(nil), Set)
+RuboCop::AST::NodePattern::Sets::SET_EQL_EQ_BE = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_ESCAPE_ENCODE_UNESCAPE_DECODE = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_EXACTLY_AT_LEAST_AT_MOST = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_EXECUTE_REMOVE_BELONGS_TO = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_EXPECT_ALLOW = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_FACTORYGIRL_FACTORYBOT = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_FIRST_LAST__ETC = T.let(T.unsafe(nil), Set)
-RuboCop::AST::NodePattern::Sets::SET_FIRST_TAKE = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_FIXNUM_BIGNUM = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_FLATTEN_FLATTEN = T.let(T.unsafe(nil), Set)
RuboCop::AST::NodePattern::Sets::SET_FORMAT_SPRINTF_PRINTF = T.let(T.unsafe(nil), Set) | true |
Other | Homebrew | brew | c9ddbc3780d76966fd410b662df1438c9aa4561f.json | Update RBI files for rubocop-ast. | Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi | @@ -26895,12 +26895,8 @@ class RuboCop::AST::NodePattern::Parser
end
module RuboCop::AST::NodePattern::Sets
- SET_BEGINNING_OF_DAY_BEGINNING_OF_WEEK_BEGINNING_OF_MONTH_ETC = ::T.let(nil, ::T.untyped)
- SET_BRANCH_REF_TAG = ::T.let(nil, ::T.untyped)
SET_BUILD_RECOMMENDED_TEST_OPTIONAL = ::T.let(nil, ::T.untyped)
SET_DEPENDS_ON_USES_FROM_MACOS = ::T.let(nil, ::T.untyped)
- SET_END_OF_DAY_END_OF_WEEK_END_OF_MONTH_ETC = ::T.let(nil, ::T.untyped)
- SET_EQL_EQ_BE = ::T.let(nil, ::T.untyped)
SET_INCLUDE_WITH_WITHOUT = ::T.let(nil, ::T.untyped)
SET_SYSTEM_SHELL_OUTPUT_PIPE_OUTPUT = ::T.let(nil, ::T.untyped)
SET_WITH_WITHOUT = ::T.let(nil, ::T.untyped) | true |
Other | Homebrew | brew | 5649d339d7861f197b06f7f35c8bfdf46fdd217e.json | Show message when developer mode is turned on | Library/Homebrew/brew.rb | @@ -93,6 +93,13 @@ class MissingEnvironmentVariables < RuntimeError; end
internal_cmd ||= begin
internal_dev_cmd = Commands.valid_internal_dev_cmd?(cmd)
if internal_dev_cmd && !Homebrew::EnvConfig.developer?
+ opoo <<~MESSAGE if ENV["HOMEBREW_DEV_CMD_RUN"].blank?
+ #{Tty.bold}#{cmd}#{Tty.reset} is a developer command, so
+ Homebrew's developer mode has been automatically turned on.
+ To turn developer mode off, run #{Tty.bold}brew developer off#{Tty.reset}
+
+ MESSAGE
+
Homebrew::Settings.write "devcmdrun", true
ENV["HOMEBREW_DEV_CMD_RUN"] = "1"
end | true |
Other | Homebrew | brew | 5649d339d7861f197b06f7f35c8bfdf46fdd217e.json | Show message when developer mode is turned on | Library/Homebrew/brew.sh | @@ -81,6 +81,30 @@ ohai() {
fi
}
+opoo() {
+ if [[ -n "${HOMEBREW_COLOR}" || (-t 2 && -z "${HOMEBREW_NO_COLOR}") ]] # check whether stderr is a tty.
+ then
+ echo -ne "\\033[4;33mWarning\\033[0m: " >&2 # highlight Warning with underline and yellow color
+ else
+ echo -n "Warning: " >&2
+ fi
+ if [[ $# -eq 0 ]]
+ then
+ cat >&2
+ else
+ echo "$*" >&2
+ fi
+}
+
+bold() {
+ if [[ -n "${HOMEBREW_COLOR}" || (-t 2 && -z "${HOMEBREW_NO_COLOR}") ]] # check whether stderr is a tty.
+ then
+ echo -e "\\033[1m""$*""\\033[0m"
+ else
+ echo "$*"
+ fi
+}
+
onoe() {
if [[ -n "${HOMEBREW_COLOR}" || (-t 2 && -z "${HOMEBREW_NO_COLOR}") ]] # check whether stderr is a tty.
then
@@ -621,6 +645,15 @@ elif [[ -f "${HOMEBREW_LIBRARY}/Homebrew/dev-cmd/${HOMEBREW_COMMAND}.sh" ]]
then
if [[ -z "${HOMEBREW_DEVELOPER}" ]]
then
+ if [[ -z "${HOMEBREW_DEV_CMD_RUN}" ]]
+ then
+ message="$(bold ${HOMEBREW_COMMAND}) is a developer command, so
+Homebrew's developer mode has been automatically turned on.
+To turn developer mode off, run $(bold "brew developer off")
+"
+ opoo "${message}"
+ fi
+
git config --file="${HOMEBREW_GIT_CONFIG_FILE}" --replace-all homebrew.devcmdrun true 2>/dev/null
export HOMEBREW_DEV_CMD_RUN="1"
fi | true |
Other | Homebrew | brew | 82c57566904147393065d06ff30ecdb899470c6e.json | dev-cmd/bottle: use native Ruby.
Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> | Library/Homebrew/dev-cmd/bottle.rb | @@ -400,7 +400,7 @@ def bottle_formula(f, args:)
# Set the times for reproducible bottles.
if file.symlink?
# Need to make symlink permissions consistent on macOS and Linux
- system "chmod", "-h", "0777", file if OS.mac?
+ File.lchmod 0777, file if OS.mac?
File.lutime(tab.source_modified_time, tab.source_modified_time, file)
else
file.utime(tab.source_modified_time, tab.source_modified_time) | false |
Other | Homebrew | brew | 41b0bf7bbb84495c82987f2fba7cf029d8abef11.json | Add `developer` command | Library/Homebrew/cmd/developer.rb | @@ -0,0 +1,53 @@
+# typed: true
+# frozen_string_literal: true
+
+require "cli/parser"
+
+module Homebrew
+ extend T::Sig
+
+ module_function
+
+ sig { returns(CLI::Parser) }
+ def developer_args
+ Homebrew::CLI::Parser.new do
+ description <<~EOS
+ Control Homebrew's developer mode. When developer mode is enabled,
+ `brew update` will update Homebrew to the latest commit on the `master`
+ branch instead of the latest stable version.
+
+ `brew developer` [`state`]:
+ Display the current state of Homebrew's developer mode.
+
+ `brew developer` (`on`|`off`):
+ Turn Homebrew's developer mode on or off respectively.
+ EOS
+
+ named_args %w[state on off], max: 1
+ end
+ end
+
+ def developer
+ args = developer_args.parse
+
+ case args.named.first
+ when nil, "state"
+ if Homebrew::EnvConfig.developer?
+ puts "Developer mode is enabled because #{Tty.bold}HOMEBREW_DEVELOPER#{Tty.reset} it set."
+ elsif Homebrew::Settings.read("devcmdrun") == "true"
+ puts "Developer mode is enabled."
+ else
+ puts "Developer mode is disabled."
+ end
+ when "on"
+ Homebrew::Settings.write "devcmdrun", true
+ when "off"
+ Homebrew::Settings.delete "devcmdrun"
+ if Homebrew::EnvConfig.developer?
+ puts "To fully disable developer mode, you must unset #{Tty.bold}HOMEBREW_DEVELOPER#{Tty.reset}."
+ end
+ else
+ raise UsageError, "unknown subcommand: #{args.named.first}"
+ end
+ end
+end | true |
Other | Homebrew | brew | 41b0bf7bbb84495c82987f2fba7cf029d8abef11.json | Add `developer` command | Library/Homebrew/test/cmd/developer_spec.rb | @@ -0,0 +1,8 @@
+# typed: false
+# frozen_string_literal: true
+
+require "cmd/shared_examples/args_parse"
+
+describe "brew developer" do
+ it_behaves_like "parseable arguments"
+end | true |
Other | Homebrew | brew | 41b0bf7bbb84495c82987f2fba7cf029d8abef11.json | Add `developer` command | completions/bash/brew | @@ -745,6 +745,23 @@ _brew_desc() {
__brew_complete_formulae
}
+_brew_developer() {
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "${cur}" in
+ -*)
+ __brewcomp "
+ --debug
+ --help
+ --quiet
+ --verbose
+ "
+ return
+ ;;
+ *)
+ esac
+ __brewcomp "state on off"
+}
+
_brew_dispatch_build_bottle() {
local cur="${COMP_WORDS[COMP_CWORD]}"
case "${cur}" in
@@ -2416,6 +2433,7 @@ _brew() {
create) _brew_create ;;
deps) _brew_deps ;;
desc) _brew_desc ;;
+ developer) _brew_developer ;;
dispatch-build-bottle) _brew_dispatch_build_bottle ;;
doctor) _brew_doctor ;;
dr) _brew_dr ;; | true |
Other | Homebrew | brew | 41b0bf7bbb84495c82987f2fba7cf029d8abef11.json | Add `developer` command | completions/fish/brew.fish | @@ -577,6 +577,16 @@ __fish_brew_complete_arg 'desc' -l verbose -d 'Make some output more verbose'
__fish_brew_complete_arg 'desc' -a '(__fish_brew_suggest_formulae_all)'
+__fish_brew_complete_cmd 'developer' 'Control Homebrew\'s developer mode'
+__fish_brew_complete_sub_cmd 'developer' 'state'
+__fish_brew_complete_sub_cmd 'developer' 'on'
+__fish_brew_complete_sub_cmd 'developer' 'off'
+__fish_brew_complete_arg 'developer' -l debug -d 'Display any debugging information'
+__fish_brew_complete_arg 'developer' -l help -d 'Show this message'
+__fish_brew_complete_arg 'developer' -l quiet -d 'Make some output more quiet'
+__fish_brew_complete_arg 'developer' -l verbose -d 'Make some output more verbose'
+
+
__fish_brew_complete_cmd 'dispatch-build-bottle' 'Build bottles for these formulae with GitHub Actions'
__fish_brew_complete_arg 'dispatch-build-bottle' -l debug -d 'Display any debugging information'
__fish_brew_complete_arg 'dispatch-build-bottle' -l help -d 'Show this message' | true |
Other | Homebrew | brew | 41b0bf7bbb84495c82987f2fba7cf029d8abef11.json | Add `developer` command | completions/internal_commands_list.txt | @@ -30,6 +30,7 @@ configure
create
deps
desc
+developer
dispatch-build-bottle
doctor
dr | true |
Other | Homebrew | brew | 41b0bf7bbb84495c82987f2fba7cf029d8abef11.json | Add `developer` command | completions/zsh/_brew | @@ -155,6 +155,7 @@ __brew_internal_commands() {
'create:Generate a formula or, with `--cask`, a cask for the downloadable file at URL and open it in the editor'
'deps:Show dependencies for formula'
'desc:Display formula'\''s name and one-line description'
+ 'developer:Control Homebrew'\''s developer mode'
'dispatch-build-bottle:Build bottles for these formulae with GitHub Actions'
'doctor:Check your system for potential problems'
'edit:Open a formula or cask in the editor set by `EDITOR` or `HOMEBREW_EDITOR`, or open the Homebrew repository for editing if no formula is provided'
@@ -709,6 +710,17 @@ _brew_desc() {
'*::formula:__brew_formulae'
}
+# brew developer
+_brew_developer() {
+ _arguments \
+ '--debug[Display any debugging information]' \
+ '--help[Show this message]' \
+ '--quiet[Make some output more quiet]' \
+ '--verbose[Make some output more verbose]' \
+ - subcommand \
+ '*::subcommand:(state on off)'
+}
+
# brew dispatch-build-bottle
_brew_dispatch_build_bottle() {
_arguments \ | true |
Other | Homebrew | brew | 41b0bf7bbb84495c82987f2fba7cf029d8abef11.json | Add `developer` command | docs/Manpage.md | @@ -184,6 +184,18 @@ first search, making that search slower than subsequent ones.
* `-d`, `--description`:
Search just descriptions for *`text`*. If *`text`* is flanked by slashes, it is interpreted as a regular expression.
+### `developer` [*`subcommand`*]
+
+Control Homebrew's developer mode. When developer mode is enabled,
+`brew update` will update Homebrew to the latest commit on the `master`
+branch instead of the latest stable version.
+
+`brew developer` [`state`]
+<br>Display the current state of Homebrew's developer mode.
+
+`brew developer` (`on`|`off`)
+<br>Turn Homebrew's developer mode on or off respectively.
+
### `doctor`, `dr` [*`--list-checks`*] [*`--audit-debug`*] [*`diagnostic_check`* ...]
Check your system for potential problems. Will exit with a non-zero status | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.