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
eedd108acec7e94724b226c85e7c651d9b9623ae.json
PageMatch: Return fetched content in match_data If we want caching to work in the `Xorg` strategy, it's necessary to pass fetched content back in the `match_data` hash.
Library/Homebrew/livecheck/strategy/page_match.rb
@@ -92,7 +92,7 @@ def self.find_versions(url, regex, provided_content = nil, &block) provided_content else match_data.merge!(Strategy.page_content(url)) - match_data.delete(:content) + match_data[:content] end return match_data if content.blank?
false
Other
Homebrew
brew
9bc1326ac2b8a509d7bed4f6f44848a3e0f0c98c.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
@@ -7851,6 +7851,11 @@ class Homebrew::Livecheck::Strategy::HeaderMatch extend ::T::Private::Methods::SingletonMethodHooks end +class Homebrew::Livecheck::Strategy::PageMatch + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + class Homebrew::Livecheck::Strategy::Sparkle::Item def self.[](*_); end @@ -7862,6 +7867,11 @@ class Homebrew::Livecheck::Strategy::Sparkle extend ::T::Private::Methods::SingletonMethodHooks end +module Homebrew::Livecheck::Strategy + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + module Homebrew::Livecheck extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks
false
Other
Homebrew
brew
a0e663d833f9a320cd50ab63d6b904b4fdd5f51b.json
update: show either changelog or release noted link
Library/Homebrew/cmd/update-report.rb
@@ -89,8 +89,7 @@ def update_report puts "Updated Homebrew from #{shorten_revision(initial_revision)} to #{shorten_revision(current_revision)}." updated = true - tag = Utils.safe_popen_read("git", "tag", "--points-at", "HEAD") - new_repository_version = tag.chomp if tag.present? + new_repository_version = Utils.safe_popen_read("git", "tag", "--points-at", "HEAD").chomp.presence end Homebrew.failed = true if ENV["HOMEBREW_UPDATE_FAILED"] @@ -144,17 +143,17 @@ def update_report return if new_repository_version.blank? ohai "Homebrew was updated to version #{new_repository_version}" - puts <<~EOS - The changelog can be found at: - #{Formatter.url("https://github.com/Homebrew/brew/releases/tag/#{new_repository_version}")} - EOS - - return unless new_repository_version.split(".").last == "0" - - puts <<~EOS - More detailed release notes are available on the Homebrew Blog: - #{Formatter.url("https://brew.sh/blog/")} - EOS + if new_repository_version.split(".").last == "0" + puts <<~EOS + More detailed release notes are available on the Homebrew Blog: + #{Formatter.url("https://brew.sh/blog/")} + EOS + else + puts <<~EOS + The changelog can be found at: + #{Formatter.url("https://github.com/Homebrew/brew/releases/tag/#{new_repository_version}")} + EOS + end end def shorten_revision(revision)
false
Other
Homebrew
brew
13e0188187056c5f0523fdd13a5c26a085f8c61d.json
bottle_spec: reduce code duplication in tests
Library/Homebrew/test/dev-cmd/bottle_spec.rb
@@ -196,6 +196,7 @@ def stub_hash(parameters) end describe "brew bottle --merge", :integration_test, :needs_linux do + let(:core_tap) { CoreTap.new } let(:tarball) do if OS.linux? TEST_FIXTURE_DIR/"tarballs/testball-0.1-linux.tbz" @@ -204,67 +205,60 @@ def stub_hash(parameters) end end + before do + Pathname("testball-1.0.big_sur.bottle.json").write stub_hash( + "name": "testball", + "version": "1.0", + "path": "#{core_tap.path}/Formula/testball.rb", + "cellar": "any_skip_relocation", + "os": "big_sur", + "filename": "hello-1.0.big_sur.bottle.tar.gz", + "local_filename": "hello--1.0.big_sur.bottle.tar.gz", + "sha256": "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f", + ) + + Pathname("testball-1.0.catalina.bottle.json").write stub_hash( + "name": "testball", + "version": "1.0", + "path": "#{core_tap.path}/Formula/testball.rb", + "cellar": "any_skip_relocation", + "os": "catalina", + "filename": "testball-1.0.catalina.bottle.tar.gz", + "local_filename": "testball--1.0.catalina.bottle.tar.gz", + "sha256": "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac", + ) + end + + after do + FileUtils.rm_f "testball-1.0.catalina.bottle.json" + FileUtils.rm_f "testball-1.0.big_sur.bottle.json" + end + it "adds the bottle block to a formula that has none" do - core_tap = CoreTap.new core_tap.path.cd do system "git", "init" setup_test_formula "testball" system "git", "add", "--all" system "git", "commit", "-m", "testball 0.1" end - begin - Pathname("testball-1.0.big_sur.bottle.json").write( - stub_hash( - { - "name": "testball", - "version": "1.0", - "path": "#{core_tap.path}/Formula/testball.rb", - "cellar": "any_skip_relocation", - "os": "big_sur", - "filename": "hello-1.0.big_sur.bottle.tar.gz", - "local_filename": "hello--1.0.big_sur.bottle.tar.gz", - "sha256": "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f", - }, - ), - ) - - Pathname("testball-1.0.catalina.bottle.json").write( - stub_hash( - { - "name": "testball", - "version": "1.0", - "path": "#{core_tap.path}/Formula/testball.rb", - "cellar": "any_skip_relocation", - "os": "catalina", - "filename": "testball-1.0.catalina.bottle.tar.gz", - "local_filename": "testball--1.0.catalina.bottle.tar.gz", - "sha256": "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac", - }, - ), - ) - - expect { - brew "bottle", - "--merge", - "--write", - "testball-1.0.big_sur.bottle.json", - "testball-1.0.catalina.bottle.json" - }.to output( - <<~EOS, - ==> testball - bottle do - root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}" - cellar :any_skip_relocation - sha256 "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f" => :big_sur - sha256 "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac" => :catalina - end - EOS - ).to_stdout - ensure - FileUtils.rm_f "testball-1.0.catalina.bottle.json" - FileUtils.rm_f "testball-1.0.big_sur.bottle.json" - end + expect { + brew "bottle", + "--merge", + "--write", + "testball-1.0.big_sur.bottle.json", + "testball-1.0.catalina.bottle.json" + }.to output( + <<~EOS, + ==> testball + bottle do + root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}" + cellar :any_skip_relocation + sha256 "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f" => :big_sur + sha256 "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac" => :catalina + end + EOS + ).to_stdout expect((core_tap.path/"Formula/testball.rb").read).to eq( <<~EOS, @@ -302,7 +296,6 @@ def install end it "replaces the bottle block in a formula that already has a bottle block" do - core_tap = CoreTap.new core_tap.path.cd do system "git", "init" bottle_block = <<~EOS @@ -319,58 +312,23 @@ def install system "git", "commit", "-m", "testball 0.1" end - begin - Pathname("testball-1.0.big_sur.bottle.json").write( - stub_hash( - { - "name": "testball", - "version": "1.0", - "path": "#{core_tap.path}/Formula/testball.rb", - "cellar": "any_skip_relocation", - "os": "big_sur", - "filename": "hello-1.0.big_sur.bottle.tar.gz", - "local_filename": "hello--1.0.big_sur.bottle.tar.gz", - "sha256": "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f", - }, - ), - ) - - Pathname("testball-1.0.catalina.bottle.json").write( - stub_hash( - { - "name": "testball", - "version": "1.0", - "path": "#{core_tap.path}/Formula/testball.rb", - "cellar": "any_skip_relocation", - "os": "catalina", - "filename": "testball-1.0.catalina.bottle.tar.gz", - "local_filename": "testball--1.0.catalina.bottle.tar.gz", - "sha256": "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac", - }, - ), - ) - - expect { - brew "bottle", - "--merge", - "--write", - "testball-1.0.big_sur.bottle.json", - "testball-1.0.catalina.bottle.json" - }.to output( - <<~EOS, - ==> testball - bottle do - root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}" - cellar :any_skip_relocation - sha256 "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f" => :big_sur - sha256 "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac" => :catalina - end - EOS - ).to_stdout - ensure - FileUtils.rm_f "testball-1.0.catalina.bottle.json" - FileUtils.rm_f "testball-1.0.big_sur.bottle.json" - end + expect { + brew "bottle", + "--merge", + "--write", + "testball-1.0.big_sur.bottle.json", + "testball-1.0.catalina.bottle.json" + }.to output( + <<~EOS, + ==> testball + bottle do + root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}" + cellar :any_skip_relocation + sha256 "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f" => :big_sur + sha256 "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac" => :catalina + end + EOS + ).to_stdout expect((core_tap.path/"Formula/testball.rb").read).to eq( <<~EOS, @@ -408,61 +366,24 @@ def install end it "fails to add the bottle block to a formula that has no bottle block when using --keep-old" do - core_tap = CoreTap.new core_tap.path.cd do system "git", "init" setup_test_formula("testball") system "git", "add", "--all" system "git", "commit", "-m", "testball 0.1" end - begin - Pathname("testball-1.0.big_sur.bottle.json").write( - stub_hash( - { - "name": "testball", - "version": "1.0", - "path": "#{core_tap.path}/Formula/testball.rb", - "cellar": "any_skip_relocation", - "os": "big_sur", - "filename": "hello-1.0.big_sur.bottle.tar.gz", - "local_filename": "hello--1.0.big_sur.bottle.tar.gz", - "sha256": "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f", - }, - ), - ) - - Pathname("testball-1.0.catalina.bottle.json").write( - stub_hash( - { - "name": "testball", - "version": "1.0", - "path": "#{core_tap.path}/Formula/testball.rb", - "cellar": "any_skip_relocation", - "os": "catalina", - "filename": "testball-1.0.catalina.bottle.tar.gz", - "local_filename": "testball--1.0.catalina.bottle.tar.gz", - "sha256": "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac", - }, - ), - ) - - expect { - brew "bottle", - "--merge", - "--write", - "--keep-old", - "testball-1.0.big_sur.bottle.json", - "testball-1.0.catalina.bottle.json" - }.to output("Error: --keep-old was passed but there was no existing bottle block!\n").to_stderr - ensure - FileUtils.rm_f "testball-1.0.catalina.bottle.json" - FileUtils.rm_f "testball-1.0.big_sur.bottle.json" - end + expect { + brew "bottle", + "--merge", + "--write", + "--keep-old", + "testball-1.0.big_sur.bottle.json", + "testball-1.0.catalina.bottle.json" + }.to output("Error: --keep-old was passed but there was no existing bottle block!\n").to_stderr end it "updates the bottle block in a formula that already has a bottle block when using --keep-old" do - core_tap = CoreTap.new core_tap.path.cd do system "git", "init" bottle_block = <<~EOS @@ -478,60 +399,25 @@ def install system "git", "commit", "-m", "testball 0.1" end - begin - Pathname("testball-1.0.big_sur.bottle.json").write( - stub_hash( - { - "name": "testball", - "version": "1.0", - "path": "#{core_tap.path}/Formula/testball.rb", - "cellar": "any_skip_relocation", - "os": "big_sur", - "filename": "hello-1.0.big_sur.bottle.tar.gz", - "local_filename": "hello--1.0.big_sur.bottle.tar.gz", - "sha256": "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f", - }, - ), - ) - - Pathname("testball-1.0.catalina.bottle.json").write( - stub_hash( - { - "name": "testball", - "version": "1.0", - "path": "#{core_tap.path}/Formula/testball.rb", - "cellar": "any_skip_relocation", - "os": "catalina", - "filename": "testball-1.0.catalina.bottle.tar.gz", - "local_filename": "testball--1.0.catalina.bottle.tar.gz", - "sha256": "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac", - }, - ), - ) - - expect { - brew "bottle", - "--merge", - "--write", - "--keep-old", - "testball-1.0.big_sur.bottle.json", - "testball-1.0.catalina.bottle.json" - }.to output( - <<~EOS, - ==> testball - bottle do - root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}" - cellar :any_skip_relocation - sha256 "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f" => :big_sur - sha256 "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac" => :catalina - sha256 "6971b6eebf4c00eaaed72a1104a49be63861eabc95d679a0c84040398e320059" => :high_sierra - end - EOS - ).to_stdout - ensure - FileUtils.rm_f "testball-1.0.catalina.bottle.json" - FileUtils.rm_f "testball-1.0.big_sur.bottle.json" - end + expect { + brew "bottle", + "--merge", + "--write", + "--keep-old", + "testball-1.0.big_sur.bottle.json", + "testball-1.0.catalina.bottle.json" + }.to output( + <<~EOS, + ==> testball + bottle do + root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}" + cellar :any_skip_relocation + sha256 "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f" => :big_sur + sha256 "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac" => :catalina + sha256 "6971b6eebf4c00eaaed72a1104a49be63861eabc95d679a0c84040398e320059" => :high_sierra + end + EOS + ).to_stdout expect((core_tap.path/"Formula/testball.rb").read).to eq( <<~EOS,
false
Other
Homebrew
brew
88843d2e437ba7d46c6e39659c4d07863f490deb.json
Livecheck: Fix final url spacing in debug output
Library/Homebrew/livecheck/livecheck.rb
@@ -524,7 +524,7 @@ def latest_version(formula_or_cask, json: false, full_name: false, verbose: fals if debug puts "URL (strategy): #{strategy_data[:url]}" if strategy_data[:url] != url - puts "URL (final): #{strategy_data[:final_url]}" if strategy_data[:final_url] + puts "URL (final): #{strategy_data[:final_url]}" if strategy_data[:final_url] puts "Regex (strategy): #{strategy_data[:regex].inspect}" if strategy_data[:regex] != livecheck_regex end
false
Other
Homebrew
brew
27ffa4e6e02d1108393e50b728712af74cf6b7ef.json
audit: fix prerelease audit
Library/Homebrew/utils/shared_audits.rb
@@ -43,7 +43,9 @@ def github_release(user, repo, tag, formula: nil, cask: nil) return "#{tag} is a GitHub pre-release." if release["prerelease"] && [version, "all"].exclude?(exception) - return "#{tag} is not a GitHub pre-release but '#{name}' is in the GitHub prerelease allowlist." if exception + if !release["prerelease"] && exception + return "#{tag} is not a GitHub pre-release but '#{name}' is in the GitHub prerelease allowlist." + end return "#{tag} is a GitHub draft." if release["draft"] end
false
Other
Homebrew
brew
174645fb9576c805c4900b1ff42aaf4174567a18.json
test/rubocops: improve test descriptions
Library/Homebrew/test/rubocops/caveats_spec.rb
@@ -6,8 +6,8 @@ describe RuboCop::Cop::FormulaAudit::Caveats do subject(:cop) { described_class.new } - context "When auditing caveats" do - it "When there is setuid mentioned in caveats" do + context "when auditing `caveats`" do + it "reports an offense if `setuid` is mentioned" do expect_offense(<<~RUBY) class Foo < Formula homepage "https://brew.sh/foo"
true
Other
Homebrew
brew
174645fb9576c805c4900b1ff42aaf4174567a18.json
test/rubocops: improve test descriptions
Library/Homebrew/test/rubocops/checksum_spec.rb
@@ -6,8 +6,8 @@ describe RuboCop::Cop::FormulaAudit::Checksum do subject(:cop) { described_class.new } - context "When auditing spec checksums" do - it "When the checksum is empty" do + context "when auditing spec checksums" do + it "reports an offense if a checksum is empty" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -26,7 +26,7 @@ class Foo < Formula RUBY end - it "When the checksum is not 64 characters" do + it "reports an offense if a checksum is not 64 characters" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -45,7 +45,7 @@ class Foo < Formula RUBY end - it "When the checksum has invalid chars" do + it "reports an offense if a checksum contains invalid characters" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -69,8 +69,8 @@ class Foo < Formula describe RuboCop::Cop::FormulaAudit::ChecksumCase do subject(:cop) { described_class.new } - context "When auditing spec checksums" do - it "When the checksum has upper case characters" do + context "when auditing spec checksums" do + it "reports an offense if a checksum contains uppercase letters" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -89,7 +89,7 @@ class Foo < Formula RUBY end - it "When auditing stable blocks outside spec blocks" do + it "reports an offense if a checksum outside a `stable` block contains uppercase letters" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -110,10 +110,8 @@ class Foo < Formula end RUBY end - end - context "When auditing checksum with autocorrect" do - it "When there is uppercase sha256" do + it "auto-corrects checksums that contain uppercase letters" do source = <<~RUBY class Foo < Formula url 'https://brew.sh/foo-1.0.tgz'
true
Other
Homebrew
brew
174645fb9576c805c4900b1ff42aaf4174567a18.json
test/rubocops: improve test descriptions
Library/Homebrew/test/rubocops/components_redundancy_spec.rb
@@ -6,8 +6,8 @@ describe RuboCop::Cop::FormulaAudit::ComponentsRedundancy do subject(:cop) { described_class.new } - context "When auditing formula components common errors" do - it "When url outside stable block" do + context "when auditing formula components" do + it "reports an offense if `url` is outside `stable` block" do expect_offense(<<~RUBY) class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -23,7 +23,7 @@ class Foo < Formula RUBY end - it "When both `head` and `head do` are present" do + it "reports an offense if both `head` and `head do` are present" do expect_offense(<<~RUBY) class Foo < Formula head "https://brew.sh/foo.git" @@ -35,7 +35,7 @@ class Foo < Formula RUBY end - it "When both `bottle :modifier` and `bottle do` are present" do + it "reports an offense if both `bottle :modifier` and `bottle do` are present" do expect_offense(<<~RUBY) class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -48,7 +48,7 @@ class Foo < Formula RUBY end - it "When `stable do` is present with a `head` method" do + it "reports no offenses if `stable do` is present with a `head` method" do expect_no_offenses(<<~RUBY) class Foo < Formula head "https://brew.sh/foo.git" @@ -60,7 +60,7 @@ class Foo < Formula RUBY end - it "When `stable do` is present with a `head do` block" do + it "reports no offenses if `stable do` is present with a `head do` block" do expect_no_offenses(<<~RUBY) class Foo < Formula stable do
true
Other
Homebrew
brew
174645fb9576c805c4900b1ff42aaf4174567a18.json
test/rubocops: improve test descriptions
Library/Homebrew/test/rubocops/conflicts_spec.rb
@@ -6,8 +6,8 @@ describe RuboCop::Cop::FormulaAudit::Conflicts do subject(:cop) { described_class.new } - context "When auditing conflicts_with" do - it "conflicts_with reason is capitalized" do + context "when auditing `conflicts_with`" do + it "reports an offense if reason is capitalized" do expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb") class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -18,7 +18,7 @@ class Foo < Formula RUBY end - it "conflicts_with reason ends with a period" do + it "reports an offense if reason ends with a period" do expect_offense(<<~RUBY) class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -28,7 +28,7 @@ class Foo < Formula RUBY end - it "conflicts_with in a versioned formula" do + it "reports an offense if it is present in a versioned formula" do expect_offense(<<~RUBY, "/homebrew-core/Formula/foo@2.0.rb") class FooAT20 < Formula url 'https://brew.sh/foo-2.0.tgz' @@ -38,7 +38,7 @@ class FooAT20 < Formula RUBY end - it "no conflicts_with" do + it "reports no offenses if it is not present" do expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo@2.0.rb") class FooAT20 < Formula url 'https://brew.sh/foo-2.0.tgz'
true
Other
Homebrew
brew
174645fb9576c805c4900b1ff42aaf4174567a18.json
test/rubocops: improve test descriptions
Library/Homebrew/test/rubocops/dependency_order_spec.rb
@@ -6,8 +6,8 @@ describe RuboCop::Cop::FormulaAudit::DependencyOrder do subject(:cop) { described_class.new } - context "uses_from_macos" do - it "wrong conditional uses_from_macos order" do + context "when auditing `uses_from_macos`" do + it "reports an offense if wrong conditional order" do expect_offense(<<~RUBY) class Foo < Formula homepage "https://brew.sh" @@ -19,7 +19,7 @@ class Foo < Formula RUBY end - it "wrong alphabetical uses_from_macos order" do + it "reports an offense if wrong alphabetical order" do expect_offense(<<~RUBY) class Foo < Formula homepage "https://brew.sh" @@ -43,7 +43,7 @@ class Foo < Formula RUBY end - it "wrong conditional uses_from_macos order with block" do + it "reports an offense if wrong conditional order with block" do expect_offense(<<~RUBY) class Foo < Formula homepage "https://brew.sh" @@ -62,7 +62,7 @@ class Foo < Formula RUBY end - it "correct uses_from_macos order for multiple tags" do + it "reports no offenses if correct order for multiple tags" do expect_no_offenses(<<~RUBY) class Foo < Formula homepage "https://brew.sh" @@ -75,8 +75,8 @@ class Foo < Formula end end - context "depends_on" do - it "wrong conditional depends_on order" do + context "when auditing `depends_on`" do + it "reports an offense if wrong conditional order" do expect_offense(<<~RUBY) class Foo < Formula homepage "https://brew.sh" @@ -88,7 +88,7 @@ class Foo < Formula RUBY end - it "wrong alphabetical depends_on order" do + it "reports an offense if wrong alphabetical order" do expect_offense(<<~RUBY) class Foo < Formula homepage "https://brew.sh" @@ -112,7 +112,7 @@ class Foo < Formula RUBY end - it "wrong conditional depends_on order with block" do + it "reports an offense if wrong conditional order with block" do expect_offense(<<~RUBY) class Foo < Formula homepage "https://brew.sh" @@ -131,7 +131,7 @@ class Foo < Formula RUBY end - it "correct depends_on order for multiple tags" do + it "reports no offenses if correct order for multiple tags" do expect_no_offenses(<<~RUBY) class Foo < Formula homepage "https://brew.sh" @@ -144,8 +144,8 @@ class Foo < Formula end end - context "autocorrect" do - it "wrong conditional uses_from_macos order" do + context "when auto-correcting" do + it "supports wrong conditional `uses_from_macos` order" do source = <<~RUBY class Foo < Formula homepage "https://brew.sh" @@ -168,7 +168,7 @@ class Foo < Formula expect(corrected_source).to eq(correct_source) end - it "wrong conditional depends_on order" do + it "supports wrong conditional `depends_on` order" do source = <<~RUBY class Foo < Formula homepage "https://brew.sh"
true
Other
Homebrew
brew
174645fb9576c805c4900b1ff42aaf4174567a18.json
test/rubocops: improve test descriptions
Library/Homebrew/test/rubocops/deprecate_disable_spec.rb
@@ -6,8 +6,8 @@ describe RuboCop::Cop::FormulaAudit::DeprecateDisableDate do subject(:cop) { described_class.new } - context "When auditing formula for deprecate! date:" do - it "deprecation date is not ISO 8601 compliant" do + context "when auditing `deprecate!`" do + it "reports an offense if `date` is not ISO 8601 compliant" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -17,7 +17,7 @@ class Foo < Formula RUBY end - it "deprecation date is not ISO 8601 compliant with reason" do + it "reports an offense if `date` is not ISO 8601 compliant (with `reason`)" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -27,7 +27,7 @@ class Foo < Formula RUBY end - it "deprecation date is ISO 8601 compliant" do + it "reports no offenses if `date` is ISO 8601 compliant" do expect_no_offenses(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -36,7 +36,7 @@ class Foo < Formula RUBY end - it "deprecation date is ISO 8601 compliant with reason" do + it "reports no offenses if `date` is ISO 8601 compliant (with `reason`)" do expect_no_offenses(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -45,7 +45,7 @@ class Foo < Formula RUBY end - it "no deprecation date" do + it "reports no offenses if no `date` is specified" do expect_no_offenses(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -54,7 +54,7 @@ class Foo < Formula RUBY end - it "no deprecation date with reason" do + it "reports no offenses if no `date` is specified (with `reason`)" do expect_no_offenses(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -63,7 +63,7 @@ class Foo < Formula RUBY end - it "auto corrects to ISO 8601 format" do + it "auto-corrects `date` to ISO 8601 format" do source = <<~RUBY class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -82,7 +82,7 @@ class Foo < Formula expect(new_source).to eq(corrected_source) end - it "auto corrects to ISO 8601 format with reason" do + it "auto-corrects `date` to ISO 8601 format (with `reason`)" do source = <<~RUBY class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -102,8 +102,8 @@ class Foo < Formula end end - context "When auditing formula for disable! date:" do - it "disable date is not ISO 8601 compliant" do + context "when auditing `disable!`" do + it "reports an offense if `date` is not ISO 8601 compliant" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -113,7 +113,7 @@ class Foo < Formula RUBY end - it "disable date is not ISO 8601 compliant with reason" do + it "reports an offense if `date` is not ISO 8601 compliant (with `reason`)" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -123,7 +123,7 @@ class Foo < Formula RUBY end - it "disable date is ISO 8601 compliant" do + it "reports no offenses if `date` is ISO 8601 compliant" do expect_no_offenses(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -132,7 +132,7 @@ class Foo < Formula RUBY end - it "disable date is ISO 8601 compliant with reason" do + it "reports no offenses if `date` is ISO 8601 compliant (with `reason`)" do expect_no_offenses(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -141,7 +141,7 @@ class Foo < Formula RUBY end - it "no disable date" do + it "reports no offenses if no `date` is specified" do expect_no_offenses(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -150,7 +150,7 @@ class Foo < Formula RUBY end - it "no disable date with reason" do + it "reports no offenses if no `date` is specified (with `reason`)" do expect_no_offenses(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -159,7 +159,7 @@ class Foo < Formula RUBY end - it "auto corrects to ISO 8601 format" do + it "auto-corrects `date` to ISO 8601 format" do source = <<~RUBY class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -178,7 +178,7 @@ class Foo < Formula expect(new_source).to eq(corrected_source) end - it "auto corrects to ISO 8601 format with reason" do + it "auto-corrects `date` to ISO 8601 format (with `reason`)" do source = <<~RUBY class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -202,8 +202,8 @@ class Foo < Formula describe RuboCop::Cop::FormulaAudit::DeprecateDisableReason do subject(:cop) { described_class.new } - context "When auditing formula for deprecate! because:" do - it "deprecation reason is acceptable" do + context "when auditing `deprecate!`" do + it "reports no offenses if `reason` is acceptable" do expect_no_offenses(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -212,7 +212,7 @@ class Foo < Formula RUBY end - it "deprecation reason is acceptable as a symbol" do + it "reports no offenses if `reason` is acceptable as a symbol" do expect_no_offenses(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -221,7 +221,7 @@ class Foo < Formula RUBY end - it "deprecation reason is acceptable with date" do + it "reports no offenses if `reason` is acceptable (with `date`)" do expect_no_offenses(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -230,7 +230,7 @@ class Foo < Formula RUBY end - it "deprecation reason is acceptable as a symbol with date" do + it "reports no offenses if `reason` is acceptable as a symbol (with `date`)" do expect_no_offenses(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -239,7 +239,7 @@ class Foo < Formula RUBY end - it "deprecation reason is absent" do + it "reports an offense if `reason` is absent" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -249,7 +249,7 @@ class Foo < Formula RUBY end - it "deprecation reason is absent with date" do + it "reports an offense if `reason` is absent (with `date`)" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -259,7 +259,7 @@ class Foo < Formula RUBY end - it "deprecation reason starts with `it`" do + it "reports an offense if `reason` starts with 'it'" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -269,7 +269,7 @@ class Foo < Formula RUBY end - it "deprecation reason starts with `it` with date" do + it "reports an offense if `reason` starts with 'it' (with `date`)" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -279,7 +279,7 @@ class Foo < Formula RUBY end - it "deprecation reason ends with a period" do + it "reports an offense if `reason` ends with a period" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -289,7 +289,7 @@ class Foo < Formula RUBY end - it "deprecation reason ends with an exclamation point" do + it "reports an offense if `reason` ends with an exclamation point" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -299,7 +299,7 @@ class Foo < Formula RUBY end - it "deprecation reason ends with a question mark" do + it "reports an offense if `reason` ends with a question mark" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -309,7 +309,7 @@ class Foo < Formula RUBY end - it "deprecation reason ends with a period with date" do + it "reports an offense if `reason` ends with a period (with `date`)" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -319,7 +319,7 @@ class Foo < Formula RUBY end - it "auto corrects to remove `it`" do + it "auto-corrects `reason` to remove 'it'" do source = <<~RUBY class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -338,7 +338,7 @@ class Foo < Formula expect(new_source).to eq(corrected_source) end - it "auto corrects to remove punctuation" do + it "auto-corrects `reason` to remove punctuation" do source = <<~RUBY class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -358,8 +358,8 @@ class Foo < Formula end end - context "When auditing formula for disable! because:" do - it "disable reason is acceptable" do + context "when auditing `disable!`" do + it "reports no offenses if `reason` is acceptable" do expect_no_offenses(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -368,7 +368,7 @@ class Foo < Formula RUBY end - it "disable reason is acceptable as a symbol" do + it "reports no offenses if `reason` is acceptable as a symbol" do expect_no_offenses(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -377,7 +377,7 @@ class Foo < Formula RUBY end - it "disable reason is acceptable with date" do + it "reports no offenses if `reason` is acceptable (with `date`)" do expect_no_offenses(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -386,7 +386,7 @@ class Foo < Formula RUBY end - it "disable reason is acceptable as a symbol with date" do + it "reports no offenses if `reason` is acceptable as a symbol (with `date`)" do expect_no_offenses(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -395,7 +395,7 @@ class Foo < Formula RUBY end - it "disable reason is absent" do + it "reports an offense if `reason` is absent" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -405,7 +405,7 @@ class Foo < Formula RUBY end - it "disable reason is absent with date" do + it "reports an offense if `reason` is absent (with `date`)" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -415,7 +415,7 @@ class Foo < Formula RUBY end - it "disable reason starts with `it`" do + it "reports an offense if `reason` starts with 'it'" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -425,7 +425,7 @@ class Foo < Formula RUBY end - it "disable reason starts with `it` with date" do + it "reports an offense if `reason` starts with 'it' (with `date`)" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -435,7 +435,7 @@ class Foo < Formula RUBY end - it "disable reason ends with a period" do + it "reports an offense if `reason` ends with a period" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -445,7 +445,7 @@ class Foo < Formula RUBY end - it "disable reason ends with an exclamation point" do + it "reports an offense if `reason` ends with an exclamation point" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -455,7 +455,7 @@ class Foo < Formula RUBY end - it "disable reason ends with a question mark" do + it "reports an offense if `reason` ends with a question mark" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -465,7 +465,7 @@ class Foo < Formula RUBY end - it "disable reason ends with a period with date" do + it "reports an offense if `reason` ends with a period (with `date`)" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -475,7 +475,7 @@ class Foo < Formula RUBY end - it "auto corrects to remove `it`" do + it "auto-corrects to remove 'it'" do source = <<~RUBY class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -494,7 +494,7 @@ class Foo < Formula expect(new_source).to eq(corrected_source) end - it "auto corrects to remove punctuation" do + it "auto-corrects to remove punctuation" do source = <<~RUBY class Foo < Formula url 'https://brew.sh/foo-1.0.tgz'
true
Other
Homebrew
brew
9acbc6c3f4847a1c48f244fa77ec60244abe1c33.json
bump-cask-pr: ignore closed duplicate PRs
Library/Homebrew/dev-cmd/bump-cask-pr.rb
@@ -88,10 +88,6 @@ def bump_cask_pr check_open_pull_requests(cask, tap_full_name, args: args) - if new_version.present? && !new_version.latest? - check_closed_pull_requests(cask, tap_full_name, version: new_version, args: args) - end - old_contents = File.read(cask.sourcefile_path) replacement_pairs = []
false
Other
Homebrew
brew
1d710047a5e4e4ab5e8855f6aa6a3394b386573d.json
formula: add more tests for `shared_library`
Library/Homebrew/test/os/linux/formula_spec.rb
@@ -107,6 +107,12 @@ f = Testball.new expect(f.shared_library("foobar")).to eq("foobar.so") expect(f.shared_library("foobar", 2)).to eq("foobar.so.2") + expect(f.shared_library("foobar", nil)).to eq("foobar.so") + expect(f.shared_library("foobar", "*")).to eq("foobar.so{,.*}") + expect(f.shared_library("*")).to eq("*.so{,.*}") + expect(f.shared_library("*", 2)).to eq("*.so.2") + expect(f.shared_library("*", nil)).to eq("*.so{,.*}") + expect(f.shared_library("*", "*")).to eq("*.so{,.*}") end end end
true
Other
Homebrew
brew
1d710047a5e4e4ab5e8855f6aa6a3394b386573d.json
formula: add more tests for `shared_library`
Library/Homebrew/test/os/mac/formula_spec.rb
@@ -112,6 +112,12 @@ f = Testball.new expect(f.shared_library("foobar")).to eq("foobar.dylib") expect(f.shared_library("foobar", 2)).to eq("foobar.2.dylib") + expect(f.shared_library("foobar", nil)).to eq("foobar.dylib") + expect(f.shared_library("foobar", "*")).to eq("foobar{,.*}.dylib") + expect(f.shared_library("*")).to eq("*.dylib") + expect(f.shared_library("*", 2)).to eq("*.2.dylib") + expect(f.shared_library("*", nil)).to eq("*.dylib") + expect(f.shared_library("*", "*")).to eq("*.dylib") end end end
true
Other
Homebrew
brew
d7323f30d3ce781519044585fab2b030e29b3efb.json
extend/os/mac/extend/ENV: fix pkg-config paths
Library/Homebrew/extend/os/mac/extend/ENV/std.rb
@@ -7,7 +7,7 @@ module Stdenv undef homebrew_extra_pkg_config_paths def homebrew_extra_pkg_config_paths - ["#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.sdk_version}"] + ["#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"] end def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false)
true
Other
Homebrew
brew
d7323f30d3ce781519044585fab2b030e29b3efb.json
extend/os/mac/extend/ENV: fix pkg-config paths
Library/Homebrew/extend/os/mac/extend/ENV/super.rb
@@ -34,7 +34,7 @@ def homebrew_extra_paths # @private def homebrew_extra_pkg_config_paths paths = \ - ["/usr/lib/pkgconfig", "#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.sdk_version}"] + ["/usr/lib/pkgconfig", "#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"] paths << "#{MacOS::XQuartz.lib}/pkgconfig" << "#{MacOS::XQuartz.share}/pkgconfig" if x11? paths end
true
Other
Homebrew
brew
b02acb37c080a6f697a6b534bdc768bf4d8ce6c9.json
Remove warning on ARM
Library/Homebrew/extend/os/mac/diagnostic.rb
@@ -63,7 +63,6 @@ def fatal_setup_build_environment_checks def supported_configuration_checks %w[ - check_for_unsupported_arch check_for_unsupported_macos ].freeze end @@ -91,18 +90,6 @@ def check_for_non_prefixed_findutils nil end - def check_for_unsupported_arch - return if Homebrew::EnvConfig.developer? - return unless Hardware::CPU.arm? - - <<~EOS - You are running macOS on a #{Hardware::CPU.arch} CPU architecture. - We do not provide support for this (yet). - Reinstall Homebrew under Rosetta 2 until we support it. - #{please_create_pull_requests} - EOS - end - def check_for_unsupported_macos return if Homebrew::EnvConfig.developer?
true
Other
Homebrew
brew
b02acb37c080a6f697a6b534bdc768bf4d8ce6c9.json
Remove warning on ARM
Library/Homebrew/install.rb
@@ -51,11 +51,6 @@ def check_prefix end def check_cpu - return if Hardware::CPU.intel? && Hardware::CPU.is_64_bit? - - # Handled by check_for_unsupported_arch in extend/os/mac/diagnostic.rb - return if Hardware::CPU.arm? - return unless Hardware::CPU.ppc? odie <<~EOS
true
Other
Homebrew
brew
42ae6adcbe56043f443bec3e42a3b27a9405a878.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/gems/rspec-github@2.3.1.rbi
@@ -0,0 +1,8 @@ +# DO NOT EDIT MANUALLY +# This is an autogenerated file for types exported from the `rspec-github` gem. +# Please instead update this file by running `tapioca sync`. + +# typed: true + +# THIS IS AN EMPTY RBI FILE. +# see https://github.com/Shopify/tapioca/blob/master/README.md#manual-gem-requires
true
Other
Homebrew
brew
42ae6adcbe56043f443bec3e42a3b27a9405a878.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
@@ -21869,9 +21869,36 @@ module RSpec::Expectations def self.fail_with(message, expected=T.unsafe(nil), actual=T.unsafe(nil)); end end +module RSpec::Github + VERSION = ::T.let(nil, ::T.untyped) +end + +class RSpec::Github::Formatter + def example_failed(failure); end + + def example_pending(pending); end +end + class RSpec::Github::Formatter end +class RSpec::Github::NotificationDecorator + def annotation(); end + + def initialize(notification); end + + def line(); end + + def path(); end + ESCAPE_MAP = ::T.let(nil, ::T.untyped) +end + +class RSpec::Github::NotificationDecorator +end + +module RSpec::Github +end + module RSpec::Its def its(attribute, *options, &block); end VERSION = ::T.let(nil, ::T.untyped)
true
Other
Homebrew
brew
9fd2319afa9ad3c40b365bff7e5668f640aed82b.json
update-report: add links to changelog and blog
Library/Homebrew/cmd/update-report.rb
@@ -78,6 +78,7 @@ def update_report install_core_tap_if_necessary updated = false + new_repository_version = nil initial_revision = ENV["HOMEBREW_UPDATE_BEFORE"].to_s current_revision = ENV["HOMEBREW_UPDATE_AFTER"].to_s @@ -87,6 +88,9 @@ def update_report update_preinstall_header args: args puts "Updated Homebrew from #{shorten_revision(initial_revision)} to #{shorten_revision(current_revision)}." updated = true + + tag = Utils.safe_popen_read("git", "tag", "--points-at", "HEAD") + new_repository_version = tag.chomp if tag.present? end Homebrew.failed = true if ENV["HOMEBREW_UPDATE_FAILED"] @@ -136,6 +140,21 @@ def update_report Commands.rebuild_commands_completion_list link_completions_manpages_and_docs Tap.each(&:link_completions_and_manpages) + + return if new_repository_version.blank? + + ohai "Homebrew was updated to version #{new_repository_version}" + puts <<~EOS + The changelog can be found at: + #{Formatter.url("https://github.com/Homebrew/brew/releases/tag/#{new_repository_version}")} + EOS + + return unless new_repository_version.split(".").last == "0" + + puts <<~EOS + More detailed release notes are available on the Homebrew Blog: + #{Formatter.url("https://brew.sh/blog/")} + EOS end def shorten_revision(revision)
false
Other
Homebrew
brew
76c69b7bb35077bbb94c8f6337bc1899b2b71b63.json
release-notes: add message directing users to the blog.
Library/Homebrew/dev-cmd/release-notes.rb
@@ -58,6 +58,7 @@ def release_notes end $stderr.puts "Release notes between #{previous_tag} and #{end_ref}:" + puts "Release notes for major and minor releases can be found in the [Homebrew blog](https://brew.sh/blog/)." puts output end end
false
Other
Homebrew
brew
c77c9422915773c33c33ebba0d913c4f5ca29c57.json
os/mac/sdk: parse version from SDKSettings.json This implements feedback from https://github.com/Homebrew/brew/pull/10072.
Library/Homebrew/os/mac/sdk.rb
@@ -93,10 +93,11 @@ def sdk_paths # Use unversioned SDK path on Big Sur to avoid issues such as: # https://github.com/Homebrew/homebrew-core/issues/67075 - if OS::Mac.version >= :big_sur - sdk_path = File.join(sdk_prefix, "MacOSX.sdk") - version = OS::Mac.full_version - paths[version] = sdk_path if File.directory?(sdk_path) + sdk_path = File.join(sdk_prefix, "MacOSX.sdk") + if OS::Mac.version >= :big_sur && File.directory?(sdk_path) + sdk_settings = File.join(sdk_path, "SDKSettings.json") + version = JSON.parse(File.read(sdk_settings))["Version"] if File.exist?(sdk_settings) + paths[OS::Mac::Version.new(version)] = sdk_path if version.present? end paths
false
Other
Homebrew
brew
0b574eff9050853d687f6fdd5d791b25b18d4a33.json
search: add two options
Library/Homebrew/cmd/search.rb
@@ -51,7 +51,13 @@ def search_args "a name matching <text>." switch "--pull-request", description: "Search for GitHub pull requests containing <text>." - + switch "--open", + depends_on: "--pull-request", + description: "Search for only open GitHub pull requests" + switch "--closed", + depends_on: "--pull-request", + description: "Search for only closed GitHub pull requests" + conflicts "--open", "--closed" package_manager_switches = PACKAGE_MANAGERS.keys.map { |name| "--#{name}" } package_manager_switches.each do |s| switch s, @@ -91,7 +97,13 @@ def search if args.desc? search_descriptions(string_or_regex) elsif args.pull_request? - GitHub.print_pull_requests_matching(query) + only = if args.open? && !args.closed? + "open" + elsif args.closed? && !args.open? + "closed" + end + + GitHub.print_pull_requests_matching(query, only) else remote_results = search_taps(query, silent: true)
true
Other
Homebrew
brew
0b574eff9050853d687f6fdd5d791b25b18d4a33.json
search: add two options
Library/Homebrew/utils/github.rb
@@ -342,8 +342,8 @@ def merge_pull_request(repo, number:, sha:, merge_method:, commit_message: nil) open_api(url, data: data, request_method: :PUT, scopes: CREATE_ISSUE_FORK_OR_PR_SCOPES) end - def print_pull_requests_matching(query) - open_or_closed_prs = search_issues(query, type: "pr", user: "Homebrew") + def print_pull_requests_matching(query, only = nil) + open_or_closed_prs = search_issues(query, is: only, type: "pr", user: "Homebrew") open_prs, closed_prs = open_or_closed_prs.partition { |pr| pr["state"] == "open" } .map { |prs| prs.map { |pr| "#{pr["title"]} (#{pr["html_url"]})" } }
true
Other
Homebrew
brew
0b574eff9050853d687f6fdd5d791b25b18d4a33.json
search: add two options
docs/Manpage.md
@@ -486,6 +486,10 @@ No online search is performed. Search for formulae with a description matching *`text`* and casks with a name matching *`text`*. * `--pull-request`: Search for GitHub pull requests containing *`text`*. +* `--open`: + Search for only open GitHub pull requests +* `--closed`: + Search for only closed GitHub pull requests * `--macports`: Search for *`text`* in the given package manager's list. * `--fink`:
true
Other
Homebrew
brew
0b574eff9050853d687f6fdd5d791b25b18d4a33.json
search: add two options
manpages/brew.1
@@ -667,6 +667,14 @@ Search for formulae with a description matching \fItext\fR and casks with a name Search for GitHub pull requests containing \fItext\fR\. . .TP +\fB\-\-open\fR +Search for only open GitHub pull requests +. +.TP +\fB\-\-closed\fR +Search for only closed GitHub pull requests +. +.TP \fB\-\-macports\fR Search for \fItext\fR in the given package manager\'s list\. .
true
Other
Homebrew
brew
2eb34b0b27160ed26f46594ff21bd2a629176398.json
formula: add deprecation_date and disable_date methods
Library/Homebrew/formula.rb
@@ -1165,6 +1165,12 @@ def link_overwrite?(path) # @return [Boolean] delegate deprecated?: :"self.class" + # The date that this {Formula} was or becomes deprecated. + # Returns `nil` if no date is specified. + # @!method deprecation_date + # @return Date + delegate deprecation_date: :"self.class" + # The reason this {Formula} is deprecated. # Returns `nil` if no reason is specified or the formula is not deprecated. # @!method deprecation_reason @@ -1177,6 +1183,12 @@ def link_overwrite?(path) # @return [Boolean] delegate disabled?: :"self.class" + # The date that this {Formula} was or becomes disabled. + # Returns `nil` if no date is specified. + # @!method disable_date + # @return Date + delegate disable_date: :"self.class" + # The reason this {Formula} is disabled. # Returns `nil` if no reason is specified or the formula is not disabled. # @!method disable_reason @@ -2771,6 +2783,8 @@ def deprecate!(date: nil, because: nil) odeprecated "`deprecate!` without a reason", "`deprecate! because: \"reason\"`" if because.blank? odeprecated "`deprecate!` without a date", "`deprecate! date: \"#{Date.today}\"`" if date.blank? + @deprecation_date = Date.parse(date) if date.present? + return if date.present? && Date.parse(date) > Date.today @deprecation_reason = because if because.present? @@ -2784,6 +2798,11 @@ def deprecated? @deprecated == true end + # The date that this {Formula} was or becomes deprecated. + # Returns `nil` if no date is specified. + # @return Date + attr_reader :deprecation_date + # The reason for deprecation of a {Formula}. # @return [nil] if no reason was provided or the formula is not deprecated. # @return [String, Symbol] @@ -2798,7 +2817,9 @@ def disable!(date: nil, because: nil) odeprecated "`disable!` without a reason", "`disable! because: \"reason\"`" if because.blank? odeprecated "`disable!` without a date", "`disable! date: \"#{Date.today}\"`" if date.blank? - if date.present? && Date.parse(date) > Date.today + @disable_date = Date.parse(date) if date.present? + + if @disable_date && @disable_date > Date.today @deprecation_reason = because if because.present? @deprecated = true return @@ -2815,6 +2836,11 @@ def disabled? @disabled == true end + # The date that this {Formula} was or becomes disabled. + # Returns `nil` if no date is specified. + # @return Date + attr_reader :disable_date + # The reason this {Formula} is disabled. # Returns `nil` if no reason was provided or the formula is not disabled. # @return [String, Symbol]
false
Other
Homebrew
brew
aaf7bc2bc5533f2ab177374193ad260f97b79985.json
utils: add AST helper functions for editing formulae
Library/Homebrew/test/utils/ast_spec.rb
@@ -0,0 +1,50 @@ +# typed: false +# frozen_string_literal: true + +require "utils/ast" + +describe Utils::AST do + let(:initial_formula) do + <<~RUBY + class Foo < Formula + url "https://brew.sh/foo-1.0.tar.gz" + license all_of: [ + :public_domain, + "MIT", + "GPL-3.0-or-later" => { with: "Autoconf-exception-3.0" }, + ] + end + RUBY + end + + describe ".replace_formula_stanza!" do + it "replaces the specified stanza in a formula" do + contents = initial_formula.dup + described_class.replace_formula_stanza! contents, name: :license, replacement: "license :public_domain" + expect(contents).to eq <<~RUBY + class Foo < Formula + url "https://brew.sh/foo-1.0.tar.gz" + license :public_domain + end + RUBY + end + end + + describe ".add_formula_stanza!" do + it "adds the specified stanza to a formula" do + contents = initial_formula.dup + described_class.add_formula_stanza! contents, name: :revision, text: "revision 1" + expect(contents).to eq <<~RUBY + class Foo < Formula + url "https://brew.sh/foo-1.0.tar.gz" + license all_of: [ + :public_domain, + "MIT", + "GPL-3.0-or-later" => { with: "Autoconf-exception-3.0" }, + ] + revision 1 + end + RUBY + end + end +end
true
Other
Homebrew
brew
aaf7bc2bc5533f2ab177374193ad260f97b79985.json
utils: add AST helper functions for editing formulae
Library/Homebrew/utils/ast.rb
@@ -0,0 +1,122 @@ +# typed: true +# frozen_string_literal: true + +module Utils + # Helper functions for editing Ruby files. + # + # @api private + module AST + class << self + extend T::Sig + + def replace_formula_stanza!(formula_contents, name:, replacement:, type: nil) + processed_source, body_node = process_formula(formula_contents) + children = body_node.begin_type? ? body_node.children.compact : [body_node] + stanza_node = children.find { |child| call_node_match?(child, name: name, type: type) } + raise "Could not find #{name} stanza!" if stanza_node.nil? + + tree_rewriter = Parser::Source::TreeRewriter.new(processed_source.buffer) + tree_rewriter.replace(stanza_node.source_range, replacement.strip) + formula_contents.replace(tree_rewriter.process) + end + + def add_formula_stanza!(formula_contents, name:, text:, type: nil) + processed_source, body_node = process_formula(formula_contents) + + preceding_component = if body_node.begin_type? + body_node.children.compact.reduce do |previous_child, current_child| + if formula_component_before_target?(current_child, + target_name: name, + target_type: type) + next current_child + else + break previous_child + end + end + else + body_node + end + preceding_component = preceding_component.last_argument if preceding_component.send_type? + + preceding_expr = preceding_component.location.expression + processed_source.comments.each do |comment| + comment_expr = comment.location.expression + distance = comment_expr.first_line - preceding_expr.first_line + case distance + when 0 + if comment_expr.last_line > preceding_expr.last_line || + comment_expr.end_pos > preceding_expr.end_pos + preceding_expr = comment_expr + end + when 1 + preceding_expr = comment_expr + end + end + + tree_rewriter = Parser::Source::TreeRewriter.new(processed_source.buffer) + tree_rewriter.insert_after(preceding_expr, "\n#{text.match?(/\A\s+/) ? text : text.indent(2)}") + formula_contents.replace(tree_rewriter.process) + end + + private + + def process_formula(formula_contents) + Homebrew.install_bundler_gems! + require "rubocop-ast" + + ruby_version = Version.new(HOMEBREW_REQUIRED_RUBY_VERSION).major_minor.to_f + processed_source = RuboCop::AST::ProcessedSource.new(formula_contents, ruby_version) + root_node = processed_source.ast + + class_node = if root_node.class_type? + root_node + elsif root_node.begin_type? + root_node.children.find { |n| n.class_type? && n.parent_class&.const_name == "Formula" } + end + + raise "Could not find formula class!" if class_node.nil? + + body_node = class_node.body + raise "Formula class is empty!" if body_node.nil? + + [processed_source, body_node] + end + + def formula_component_before_target?(node, target_name:, target_type: nil) + require "rubocops/components_order" + + RuboCop::Cop::FormulaAudit::ComponentsOrder::COMPONENT_PRECEDENCE_LIST.each do |components| + return false if components.any? do |component| + component_match?(component_name: component[:name], + component_type: component[:type], + target_name: target_name, + target_type: target_type) + end + return true if components.any? do |component| + call_node_match?(node, name: component[:name], type: component[:type]) + end + end + + false + end + + def component_match?(component_name:, component_type:, target_name:, target_type: nil) + component_name == target_name && (target_type.nil? || component_type == target_type) + end + + def call_node_match?(node, name:, type: nil) + node_type = if node.send_type? + :method_call + elsif node.block_type? + :block_call + end + return false if node_type.nil? + + component_match?(component_name: T.unsafe(node).method_name, + component_type: node_type, + target_name: name, + target_type: type) + end + end + end +end
true
Other
Homebrew
brew
aaf7bc2bc5533f2ab177374193ad260f97b79985.json
utils: add AST helper functions for editing formulae
Library/Homebrew/utils/bottles.rb
@@ -2,6 +2,7 @@ # frozen_string_literal: true require "tab" +require "utils/ast" module Utils # Helper functions for bottles. @@ -76,75 +77,10 @@ def formula_contents(bottle_file, end def add_bottle_stanza!(formula_contents, bottle_output) - Homebrew.install_bundler_gems! - require "rubocop-ast" - - ruby_version = Version.new(HOMEBREW_REQUIRED_RUBY_VERSION).major_minor.to_f - processed_source = RuboCop::AST::ProcessedSource.new(formula_contents, ruby_version) - root_node = processed_source.ast - - class_node = if root_node.class_type? - root_node - elsif root_node.begin_type? - root_node.children.find do |n| - n.class_type? && n.parent_class&.const_name == "Formula" - end - end - - odie "Could not find formula class!" if class_node.nil? - - body_node = class_node.body - odie "Formula class is empty!" if body_node.nil? - - node_before_bottle = if body_node.begin_type? - body_node.children.compact.reduce do |previous_child, current_child| - break previous_child unless component_before_bottle_block? current_child - - current_child - end - else - body_node - end - node_before_bottle = node_before_bottle.last_argument if node_before_bottle.send_type? - - expr_before_bottle = node_before_bottle.location.expression - processed_source.comments.each do |comment| - comment_expr = comment.location.expression - distance = comment_expr.first_line - expr_before_bottle.first_line - case distance - when 0 - if comment_expr.last_line > expr_before_bottle.last_line || - comment_expr.end_pos > expr_before_bottle.end_pos - expr_before_bottle = comment_expr - end - when 1 - expr_before_bottle = comment_expr - end - end - - tree_rewriter = Parser::Source::TreeRewriter.new(processed_source.buffer) - tree_rewriter.insert_after(expr_before_bottle, "\n\n#{bottle_output.chomp}") - formula_contents.replace(tree_rewriter.process) - end - - private - - def component_before_bottle_block?(node) - require "rubocops/components_order" - - RuboCop::Cop::FormulaAudit::ComponentsOrder::COMPONENT_PRECEDENCE_LIST.each do |components| - components.each do |component| - return false if component[:name] == :bottle && component[:type] == :block_call - - case component[:type] - when :method_call - return true if node.send_type? && node.method_name == component[:name] - when :block_call - return true if node.block_type? && node.method_name == component[:name] - end - end - end - false + Utils::AST.add_formula_stanza!(formula_contents, + name: :bottle, + type: :block_call, + text: "\n#{bottle_output.chomp}") end end
true
Other
Homebrew
brew
668f0475eb59e4edc594481e0651f2eca598157a.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
@@ -30099,6 +30099,10 @@ class String def html_safe(); end + def indent(amount, indent_string=T.unsafe(nil), indent_empty_lines=T.unsafe(nil)); end + + def indent!(amount, indent_string=T.unsafe(nil), indent_empty_lines=T.unsafe(nil)); end + def iseuc(); end def isjis(); end
false
Other
Homebrew
brew
095798be405be47429877f9d92f416153f86e147.json
hardware: optimize Big Sur bottles for Ivy Bridge
Library/Homebrew/extend/os/mac/hardware.rb
@@ -7,6 +7,8 @@ module Hardware def self.oldest_cpu(version = MacOS.version) if CPU.arch == :arm64 :arm_vortex_tempest + elsif version >= :big_sur + :ivybridge elsif version >= :mojave :nehalem else
true
Other
Homebrew
brew
095798be405be47429877f9d92f416153f86e147.json
hardware: optimize Big Sur bottles for Ivy Bridge
Library/Homebrew/hardware.rb
@@ -26,8 +26,9 @@ class << self def optimization_flags @optimization_flags ||= { native: arch_flag("native"), - nehalem: "-march=nehalem", + ivybridge: "-march=ivybridge", sandybridge: "-march=sandybridge", + nehalem: "-march=nehalem", core2: "-march=core2", core: "-march=prescott", arm_vortex_tempest: "",
true
Other
Homebrew
brew
4afcae58c30a6055831cb1f3d26e79242b39c4e4.json
bottle: add test for writing part In preparation for https://github.com/Homebrew/brew/issues/9315
Library/Homebrew/test/.rubocop_todo.yml
@@ -11,6 +11,7 @@ RSpec/ExampleLength: Exclude: - 'rubocops/patches_spec.rb' + - 'dev-cmd/bottle_spec.rb' # Offense count: 6 # Configuration parameters: AssignmentOnly.
true
Other
Homebrew
brew
4afcae58c30a6055831cb1f3d26e79242b39c4e4.json
bottle: add test for writing part In preparation for https://github.com/Homebrew/brew/issues/9315
Library/Homebrew/test/dev-cmd/bottle_spec.rb
@@ -42,39 +42,39 @@ end end +def stub_hash(parameters) + <<~EOS + { + "#{parameters[:name]}":{ + "formula":{ + "pkg_version":"#{parameters[:version]}", + "path":"#{parameters[:path]}" + }, + "bottle":{ + "root_url":"#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}", + "prefix":"/usr/local", + "cellar":"#{parameters[:cellar]}", + "rebuild":0, + "tags":{ + "#{parameters[:os]}":{ + "filename":"#{parameters[:filename]}", + "local_filename":"#{parameters[:local_filename]}", + "sha256":"#{parameters[:sha256]}" + } + } + }, + "bintray":{ + "package":"#{parameters[:name]}", + "repository":"bottles" + } + } + } + EOS +end + describe Homebrew do subject(:homebrew) { described_class } - def stub_hash(parameters) - <<~EOS - { - "#{parameters[:name]}":{ - "formula":{ - "pkg_version":"#{parameters[:version]}", - "path":"#{parameters[:path]}" - }, - "bottle":{ - "root_url":"https://homebrew.bintray.com/bottles", - "prefix":"/usr/local", - "cellar":"#{parameters[:cellar]}", - "rebuild":0, - "tags":{ - "#{parameters[:os]}":{ - "filename":"#{parameters[:filename]}", - "local_filename":"#{parameters[:local_filename]}", - "sha256":"#{parameters[:sha256]}" - } - } - }, - "bintray":{ - "package":"#{parameters[:name]}", - "repository":"bottles" - } - } - } - EOS - end - let(:hello_hash_big_sur) { JSON.parse( stub_hash( @@ -194,3 +194,106 @@ def stub_hash(parameters) ) end end + +describe "brew bottle --merge", :integration_test, :needs_linux do + it "adds the bottle block to a formula that has none" do + core_tap = CoreTap.new + core_tap.path.cd do + system "git", "init" + setup_test_formula "testball" + system "git", "add", "--all" + system "git", "commit", "-m", "testball 0.1" + end + + Pathname("testball-1.0.big_sur.bottle.json").write( + stub_hash( + { + "name": "testball", + "version": "1.0", + "path": "#{core_tap.path}/Formula/testball.rb", + "cellar": "any_skip_relocation", + "os": "big_sur", + "filename": "hello-1.0.big_sur.bottle.tar.gz", + "local_filename": "hello--1.0.big_sur.bottle.tar.gz", + "sha256": "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f", + }, + ), + ) + + Pathname("testball-1.0.catalina.bottle.json").write( + stub_hash( + { + "name": "testball", + "version": "1.0", + "path": "#{core_tap.path}/Formula/testball.rb", + "cellar": "any_skip_relocation", + "os": "catalina", + "filename": "testball-1.0.catalina.bottle.tar.gz", + "local_filename": "testball--1.0.catalina.bottle.tar.gz", + "sha256": "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac", + }, + ), + ) + + expect { + brew "bottle", + "--merge", + "--write", + "testball-1.0.big_sur.bottle.json", + "testball-1.0.catalina.bottle.json" + }.to output( + <<~EOS, + ==> testball + bottle do + root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}" + cellar :any_skip_relocation + sha256 "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f" => :big_sur + sha256 "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac" => :catalina + end + EOS + ).to_stdout + + FileUtils.rm_f "testball-1.0.catalina.bottle.json" + FileUtils.rm_f "testball-1.0.big_sur.bottle.json" + + tarball = if OS.linux? + TEST_FIXTURE_DIR/"tarballs/testball-0.1-linux.tbz" + else + TEST_FIXTURE_DIR/"tarballs/testball-0.1.tbz" + end + + expect((core_tap.path/"Formula/testball.rb").read).to eq( + <<~EOS, + class Testball < Formula + desc "Some test" + homepage "https://brew.sh/testball" + url "file://#{tarball}" + sha256 "#{tarball.sha256}" + + bottle do + root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}" + cellar :any_skip_relocation + sha256 "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f" => :big_sur + sha256 "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac" => :catalina + end + + option "with-foo", "Build with foo" + + def install + (prefix/"foo"/"test").write("test") if build.with? "foo" + prefix.install Dir["*"] + (buildpath/"test.c").write \ + "#include <stdio.h>\\nint main(){printf(\\"test\\");return 0;}" + bin.mkpath + system ENV.cc, "test.c", "-o", bin/"test" + end + + + + # something here + + end + EOS + ) + end +end
true
Other
Homebrew
brew
722a040c49f20952aeade6d5737bbffa2e4f75e8.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
@@ -7827,6 +7827,22 @@ class Homebrew::FormulaCreator extend ::T::Private::Methods::SingletonMethodHooks end +class Homebrew::Livecheck::Strategy::HeaderMatch + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + +class Homebrew::Livecheck::Strategy::Sparkle::Item + def self.[](*_); end + + def self.members(); end +end + +class Homebrew::Livecheck::Strategy::Sparkle + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + module Homebrew::Livecheck extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks
false
Other
Homebrew
brew
cdb07d89ae54468d66a3f6948c937b00a3bbcdf0.json
integration_test: fix indentation for test formulae
Library/Homebrew/global.rb
@@ -29,6 +29,7 @@ require "active_support/core_ext/file/atomic" require "active_support/core_ext/enumerable" require "active_support/core_ext/string/exclude" +require "active_support/core_ext/string/indent" I18n.backend.available_locales # Initialize locales so they can be overwritten. I18n.backend.store_translations :en, support: { array: { last_word_connector: " and " } }
true
Other
Homebrew
brew
cdb07d89ae54468d66a3f6948c937b00a3bbcdf0.json
integration_test: fix indentation for test formulae
Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
@@ -171,7 +171,7 @@ def install Formulary.core_path(name).tap do |formula_path| formula_path.write <<~RUBY class #{Formulary.class_s(name)} < Formula - #{content} + #{content.indent(2)} end RUBY end
true
Other
Homebrew
brew
cdb07d89ae54468d66a3f6948c937b00a3bbcdf0.json
integration_test: fix indentation for test formulae
Library/Homebrew/test/utils/bottles/bottles_spec.rb
@@ -17,8 +17,6 @@ describe "#add_bottle_stanza!" do let(:bottle_output) do - require "active_support/core_ext/string/indent" - <<~RUBY.chomp.indent(2) bottle do sha256 "f7b1fc772c79c20fddf621ccc791090bc1085fcef4da6cca03399424c66e06ca" => :sierra
true
Other
Homebrew
brew
8b17017108d5b550562b556c5d407361cea27781.json
Improve error message for missing PKG source.
Library/Homebrew/cask/artifact/pkg.rb
@@ -42,7 +42,14 @@ def run_installer(command: nil, verbose: false, **_options) ohai "Running installer for #{cask}; your password may be necessary." ohai "Package installers may write to any location; options such as --appdir are ignored." unless path.exist? - raise CaskError, "pkg source file not found: '#{path.relative_path_from(cask.staged_path)}'" + pkg = path.relative_path_from(cask.staged_path) + pkgs = Pathname.glob(cask.staged_path/"**"/"*.pkg").map { |path| path.relative_path_from(cask.staged_path) } + + message = "Could not find PKG source file '#{pkg}'" + message += ", found #{pkgs.map { |path| "'#{path}'" }.to_sentence} instead" if pkgs.any? + message += "." + + raise CaskError, message end args = [
false
Other
Homebrew
brew
82c1e6fb0ebeb5bb34f03c1ef1b4cd482515f76c.json
Fix basename for extracting cask downloads.
Library/Homebrew/cask/download.rb
@@ -52,6 +52,10 @@ def cached_download downloader.cached_location end + def basename + downloader.basename + end + def verify_download_integrity(fn) if @cask.sha256 == :no_check opoo "No checksum defined for cask '#{@cask}', skipping verification."
true
Other
Homebrew
brew
82c1e6fb0ebeb5bb34f03c1ef1b4cd482515f76c.json
Fix basename for extracting cask downloads.
Library/Homebrew/cask/installer.rb
@@ -152,10 +152,14 @@ def summary s.freeze end + sig { returns(Download) } + def downloader + @downloader ||= Download.new(@cask, quarantine: quarantine?) + end + sig { returns(Pathname) } def download - @download ||= Download.new(@cask, quarantine: quarantine?) - .fetch(verify_download_integrity: @verify_download_integrity) + @download ||= downloader.fetch(verify_download_integrity: @verify_download_integrity) end def verify_has_sha @@ -180,7 +184,7 @@ def extract_primary_container(to: @cask.staged_path) odebug "Using container class #{primary_container.class} for #{primary_container.path}" - basename = CGI.unescape(File.basename(@cask.url.path)) + basename = downloader.basename if nested_container = @cask.container&.nested Dir.mktmpdir do |tmpdir|
true
Other
Homebrew
brew
3f0ed01a2aeceb9fbe8ff410a170d7f30b7936e4.json
sdk: use unversioned SDK path on Big Sur Fixes https://github.com/Homebrew/homebrew-core/issues/67075. This implements @fxcoudert's suggestion in the issue linked above.
Library/Homebrew/os/mac/sdk.rb
@@ -91,6 +91,14 @@ def sdk_paths paths[OS::Mac::Version.new(version)] = sdk_path if version.present? end + # Use unversioned SDK path on Big Sur to avoid issues such as: + # https://github.com/Homebrew/homebrew-core/issues/67075 + if OS::Mac.version >= :big_sur + sdk_path = File.join(sdk_prefix, "MacOSX.sdk") + version = OS::Mac.full_version + paths[version] = sdk_path if File.directory?(sdk_path) + end + paths else {}
false
Other
Homebrew
brew
bade687f118ecd857a5fa843a00160ceb9699f90.json
upgrade: fix style in help text
Library/Homebrew/cmd/upgrade.rb
@@ -39,7 +39,7 @@ def upgrade_args description: "Show what would be upgraded, but do not actually upgrade anything." [ [:switch, "--formula", "--formulae", { - description: "Treat all named arguments as formulae. If no named arguments" \ + description: "Treat all named arguments as formulae. If no named arguments " \ "are specified, upgrade only outdated formulae.", }], [:switch, "-s", "--build-from-source", {
true
Other
Homebrew
brew
bade687f118ecd857a5fa843a00160ceb9699f90.json
upgrade: fix style in help text
docs/Manpage.md
@@ -612,7 +612,7 @@ upgraded formulae or, every 30 days, for all formulae. * `-n`, `--dry-run`: Show what would be upgraded, but do not actually upgrade anything. * `--formula`: - Treat all named arguments as formulae. If no named argumentsare specified, upgrade only outdated formulae. + Treat all named arguments as formulae. If no named arguments are specified, upgrade only outdated formulae. * `-s`, `--build-from-source`: Compile *`formula`* from source even if a bottle is available. * `-i`, `--interactive`:
true
Other
Homebrew
brew
bade687f118ecd857a5fa843a00160ceb9699f90.json
upgrade: fix style in help text
manpages/brew.1
@@ -823,7 +823,7 @@ Show what would be upgraded, but do not actually upgrade anything\. . .TP \fB\-\-formula\fR -Treat all named arguments as formulae\. If no named argumentsare specified, upgrade only outdated formulae\. +Treat all named arguments as formulae\. If no named arguments are specified, upgrade only outdated formulae\. . .TP \fB\-s\fR, \fB\-\-build\-from\-source\fR
true
Other
Homebrew
brew
9f7e471382d61b5a6ea61c48767271edcedcebe2.json
livecheck: raise error if no watchlist
Library/Homebrew/dev-cmd/livecheck.rb
@@ -96,6 +96,9 @@ def livecheck rescue Errno::ENOENT => e onoe e end + else + raise UsageError, "ENV['HOMEBREW_LIVECHECK_WATCHLIST'] or ~/.brew_livecheck_watchlist is required " \ + "if no formula or cask argument is passed" end&.sort_by do |formula_or_cask| formula_or_cask.respond_to?(:token) ? formula_or_cask.token : formula_or_cask.name end
false
Other
Homebrew
brew
e604cf742bf158b9f133c14ac438822326fbbd2e.json
dev-cmd/livecheck: use safe navigation on #sort_by
Library/Homebrew/dev-cmd/livecheck.rb
@@ -60,44 +60,45 @@ def livecheck puts ENV["HOMEBREW_LIVECHECK_WATCHLIST"] if ENV["HOMEBREW_LIVECHECK_WATCHLIST"].present? end - formulae_and_casks_to_check = if args.tap - tap = Tap.fetch(args.tap) - formulae = args.cask? ? [] : tap.formula_files.map { |path| Formulary.factory(path) } - casks = args.formula? ? [] : tap.cask_files.map { |path| Cask::CaskLoader.load(path) } - formulae + casks - elsif args.installed? - formulae = args.cask? ? [] : Formula.installed - casks = args.formula? ? [] : Cask::Caskroom.casks - formulae + casks - elsif args.all? - formulae = args.cask? ? [] : Formula.to_a - casks = args.formula? ? [] : Cask::Cask.to_a - formulae + casks - elsif args.named.present? - if args.formula? - args.named.to_formulae - elsif args.cask? - args.named.to_casks - else - args.named.to_formulae_and_casks - end - elsif File.exist?(WATCHLIST_PATH) - begin - names = Pathname.new(WATCHLIST_PATH).read.lines - .reject { |line| line.start_with?("#") || line.blank? } - .map(&:strip) + formulae_and_casks_to_check = + if args.tap + tap = Tap.fetch(args.tap) + formulae = args.cask? ? [] : tap.formula_files.map { |path| Formulary.factory(path) } + casks = args.formula? ? [] : tap.cask_files.map { |path| Cask::CaskLoader.load(path) } + formulae + casks + elsif args.installed? + formulae = args.cask? ? [] : Formula.installed + casks = args.formula? ? [] : Cask::Caskroom.casks + formulae + casks + elsif args.all? + formulae = args.cask? ? [] : Formula.to_a + casks = args.formula? ? [] : Cask::Cask.to_a + formulae + casks + elsif args.named.present? + if args.formula? + args.named.to_formulae + elsif args.cask? + args.named.to_casks + else + args.named.to_formulae_and_casks + end + elsif File.exist?(WATCHLIST_PATH) + begin + names = Pathname.new(WATCHLIST_PATH).read.lines + .reject { |line| line.start_with?("#") || line.blank? } + .map(&:strip) - named_args = T.unsafe(CLI::NamedArgs).new(*names) - named_args.to_formulae_and_casks.reject do |formula_or_cask| - (args.formula? && !formula_or_cask.is_a?(Formula)) || - (args.cask? && !formula_or_cask.is_a?(Cask::Cask)) + named_args = T.unsafe(CLI::NamedArgs).new(*names) + named_args.to_formulae_and_casks.reject do |formula_or_cask| + (args.formula? && !formula_or_cask.is_a?(Formula)) || + (args.cask? && !formula_or_cask.is_a?(Cask::Cask)) + end + rescue Errno::ENOENT => e + onoe e end - rescue Errno::ENOENT => e - onoe e + end&.sort_by do |formula_or_cask| + formula_or_cask.respond_to?(:token) ? formula_or_cask.token : formula_or_cask.name end - end.sort_by do |formula_or_cask| - formula_or_cask.respond_to?(:token) ? formula_or_cask.token : formula_or_cask.name - end raise UsageError, "No formulae or casks to check." if formulae_and_casks_to_check.blank?
false
Other
Homebrew
brew
91ee5e0a6592a45a5b0cdce8a2f00f41f7c84c55.json
Simplify assignment of `curl` result.
Library/Homebrew/livecheck/strategy.rb
@@ -98,13 +98,12 @@ def self.page_headers(url) "--max-time", "10" # Max time allowed for transfer (secs) ] - result = curl_with_workarounds( + stdout, _, status = curl_with_workarounds( *args, url, print_stdout: false, print_stderr: false, debug: false, verbose: false, user_agent: user_agent, retry: false ) - stdout = result.stdout while stdout.match?(/\AHTTP.*\r$/) h, stdout = stdout.split("\r\n\r\n", 2) @@ -114,7 +113,7 @@ def self.page_headers(url) .to_h.transform_keys(&:downcase) end - return (@headers[url] = headers) if result.success? + return (@headers[url] = headers) if status.success? end headers
false
Other
Homebrew
brew
edf6a11be601918ae1374124407ea244a35e2824.json
Simplify creation of `merged_headers`.
Library/Homebrew/livecheck/strategy/header_match.rb
@@ -37,8 +37,7 @@ def self.find_versions(url, regex, &block) headers = Strategy.page_headers(url) # Merge the headers from all responses into one hash - merged_headers = {} - headers.each { |resp_headers| merged_headers.merge!(resp_headers) } + merged_headers = headers.reduce(&:merge) if block match = block.call(merged_headers)
false
Other
Homebrew
brew
0148ee870eedc0d850c25fd7c6fb3e0e02893653.json
Livecheck: Use alphabetical order in symbols array
Library/Homebrew/livecheck/livecheck.rb
@@ -29,8 +29,8 @@ module Livecheck STRATEGY_SYMBOLS_TO_SKIP_PREPROCESS_URL = [ :github_latest, - :sparkle, :page_match, + :sparkle, ].freeze UNSTABLE_VERSION_KEYWORDS = %w[
false
Other
Homebrew
brew
f5774c1af430b8798b6be7ebb8cffec7ba644549.json
Sparkle: Use demodulized class name in error text
Library/Homebrew/livecheck/strategy/sparkle.rb
@@ -19,7 +19,7 @@ class Sparkle < PageMatch # Checks the content at the URL for new versions. sig { params(url: String, regex: T.nilable(Regexp)).returns(T::Hash[Symbol, T.untyped]) } def self.find_versions(url, regex, &block) - raise ArgumentError, "The #{NICE_NAME} strategy does not support regular expressions." if regex + raise ArgumentError, "The #{name.demodulize} strategy does not support regular expressions." if regex match_data = { matches: {}, regex: regex, url: url }
false
Other
Homebrew
brew
3723cd7decc4d94ad772e3e6948262ceff35ee94.json
Remove detection for Sparkle strategy.
Library/Homebrew/livecheck/strategy/sparkle.rb
@@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "bundle_version" @@ -11,36 +11,11 @@ module Strategy # its contents as a Sparkle appcast in XML format. # # @api private - class Sparkle + class Sparkle < PageMatch extend T::Sig NICE_NAME = "Sparkle" - PRIORITY = 1 - - # Whether the strategy can be applied to the provided URL. - sig { params(url: String).returns(T::Boolean) } - def self.match?(url) - return false unless url.match?(%r{^https?://}) - - xml = url.end_with?(".xml") - xml ||= begin - headers = Strategy.page_headers(url) - content_type = headers["content-type"] - content_type.blank? || content_type.include?("xml") - end - return false unless xml - - contents = Strategy.page_contents(url) - - return true if contents.match?(%r{https?://www.andymatuschak.org/xml-namespaces/sparkle}) - - contents.include?("rss") && - contents.include?("channel") && - contents.include?("item") && - contents.include?("enclosure") - end - # Checks the content at the URL for new versions. sig { params(url: String, regex: T.nilable(Regexp)).returns(T::Hash[Symbol, T.untyped]) } def self.find_versions(url, regex, &block)
false
Other
Homebrew
brew
71759035dd82b40b7ad8a4a1f30e917b4306e6c8.json
Fix Sparkle detection if content type is missing.
Library/Homebrew/livecheck/strategy/sparkle.rb
@@ -26,8 +26,8 @@ def self.match?(url) xml = url.end_with?(".xml") xml ||= begin headers = Strategy.page_headers(url) - content_type = headers["content-type"]&.split(";", 2)&.first - ["application/xml", "text/xml"].include?(content_type) + content_type = headers["content-type"] + content_type.blank? || content_type.include?("xml") end return false unless xml
false
Other
Homebrew
brew
0deceac28cf190900ca861f7da27f05cf82f8b61.json
Allow regex without capture groups.
Library/Homebrew/livecheck/strategy/page_match.rb
@@ -61,7 +61,14 @@ def self.page_matches(url, regex, &block) end end - page.scan(regex).map(&:first).uniq + page.scan(regex).map do |match| + case match + when String + match + else + match.first + end + end.uniq end # Checks the content at the URL for new versions, using the provided
false
Other
Homebrew
brew
3a4c7223df13161c834d85258ba8567c5e55a722.json
Allow accessing version in `livecheck` blocks.
Library/Homebrew/livecheck.rb
@@ -8,6 +8,8 @@ # This information is used by the `brew livecheck` command to control its # behavior. class Livecheck + extend Forwardable + # A very brief description of why the formula/cask is skipped (e.g. `No longer # developed or maintained`). # @return [String, nil] @@ -107,6 +109,9 @@ def url(val = nil) end end + delegate version: :@formula_or_cask + private :version + # Returns a `Hash` of all instance variable values. # @return [Hash] def to_hash
false
Other
Homebrew
brew
d3e2a98136385197f52f6f979378efed6cdad202.json
Remove debug output.
Library/Homebrew/livecheck/strategy/page_match.rb
@@ -49,8 +49,6 @@ def self.match?(url) def self.page_matches(url, regex, &block) page = Strategy.page_contents(url) - odebug "Page Contents", page - if block data = { page: page } case (value = block.call(data))
false
Other
Homebrew
brew
605c33c70ce5e57d6a7762afc0c52faf70d4a692.json
Improve matching of Sparkle strategy.
Library/Homebrew/livecheck/strategy.rb
@@ -63,10 +63,11 @@ def from_url(url, livecheck_strategy: nil, url_provided: nil, regex_provided: ni # Only treat the `PageMatch` strategy as usable if a regex is # present in the `livecheck` block next unless regex_provided || block_provided - elsif strategy == Sparkle && (from_symbol(livecheck_strategy) != Sparkle || !url_provided) - # Skip the `Sparkle` strategy if a strategy is specified explicitly + elsif strategy == Sparkle + # Skip the `Sparkle` strategy if another strategy is specified explicitly # or if the URL is not specified explicitly. - next + next unless url_provided + next if livecheck_strategy && from_symbol(livecheck_strategy) != strategy elsif strategy.const_defined?(:PRIORITY) && !strategy::PRIORITY.positive? && from_symbol(livecheck_strategy) != strategy
false
Other
Homebrew
brew
82535696fad17f62c6f82fc4d7f43b9f02225da2.json
Fix code style.
Library/Homebrew/livecheck/strategy/sparkle.rb
@@ -23,10 +23,10 @@ class Sparkle def self.match?(url) return false unless url.match?(%r{^https?://}) - xml = url.end_with?('.xml') + xml = url.end_with?(".xml") xml ||= begin headers = Strategy.page_headers(url) - content_type = headers["content-type"]&.split(';', 2)&.first + content_type = headers["content-type"]&.split(";", 2)&.first ["application/xml", "text/xml"].include?(content_type) end return false unless xml
false
Other
Homebrew
brew
8b7f38faf0e770c8446f328364e639e78307f062.json
Fix code style.
Library/Homebrew/livecheck/livecheck.rb
@@ -477,7 +477,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) strategy ||= strategies.first
true
Other
Homebrew
brew
8b7f38faf0e770c8446f328364e639e78307f062.json
Fix code style.
Library/Homebrew/livecheck/strategy.rb
@@ -62,7 +62,7 @@ def from_url(url, livecheck_strategy: nil, url_provided: nil, regex_provided: ni if strategy == PageMatch # Only treat the `PageMatch` strategy as usable if a regex is # present in the `livecheck` block - next unless (regex_provided || block_provided) + next unless regex_provided || block_provided elsif strategy == Sparkle && (livecheck_strategy || !url_provided) # Skip the `Sparkle` strategy if a strategy is specified explicitly # or if the URL is not specified explicitly.
true
Other
Homebrew
brew
775c2fd245c5a2eb9976885778ff91d7b6c66b35.json
Clarify error message.
Library/Homebrew/livecheck/strategy/page_match.rb
@@ -49,6 +49,8 @@ def self.match?(url) def self.page_matches(url, regex, &block) page = Strategy.page_contents(url) + odebug "Page Contents", page + if block data = { page: page } case (value = block.call(data)) @@ -57,7 +59,7 @@ def self.page_matches(url, regex, &block) when Array return value else - raise TypeError, "Return value of `strategy :page_match` block must be a string or array." + raise TypeError, "Return value of `strategy :page_match` block must be a string or array of strings." end end
false
Other
Homebrew
brew
b3c46ba2b931aa8d6e99eaf1733f0349f2c09a19.json
Allow extracting URL in Sparkle strategy.
Library/Homebrew/livecheck.rb
@@ -67,7 +67,9 @@ def skip? # # @param symbol [Symbol] symbol for the desired strategy # @return [Symbol, nil] - def strategy(symbol = nil) + def strategy(symbol = nil, &block) + @strategy_block = block if block + case symbol when nil @strategy @@ -78,6 +80,8 @@ def strategy(symbol = nil) end end + attr_reader :strategy_block + # Sets the `@url` instance variable to the provided argument or returns the # `@url` instance variable when no argument is provided. The argument can be # a `String` (a URL) or a supported `Symbol` corresponding to a URL in the
true
Other
Homebrew
brew
b3c46ba2b931aa8d6e99eaf1733f0349f2c09a19.json
Allow extracting URL in Sparkle strategy.
Library/Homebrew/livecheck/livecheck.rb
@@ -480,7 +480,7 @@ def latest_version(formula_or_cask, json: false, full_name: false, verbose: fals next if strategy.blank? - strategy_data = strategy.find_versions(url, livecheck_regex) + strategy_data = strategy.find_versions(url, livecheck_regex, &livecheck.strategy_block) match_version_map = strategy_data[:matches] regex = strategy_data[:regex]
true
Other
Homebrew
brew
b3c46ba2b931aa8d6e99eaf1733f0349f2c09a19.json
Allow extracting URL in Sparkle strategy.
Library/Homebrew/livecheck/strategy/sparkle.rb
@@ -1,6 +1,7 @@ # typed: false # frozen_string_literal: true +require "bundle_version" require_relative "page_match" module Homebrew @@ -27,7 +28,7 @@ def self.match?(url) # Checks the content at the URL for new versions. sig { params(url: String, regex: T.nilable(Regexp)).returns(T::Hash[Symbol, T.untyped]) } - def self.find_versions(url, regex) + def self.find_versions(url, regex, &block) raise ArgumentError, "The #{NICE_NAME} strategy does not support regular expressions." if regex require "nokogiri" @@ -39,14 +40,21 @@ def self.find_versions(url, regex) xml = Nokogiri.parse(contents) xml.remove_namespaces! - match = xml.xpath("//rss//channel//item//enclosure") - .map { |enclosure| [*enclosure["shortVersionString"], *enclosure["version"]].uniq } - .reject(&:empty?) - .uniq - .max_by { |versions| versions.map { |v| Version.new(v) } } - &.join(",") + enclosure = + xml.xpath("//rss//channel//item//enclosure") + .map { |e| { url: e["url"], version: BundleVersion.new(e["shortVersionString"], e["version"]) } } + .max_by { |e| e[:version] } - match_data[:matches][match] = Version.new(match) if match + if enclosure + match = if block + enclosure[:version] = Cask::DSL::Version.new(enclosure[:version].nice_version) + block.call(enclosure).to_s + else + enclosure[:version].nice_version + end + + match_data[:matches][match] = Version.new(match) + end match_data end
true
Other
Homebrew
brew
10b5548eace342387afc97f5a809792dbd94b4b5.json
Fix `page_headers` method for multiple headers.
Library/Homebrew/livecheck/strategy.rb
@@ -83,11 +83,27 @@ def from_url(url, livecheck_strategy: nil, regex_provided: nil) def self.page_headers(url) @headers ||= {} - @headers[url] ||= curl_output("--head", "--location", url).stdout - .split("\r\n\r\n", 2).first - .split("\r\n").drop(1) - .map { |header| header.split(/:\s*/, 2) } - .to_h.transform_keys(&:downcase) + + return @headers[url] if @headers.key?(url) + + stdout, _, status = curl_output( + "--head", "--request", "GET", "--silent", "--location", + "--connect-timeout", 5, "--retry-max-time", 15, "--max-time", 10, + url + ) + return {} unless status.success? + + headers = {} + + while stdout.match?(/\AHTTP.*\r$/) + h, stdout = stdout.split("\r\n\r\n", 2) + + headers = headers.merge(h.split("\r\n").drop(1) + .map { |header| header.split(/:\s*/, 2) } + .to_h.transform_keys(&:downcase)) + end + + @headers[url] = headers end def self.page_contents(url)
false
Other
Homebrew
brew
c24af82a25f9ce625a81dbe19a93b0242989ae11.json
Add `Sparkle` livecheck strategy.
Library/Homebrew/livecheck/strategy.rb
@@ -112,4 +112,5 @@ def self.page_contents(url) require_relative "strategy/pypi" require_relative "strategy/follow_redirection" require_relative "strategy/sourceforge" +require_relative "strategy/sparkle" require_relative "strategy/xorg"
true
Other
Homebrew
brew
c24af82a25f9ce625a81dbe19a93b0242989ae11.json
Add `Sparkle` livecheck strategy.
Library/Homebrew/livecheck/strategy/sparkle.rb
@@ -0,0 +1,56 @@ +# typed: false +# frozen_string_literal: true + +require_relative "page_match" + +module Homebrew + module Livecheck + module Strategy + # The {Sparkle} strategy fetches content at a URL and parses + # its contents as a Sparkle appcast in XML format. + # + # @api private + class Sparkle + extend T::Sig + + NICE_NAME = "Sparkle" + + PRIORITY = 1 + + # Whether the strategy can be applied to the provided URL. + sig { params(url: String).returns(T::Boolean) } + def self.match?(url) + url.match?(%r{^https?://}) && + ["application/xml", "text/xml"].include?(Strategy.page_headers(url)["content-type"]) && + Strategy.page_contents(url).include?("http://www.andymatuschak.org/xml-namespaces/sparkle") + end + + # Checks the content at the URL for new versions. + sig { params(url: String, regex: T.nilable(Regexp)).returns(T::Hash[Symbol, T.untyped]) } + def self.find_versions(url, regex) + raise ArgumentError, "The #{NICE_NAME} strategy does not support regular expressions." if regex + + require "nokogiri" + + match_data = { matches: {}, regex: regex, url: url } + + contents = Strategy.page_contents(url) + + xml = Nokogiri.parse(contents) + xml.remove_namespaces! + + match = xml.xpath("//rss//channel//item//enclosure") + .map { |enclosure| [*enclosure["shortVersionString"], *enclosure["version"]].uniq } + .reject(&:empty?) + .uniq + .max_by { |versions| versions.map { |v| Version.new(v) } } + &.join(",") + + match_data[:matches][match] = Version.new(match) if match + + match_data + end + end + end + end +end
true
Other
Homebrew
brew
b293acc89bc1dbc1c8bde6c40cd7dd0bc0cc745c.json
Add `FollowRedirection` livecheck strategy.
Library/Homebrew/livecheck/strategy.rb
@@ -110,5 +110,6 @@ def self.page_contents(url) require_relative "strategy/npm" require_relative "strategy/page_match" require_relative "strategy/pypi" +require_relative "strategy/follow_redirection" require_relative "strategy/sourceforge" require_relative "strategy/xorg"
true
Other
Homebrew
brew
b293acc89bc1dbc1c8bde6c40cd7dd0bc0cc745c.json
Add `FollowRedirection` livecheck strategy.
Library/Homebrew/livecheck/strategy/follow_redirection.rb
@@ -0,0 +1,47 @@ +# typed: false +# frozen_string_literal: true + +require_relative "page_match" + +module Homebrew + module Livecheck + module Strategy + # The {FollowRedirection} strategy follows all URL redirections and scans + # the final URL for matching text using the provided regex. + # + # @api private + class FollowRedirection + extend T::Sig + + NICE_NAME = "Follow HTTP Redirection" + + # We set the priority to zero since this cannot + # be detected automatically. + PRIORITY = 0 + + # Whether the strategy can be applied to the provided URL. + # FollowRedirection will technically match any HTTP URL but is + # only usable with a `livecheck` block containing a regex. + sig { params(url: String).returns(T::Boolean) } + def self.match?(url) + url.match?(%r{^https?://}) + end + + # Checks the final URL for new versions after following all redirections, + # using the provided regex for matching. + sig { params(url: String, regex: T.nilable(Regexp)).returns(T::Hash[Symbol, T.untyped]) } + def self.find_versions(url, regex) + raise ArgumentError, "A regular expression is required for the #{NICE_NAME} strategy." if regex.nil? + + match_data = { matches: {}, regex: regex, url: url } + + if (location = Strategy.page_headers(url)["location"]) && (match = location[regex, 1]) + match_data[:matches][match] = Version.new(match) + end + + match_data + end + end + end + end +end
true
Other
Homebrew
brew
aad02c4524199f6e558609dc4b62860783da8d25.json
shared_audits: add xit to GITHUB_PRERELEASE_ALLOWLIST
Library/Homebrew/utils/shared_audits.rb
@@ -46,6 +46,7 @@ def github_release_data(user, repo, tag) "telegram-cli" => "1.3.1", "toggl-track" => :all, "volta" => "0.8.6", + "xit" => :all, }.freeze def github_release(user, repo, tag, formula: nil, cask: nil)
false
Other
Homebrew
brew
27b7713f1ec1f02d184730c44f9289694bb01e9c.json
Expand tests for Curl#curl_args
Library/Homebrew/test/utils/curl_spec.rb
@@ -3,25 +3,61 @@ require "utils/curl" -describe "curl" do +describe "Utils::Curl" do describe "curl_args" do + let(:args) { "foo" } + let(:user_agent_string) { "Lorem ipsum dolor sit amet" } + it "returns --disable as the first argument when HOMEBREW_CURLRC is not set" do # --disable must be the first argument according to "man curl" - expect(curl_args("foo").first).to eq("--disable") + expect(curl_args(*args).first).to eq("--disable") end - it "doesn't return --disable as the first argument when HOMEBREW_CURLRC is set" do + it "doesn't return `--disable` as the first argument when HOMEBREW_CURLRC is set" do ENV["HOMEBREW_CURLRC"] = "1" - expect(curl_args("foo").first).not_to eq("--disable") + expect(curl_args(*args).first).not_to eq("--disable") end it "uses `--retry 3` when HOMEBREW_CURL_RETRIES is unset" do - expect(curl_args("foo").join(" ")).to include("--retry 3") + expect(curl_args(*args).join(" ")).to include("--retry 3") end it "uses the given value for `--retry` when HOMEBREW_CURL_RETRIES is set" do ENV["HOMEBREW_CURL_RETRIES"] = "10" - expect(curl_args("foo").join(" ")).to include("--retry 10") + expect(curl_args(*args).join(" ")).to include("--retry 10") + end + + it "doesn't use `--retry` when `:retry` == `false`" do + expect(curl_args(*args, retry: false).join(" ")).not_to include("--retry") + end + + it "uses `--retry 3` when `:retry` == `true`" do + expect(curl_args(*args, retry: true).join(" ")).to include("--retry 3") + end + + it "uses HOMEBREW_USER_AGENT_FAKE_SAFARI when `:user_agent` is `:browser` or `:fake`" do + expect(curl_args(*args, user_agent: :browser).join(" ")) + .to include("--user-agent #{HOMEBREW_USER_AGENT_FAKE_SAFARI}") + expect(curl_args(*args, user_agent: :fake).join(" ")) + .to include("--user-agent #{HOMEBREW_USER_AGENT_FAKE_SAFARI}") + end + + it "uses HOMEBREW_USER_AGENT_CURL when `:user_agent` is `:default` or omitted" do + expect(curl_args(*args, user_agent: :default).join(" ")).to include("--user-agent #{HOMEBREW_USER_AGENT_CURL}") + expect(curl_args(*args, user_agent: nil).join(" ")).to include("--user-agent #{HOMEBREW_USER_AGENT_CURL}") + expect(curl_args(*args).join(" ")).to include("--user-agent #{HOMEBREW_USER_AGENT_CURL}") + end + + it "uses provided user agent string when `:user_agent` is a `String`" do + expect(curl_args(*args, user_agent: user_agent_string).join(" ")) + .to include("--user-agent #{user_agent_string}") + end + + it "uses `--fail` unless `:show_output` is `true`" do + expect(curl_args(*args, show_output: false).join(" ")).to include("--fail") + expect(curl_args(*args, show_output: nil).join(" ")).to include("--fail") + expect(curl_args(*args).join(" ")).to include("--fail") + expect(curl_args(*args, show_output: true).join(" ")).not_to include("--fail") end end end
false
Other
Homebrew
brew
e687774e8adf892b0a955c8bc1d3dfef18788579.json
Curl: Allow option to omit `--retry` in curl_args
Library/Homebrew/utils/curl.rb
@@ -21,7 +21,7 @@ def curl_executable @curl end - def curl_args(*extra_args, show_output: false, user_agent: :default) + def curl_args(*extra_args, **options) args = [] # do not load .curlrc unless requested (must be the first argument) @@ -31,25 +31,25 @@ def curl_args(*extra_args, show_output: false, user_agent: :default) args << "--show-error" - args << "--user-agent" << case user_agent + args << "--user-agent" << case options[:user_agent] when :browser, :fake HOMEBREW_USER_AGENT_FAKE_SAFARI - when :default + when :default, nil HOMEBREW_USER_AGENT_CURL - else - user_agent + when String + options[:user_agent] end args << "--header" << "Accept-Language: en" - unless show_output + unless options[:show_output] == true args << "--fail" args << "--progress-bar" unless Context.current.verbose? args << "--verbose" if Homebrew::EnvConfig.curl_verbose? args << "--silent" unless $stdout.tty? end - args << "--retry" << Homebrew::EnvConfig.curl_retries + args << "--retry" << Homebrew::EnvConfig.curl_retries unless options[:retry] == false args + extra_args end
false
Other
Homebrew
brew
9d92ed868b74cfbacab3a1f082bd5c56b8b4802d.json
Curl: Add debug parameter to curl_with_workarounds
Library/Homebrew/utils/curl.rb
@@ -55,12 +55,13 @@ def curl_args(*extra_args, show_output: false, user_agent: :default) end def curl_with_workarounds( - *args, secrets: nil, print_stdout: nil, print_stderr: nil, verbose: nil, env: {}, **options + *args, secrets: nil, print_stdout: nil, print_stderr: nil, debug: nil, verbose: nil, env: {}, **options ) command_options = { secrets: secrets, print_stdout: print_stdout, print_stderr: print_stderr, + debug: debug, verbose: verbose, }.compact
false
Other
Homebrew
brew
d94afb91dd583330cf36dca598929455c152ec39.json
SystemCommand: Add debug parameter
Library/Homebrew/system_command.rb
@@ -74,13 +74,15 @@ def run! must_succeed: T::Boolean, print_stdout: T::Boolean, print_stderr: T::Boolean, + debug: T::Boolean, verbose: T::Boolean, secrets: T.any(String, T::Array[String]), chdir: T.any(String, Pathname), ).void end def initialize(executable, args: [], sudo: false, env: {}, input: [], must_succeed: false, - print_stdout: false, print_stderr: true, verbose: false, secrets: [], chdir: T.unsafe(nil)) + print_stdout: false, print_stderr: true, debug: false, verbose: false, secrets: [], + chdir: T.unsafe(nil)) require "extend/ENV" @executable = executable @args = args @@ -95,6 +97,7 @@ def initialize(executable, args: [], sudo: false, env: {}, input: [], must_succe @must_succeed = must_succeed @print_stdout = print_stdout @print_stderr = print_stderr + @debug = debug @verbose = verbose @secrets = (Array(secrets) + ENV.sensitive_environment.values).uniq @chdir = chdir @@ -111,6 +114,13 @@ def command attr_predicate :sudo?, :print_stdout?, :print_stderr?, :must_succeed? + sig { returns(T::Boolean) } + def debug? + return super if @debug.nil? + + @debug + end + sig { returns(T::Boolean) } def verbose? return super if @verbose.nil?
false
Other
Homebrew
brew
19c118d0026482d9e0a59833570cc9985092cb4d.json
formula: activate env extensions for postinstall
Library/Homebrew/formula.rb
@@ -1049,6 +1049,7 @@ def run_post_install with_env(new_env) do ENV.clear_sensitive_environment! + ENV.activate_extensions! etc_var_dirs = [bottle_prefix/"etc", bottle_prefix/"var"] T.unsafe(Find).find(*etc_var_dirs.select(&:directory?)) do |path|
false
Other
Homebrew
brew
bdfa7a757dbcaddbb1502991b8d2a95530898ce4.json
Hide `parser` warning.
Library/Homebrew/style.rb
@@ -144,10 +144,12 @@ def run_rubocop(files, output_type, args << "--color" if Tty.color? - system cache_env, "rubocop", *args + system cache_env, RUBY_PATH, ENV["HOMEBREW_RUBY_WARNINGS"], "-S", "rubocop", *args $CHILD_STATUS.success? when :json - result = system_command "rubocop", args: ["--format", "json", *args], env: cache_env + result = system_command RUBY_PATH, + args: [ENV["HOMEBREW_RUBY_WARNINGS"], "-S", "rubocop", "--format", "json", *args], + env: cache_env json = json_result!(result) json["files"] end
false
Other
Homebrew
brew
207a45b52623c90408f9eb522b80c48839f276cb.json
Update RBI files for sorbet.
Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi
@@ -6938,10 +6938,6 @@ module FileUtils extend ::FileUtils::StreamUtils_ end -class Formula - include ::Formula::Compat -end - module FormulaCellarChecks extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks @@ -7690,10 +7686,6 @@ class Homebrew::CLI::NamedArgs extend ::T::Private::Methods::SingletonMethodHooks end -class Homebrew::CLI::Parser - include ::Homebrew::CLI::Parser::Compat -end - class Homebrew::CLI::Parser extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks @@ -7770,12 +7762,8 @@ module Homebrew::EnvConfig def self.git_name(); end - def self.github_api_password(); end - def self.github_api_token(); end - def self.github_api_username(); end - def self.http_proxy(); end def self.https_proxy(); end @@ -7857,7 +7845,6 @@ end module Homebrew extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks - extend ::Homebrew::Compat end module HostEnvironmentSimulatorHelper
false
Other
Homebrew
brew
19435e6f1775a03384c17b15ebf4608761d064ba.json
Update RBI files for rubocop-rspec.
Library/Homebrew/sorbet/rbi/gems/rubocop-rspec@2.1.0.rbi
@@ -652,11 +652,11 @@ class RuboCop::Cop::RSpec::FilePath < ::RuboCop::Cop::RSpec::Base def custom_transform; end def ensure_correct_file_path(send_node, described_class, arguments); end def expected_path(constant); end - def filename_ends_with?(glob); end - def glob_for(described_class, method_name); end - def glob_for_spec_suffix_only?; end + def filename_ends_with?(pattern); end def ignore_methods?; end - def name_glob(method_name); end + def name_pattern(method_name); end + def pattern_for(described_class, method_name); end + def pattern_for_spec_suffix_only?; end def relevant_rubocop_rspec_file?(_file); end def routing_spec?(args); end def spec_suffix_only?; end @@ -669,14 +669,19 @@ module RuboCop::Cop::RSpec::FinalEndLocation end class RuboCop::Cop::RSpec::Focus < ::RuboCop::Cop::RSpec::Base + include(::RuboCop::Cop::RangeHelp) + extend(::RuboCop::Cop::AutoCorrector) + def focusable_selector?(param0 = T.unsafe(nil)); end def focused_block?(param0 = T.unsafe(nil)); end def metadata(param0 = T.unsafe(nil)); end def on_send(node); end private + def correct_send(corrector, focus); end def focus_metadata(node, &block); end + def with_surrounding(focus); end end RuboCop::Cop::RSpec::Focus::MSG = T.let(T.unsafe(nil), String)
true
Other
Homebrew
brew
19435e6f1775a03384c17b15ebf4608761d064ba.json
Update RBI files for rubocop-rspec.
Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi
@@ -6938,10 +6938,6 @@ module FileUtils extend ::FileUtils::StreamUtils_ end -class Formula - include ::Formula::Compat -end - module FormulaCellarChecks extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks @@ -7690,10 +7686,6 @@ class Homebrew::CLI::NamedArgs extend ::T::Private::Methods::SingletonMethodHooks end -class Homebrew::CLI::Parser - include ::Homebrew::CLI::Parser::Compat -end - class Homebrew::CLI::Parser extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks @@ -7770,12 +7762,8 @@ module Homebrew::EnvConfig def self.git_name(); end - def self.github_api_password(); end - def self.github_api_token(); end - def self.github_api_username(); end - def self.http_proxy(); end def self.https_proxy(); end @@ -7857,7 +7845,6 @@ end module Homebrew extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks - extend ::Homebrew::Compat end module HostEnvironmentSimulatorHelper
true
Other
Homebrew
brew
2dd40720f075bf93551a27fe0be64c96312632fd.json
Add test for `SystemCommand` with `SIGINT` handler.
Library/Homebrew/test/spec_helper.rb
@@ -165,34 +165,37 @@ config.around do |example| def find_files + return [] unless File.exist?(TEST_TMPDIR) + Find.find(TEST_TMPDIR) .reject { |f| File.basename(f) == ".DS_Store" } + .reject { |f| TEST_DIRECTORIES.include?(Pathname(f)) } .map { |f| f.sub(TEST_TMPDIR, "") } end - begin - Homebrew.raise_deprecation_exceptions = true + Homebrew.raise_deprecation_exceptions = true - Formulary.clear_cache - Tap.clear_cache - DependencyCollector.clear_cache - Formula.clear_cache - Keg.clear_cache - Tab.clear_cache - FormulaInstaller.clear_attempted - FormulaInstaller.clear_installed + Formulary.clear_cache + Tap.clear_cache + DependencyCollector.clear_cache + Formula.clear_cache + Keg.clear_cache + Tab.clear_cache + FormulaInstaller.clear_attempted + FormulaInstaller.clear_installed - TEST_DIRECTORIES.each(&:mkpath) + TEST_DIRECTORIES.each(&:mkpath) - @__homebrew_failed = Homebrew.failed? + @__homebrew_failed = Homebrew.failed? - @__files_before_test = find_files + @__files_before_test = find_files - @__env = ENV.to_hash # dup doesn't work on ENV + @__env = ENV.to_hash # dup doesn't work on ENV - @__stdout = $stdout.clone - @__stderr = $stderr.clone + @__stdout = $stdout.clone + @__stderr = $stderr.clone + begin if (example.metadata.keys & [:focus, :byebug]).empty? && !ENV.key?("VERBOSE_TESTS") $stdout.reopen(File::NULL) $stderr.reopen(File::NULL) @@ -224,7 +227,7 @@ def find_files Tab.clear_cache FileUtils.rm_rf [ - TEST_DIRECTORIES.map(&:children), + *TEST_DIRECTORIES, *Keg::MUST_EXIST_SUBDIRECTORIES, HOMEBREW_LINKED_KEGS, HOMEBREW_PINNED_KEGS,
true
Other
Homebrew
brew
2dd40720f075bf93551a27fe0be64c96312632fd.json
Add test for `SystemCommand` with `SIGINT` handler.
Library/Homebrew/test/system_command_spec.rb
@@ -281,5 +281,28 @@ }.to raise_error.with_message(redacted_msg).and output(redacted_msg).to_stderr end end + + context "when a `SIGINT` handler is set in the parent process" do + it "is not interrupted" do + start_time = Time.now + + pid = fork do + trap("INT") do + # Ignore SIGINT. + end + + described_class.run! "sleep", args: [5] + + exit! + end + + sleep 1 + Process.kill("INT", pid) + + Process.waitpid(pid) + + expect(Time.now - start_time).to be >= 5 + end + end end end
true
Other
Homebrew
brew
3db55d13d6996df22a0169df4dbbc8f854b2f051.json
Improve handling of SIGINT.
Library/Homebrew/dev-cmd/ruby.rb
@@ -32,14 +32,10 @@ def ruby ruby_sys_args << "-e #{args.e}" if args.e ruby_sys_args += args.named - begin - safe_system RUBY_PATH, - ENV["HOMEBREW_RUBY_WARNINGS"], - "-I", $LOAD_PATH.join(File::PATH_SEPARATOR), - "-rglobal", "-rdev-cmd/irb", - *ruby_sys_args - rescue ErrorDuringExecution => e - exit e.status.exitstatus - end + exec RUBY_PATH, + ENV["HOMEBREW_RUBY_WARNINGS"], + "-I", $LOAD_PATH.join(File::PATH_SEPARATOR), + "-rglobal", "-rdev-cmd/irb", + *ruby_sys_args end end
true
Other
Homebrew
brew
3db55d13d6996df22a0169df4dbbc8f854b2f051.json
Improve handling of SIGINT.
Library/Homebrew/exceptions.rb
@@ -578,14 +578,24 @@ def initialize(cmd, status:, output: nil, secrets: []) @status = status @output = output - exitstatus = if status.respond_to?(:exitstatus) - status.exitstatus - else + exitstatus = case status + when Integer status + else + status.exitstatus end redacted_cmd = redact_secrets(cmd.shelljoin.gsub('\=', "="), secrets) - s = +"Failure while executing; `#{redacted_cmd}` exited with #{exitstatus}." + + reason = if exitstatus + "exited with #{exitstatus}" + elsif (uncaught_signal = status.termsig) + "was terminated by uncaught signal #{Signal.signame(uncaught_signal)}" + else + raise ArgumentError, "Status does neither have `exitstatus` nor `termsig`." + end + + s = +"Failure while executing; `#{redacted_cmd}` #{reason}." if Array(output).present? format_output_line = lambda do |type_line|
true
Other
Homebrew
brew
3db55d13d6996df22a0169df4dbbc8f854b2f051.json
Improve handling of SIGINT.
Library/Homebrew/system_command.rb
@@ -20,6 +20,8 @@ class SystemCommand # Helper functions for calling {SystemCommand.run}. module Mixin + extend T::Sig + def system_command(*args) T.unsafe(SystemCommand).run(*args) end @@ -32,8 +34,6 @@ def system_command!(*args) include Context extend Predicable - attr_reader :pid - def self.run(executable, **options) T.unsafe(self).new(executable, **options).run! end @@ -44,7 +44,7 @@ def self.run!(command, **options) sig { returns(SystemCommand::Result) } def run! - puts redact_secrets(command.shelljoin.gsub('\=', "="), @secrets) if verbose? || debug? + $stderr.puts redact_secrets(command.shelljoin.gsub('\=', "="), @secrets) if verbose? || debug? @output = [] @@ -152,28 +152,42 @@ def expanded_args end end - def each_output_line(&b) + sig { params(block: T.proc.params(type: Symbol, line: String).void).void } + def each_output_line(&block) executable, *args = command - - raw_stdin, raw_stdout, raw_stderr, raw_wait_thr = - T.unsafe(Open3).popen3(env, [executable, executable], *args, **{ chdir: chdir }.compact) - @pid = raw_wait_thr.pid + options = { + # Create a new process group so that we can send `SIGINT` from + # parent to child rather than the child receiving `SIGINT` directly. + pgroup: true, + } + options[:chdir] = chdir if chdir + + pid = T.let(nil, T.nilable(Integer)) + raw_stdin, raw_stdout, raw_stderr, raw_wait_thr = ignore_interrupts do + T.unsafe(Open3).popen3(env, [executable, executable], *args, **options) + .tap { |*, wait_thr| pid = wait_thr.pid } + end write_input_to(raw_stdin) raw_stdin.close_write - each_line_from [raw_stdout, raw_stderr], &b + each_line_from [raw_stdout, raw_stderr], &block @status = raw_wait_thr.value + rescue Interrupt + Process.kill("INT", pid) if pid + raise Interrupt rescue SystemCallError => e @status = $CHILD_STATUS @output << [:stderr, e.message] end + sig { params(raw_stdin: IO).void } def write_input_to(raw_stdin) input.each(&raw_stdin.method(:write)) end - def each_line_from(sources) + sig { params(sources: T::Array[IO], _block: T.proc.params(type: Symbol, line: String).void).void } + def each_line_from(sources, &_block) loop do readable_sources, = IO.select(sources)
true
Other
Homebrew
brew
3db55d13d6996df22a0169df4dbbc8f854b2f051.json
Improve handling of SIGINT.
Library/Homebrew/test/system_command_spec.rb
@@ -24,7 +24,11 @@ it "includes the given variables explicitly" do expect(Open3) .to receive(:popen3) - .with(an_instance_of(Hash), ["/usr/bin/env", "/usr/bin/env"], "A=1", "B=2", "C=3", "env", *env_args, {}) + .with( + an_instance_of(Hash), ["/usr/bin/env", "/usr/bin/env"], "A=1", "B=2", "C=3", + "env", *env_args, + pgroup: true + ) .and_call_original command.run! @@ -49,8 +53,10 @@ it "includes the given variables explicitly" do expect(Open3) .to receive(:popen3) - .with(an_instance_of(Hash), ["/usr/bin/sudo", "/usr/bin/sudo"], "-E", "--", - "/usr/bin/env", "A=1", "B=2", "C=3", "env", *env_args, {}) + .with( + an_instance_of(Hash), ["/usr/bin/sudo", "/usr/bin/sudo"], "-E", "--", + "/usr/bin/env", "A=1", "B=2", "C=3", "env", *env_args, pgroup: true + ) .and_wrap_original do |original_popen3, *_, &block| original_popen3.call("true", &block) end @@ -257,24 +263,22 @@ context "when given arguments with secrets" do it "does not leak the secrets" do redacted_msg = /#{Regexp.escape("username:******")}/ - expect do + expect { described_class.run! "curl", args: %w[--user username:hunter2], verbose: true, secrets: %w[hunter2] - end.to raise_error.with_message(redacted_msg).and output(redacted_msg).to_stdout + }.to raise_error.with_message(redacted_msg).and output(redacted_msg).to_stderr end it "does not leak the secrets set by environment" do redacted_msg = /#{Regexp.escape("username:******")}/ - expect do + expect { ENV["PASSWORD"] = "hunter2" described_class.run! "curl", args: %w[--user username:hunter2], verbose: true - ensure - ENV.delete "PASSWORD" - end.to raise_error.with_message(redacted_msg).and output(redacted_msg).to_stdout + }.to raise_error.with_message(redacted_msg).and output(redacted_msg).to_stderr end end end
true
Other
Homebrew
brew
3db55d13d6996df22a0169df4dbbc8f854b2f051.json
Improve handling of SIGINT.
Library/Homebrew/utils.rb
@@ -388,13 +388,30 @@ def archs_for_command(cmd) Pathname.new(cmd).archs end - def ignore_interrupts(opt = nil) - std_trap = trap("INT") do - puts "One sec, just cleaning up" unless opt == :quietly + def ignore_interrupts(_opt = nil) + # rubocop:disable Style/GlobalVars + $ignore_interrupts_nesting_level = 0 unless defined?($ignore_interrupts_nesting_level) + $ignore_interrupts_nesting_level += 1 + + $ignore_interrupts_interrupted = false unless defined?($ignore_interrupts_interrupted) + old_sigint_handler = trap(:INT) do + $ignore_interrupts_interrupted = true + $stderr.print "\n" + $stderr.puts "One sec, cleaning up..." end - yield - ensure - trap("INT", std_trap) + + begin + yield + ensure + trap(:INT, old_sigint_handler) + + $ignore_interrupts_nesting_level -= 1 + if $ignore_interrupts_nesting_level == 0 && $ignore_interrupts_interrupted + $ignore_interrupts_interrupted = false + raise Interrupt + end + end + # rubocop:enable Style/GlobalVars end sig { returns(String) }
true
Other
Homebrew
brew
2777369da798dad955d1dd03723425e8d105ebed.json
formula_installer: exclude more from build-from-source warning. We should only complain when installing requested formulae that aren't currently installed.
Library/Homebrew/formula_installer.rb
@@ -234,7 +234,8 @@ def check_install_sanity if Homebrew.default_prefix? && !Homebrew::EnvConfig.developer? && !build_from_source? && !build_bottle? && - formula.tap&.core_tap? && !formula.bottle_unneeded? && + !installed_as_dependency? && + formula.tap&.core_tap? && !formula.bottle_unneeded? && !formula.any_version_installed? && # Integration tests override homebrew-core locations ENV["HOMEBREW_TEST_TMPDIR"].nil? && !pour_bottle? @@ -684,6 +685,7 @@ def fetch_dependency(dep) # been done for us in `compute_dependencies` and there's no requirement to # fetch in a particular order. ignore_deps: true, + installed_as_dependency: true, include_test_formulae: @include_test_formulae, build_from_source_formulae: @build_from_source_formulae, keep_tmp: keep_tmp?,
false
Other
Homebrew
brew
e2d032a6b6c765e0a6311a84a7b70f5ddf12b665.json
keg_relocate: ensure @@HOMEBREW_REPOSITORY@@ is always relocated. This will be needed to pour older bottles after 2.7.0.
Library/Homebrew/keg_relocate.rb
@@ -4,16 +4,15 @@ class Keg PREFIX_PLACEHOLDER = "@@HOMEBREW_PREFIX@@" CELLAR_PLACEHOLDER = "@@HOMEBREW_CELLAR@@" + REPOSITORY_PLACEHOLDER = "@@HOMEBREW_REPOSITORY@@" LIBRARY_PLACEHOLDER = "@@HOMEBREW_LIBRARY@@" - # TODO: delete these after Homebrew 2.7.0 is released. - REPOSITORY_PLACEHOLDER = "@@HOMEBREW_REPOSITORY@@" + # TODO: delete this after Homebrew 2.7.0 is released. REPOSITORY_LIBRARY_PLACEHOLDER = "#{REPOSITORY_PLACEHOLDER}/Library" - Relocation = Struct.new(:old_prefix, :old_cellar, :old_library, - :new_prefix, :new_cellar, :new_library, + Relocation = Struct.new(:old_prefix, :old_cellar, :old_repository, :old_library, + :new_prefix, :new_cellar, :new_repository, :new_library, # TODO: delete these after Homebrew 2.7.0 is released. - :old_repository, :new_repository, :old_repository_library, :new_repository_library) do # Use keyword args instead of positional args for initialization. def initialize(**kwargs) @@ -65,13 +64,13 @@ def replace_placeholders_with_locations(files, skip_linkage: false) relocation = Relocation.new( old_prefix: PREFIX_PLACEHOLDER, old_cellar: CELLAR_PLACEHOLDER, + old_repository: REPOSITORY_PLACEHOLDER, old_library: LIBRARY_PLACEHOLDER, new_prefix: HOMEBREW_PREFIX.to_s, new_cellar: HOMEBREW_CELLAR.to_s, + new_repository: HOMEBREW_REPOSITORY.to_s, new_library: HOMEBREW_LIBRARY.to_s, # TODO: delete these after Homebrew 2.7.0 is released. - old_repository: REPOSITORY_PLACEHOLDER, - new_repository: HOMEBREW_REPOSITORY.to_s, old_repository_library: REPOSITORY_LIBRARY_PLACEHOLDER, new_repository_library: HOMEBREW_LIBRARY.to_s, ) @@ -95,7 +94,6 @@ def replace_text_in_files(relocation, files: nil) }.compact # when HOMEBREW_PREFIX == HOMEBREW_REPOSITORY we should use HOMEBREW_PREFIX for all relocations to avoid # being unable to differentiate between them. - # TODO: delete this after Homebrew 2.7.0 is released. replacements[relocation.old_repository] = relocation.new_repository if HOMEBREW_PREFIX != HOMEBREW_REPOSITORY changed = s.gsub!(Regexp.union(replacements.keys.sort_by(&:length).reverse), replacements) next unless changed
false
Other
Homebrew
brew
09c3058618a5f938f5d648a5dc510bd3f770cf3f.json
Remove basic authentication support for GitHub. Since we (and GitHub) no longer support password authentication using non-token passwords, always set the Authorization header, rather than needlessly checking for a (possibly incorrect) username.
Library/Homebrew/dev-cmd/pr-pull.rb
@@ -343,15 +343,10 @@ def changed_formulae(tap, original_commit) end def download_artifact(url, dir, pr) - token, username = GitHub.api_credentials - case GitHub.api_credentials_type - when :env_username_password, :keychain_username_password - curl_args = ["--user", "#{username}:#{token}"] - when :env_token - curl_args = ["--header", "Authorization: token #{token}"] - when :none - raise "Credentials must be set to access the Artifacts API" - end + raise "Credentials must be set to access the Artifacts API" if GitHub.api_credentials_type == :none + + token = GitHub.api_credentials + curl_args = ["--header", "Authorization: token #{token}"] # Download the artifact as a zip file and unpack it into `dir`. This is # preferred over system `curl` and `tar` as this leverages the Homebrew
true
Other
Homebrew
brew
09c3058618a5f938f5d648a5dc510bd3f770cf3f.json
Remove basic authentication support for GitHub. Since we (and GitHub) no longer support password authentication using non-token passwords, always set the Authorization header, rather than needlessly checking for a (possibly incorrect) username.
Library/Homebrew/utils/github.rb
@@ -99,6 +99,9 @@ def env_username_password odisabled "the GitHub API with HOMEBREW_GITHUB_API_PASSWORD", "HOMEBREW_GITHUB_API_TOKEN" end + # Gets the password field from `git-credential-osxkeychain` for github.com, + # but only if that password looks like a GitHub Personal Access Token. + sig { returns(T.nilable(String)) } def keychain_username_password github_credentials = Utils.popen(["git", "credential-osxkeychain", "get"], "w+") do |pipe| pipe.write "protocol=https\nhost=github.com\n" @@ -114,7 +117,7 @@ def keychain_username_password # https://github.com/Homebrew/brew/issues/6862#issuecomment-572610344 return unless /^[a-f0-9]{40}$/i.match?(github_password) - [github_password, github_username] + github_password rescue Errno::EPIPE # The above invocation via `Utils.popen` can fail, causing the pipe to be # prematurely closed (before we can write to it) and thus resulting in a @@ -182,13 +185,8 @@ def open_api(url, data: nil, data_binary_path: nil, request_method: nil, scopes: args = ["--header", "Accept: application/vnd.github.v3+json", "--write-out", "\n%\{http_code}"] args += ["--header", "Accept: application/vnd.github.antiope-preview+json"] - token, username = api_credentials - case api_credentials_type - when :env_username_password, :keychain_username_password - args += ["--user", "#{username}:#{token}"] - when :env_token - args += ["--header", "Authorization: token #{token}"] - end + token = api_credentials + args += ["--header", "Authorization: token #{token}"] unless api_credentials_type == :none data_tmpfile = nil if data @@ -379,12 +377,7 @@ def create_fork(repo) def check_fork_exists(repo) _, reponame = repo.split("/") - case api_credentials_type - when :env_username_password, :keychain_username_password - _, username = api_credentials - when :env_token - username = open_api(url_to("user")) { |json| json["login"] } - end + username = open_api(url_to("user")) { |json| json["login"] } json = open_api(url_to("repos", username, reponame)) return false if json["message"] == "Not Found"
true
Other
Homebrew
brew
7be216fcbec3021df87fb37b17bbbd91202af6f5.json
change function name
Library/Homebrew/cli/args.rb
@@ -133,7 +133,7 @@ def context Context::ContextStruct.new(debug: debug?, quiet: quiet?, verbose: verbose?) end - def only_path_formula_or_cask + def only_formula_or_cask return :formula if formula? && !cask? return :cask if cask? && !formula? end
true
Other
Homebrew
brew
7be216fcbec3021df87fb37b17bbbd91202af6f5.json
change function name
Library/Homebrew/cmd/fetch.rb
@@ -81,7 +81,7 @@ def fetch end end else - args.named.to_formulae_and_casks(only: args.only_path_formula_or_cask) + args.named.to_formulae_and_casks(only: args.only_formula_or_cask) end.uniq puts "Fetching: #{bucket * ", "}" if bucket.size > 1
true
Other
Homebrew
brew
7be216fcbec3021df87fb37b17bbbd91202af6f5.json
change function name
Library/Homebrew/cmd/home.rb
@@ -35,7 +35,7 @@ def home return end - homepages = args.named.to_formulae_and_casks(only: args.only_path_formula_or_cask).map do |formula_or_cask| + homepages = args.named.to_formulae_and_casks(only: args.only_formula_or_cask).map do |formula_or_cask| puts "Opening homepage for #{name_of(formula_or_cask)}" formula_or_cask.homepage end
true
Other
Homebrew
brew
7be216fcbec3021df87fb37b17bbbd91202af6f5.json
change function name
Library/Homebrew/cmd/info.rb
@@ -90,17 +90,17 @@ def info end end - print_analytics(args: args, only: args.only_path_formula_or_cask) + print_analytics(args: args, only: args.only_formula_or_cask) elsif args.json - print_json(args: args, only: args.only_path_formula_or_cask) + print_json(args: args, only: args.only_formula_or_cask) elsif args.github? raise FormulaOrCaskUnspecifiedError if args.no_named? - exec_browser(*args.named.to_formulae_and_casks(only: args.only_path_formula_or_cask).map { |f| github_info(f) }) + exec_browser(*args.named.to_formulae_and_casks(only: args.only_formula_or_cask).map { |f| github_info(f) }) elsif args.no_named? print_statistics else - print_info(args: args, only: args.only_path_formula_or_cask) + print_info(args: args, only: args.only_formula_or_cask) end end @@ -119,7 +119,7 @@ def print_analytics(args:, only: nil) return end - args.named.to_formulae_and_casks_and_unavailable(only: args.only_path_formula_or_cask).each_with_index do |obj, i| + args.named.to_formulae_and_casks_and_unavailable(only: args.only_formula_or_cask).each_with_index do |obj, i| puts unless i.zero? case obj @@ -137,7 +137,7 @@ def print_analytics(args:, only: nil) sig { params(args: CLI::Args, only: T.nilable(Symbol)).void } def print_info(args:, only: nil) - args.named.to_formulae_and_casks_and_unavailable(only: args.only_path_formula_or_cask).each_with_index do |obj, i| + args.named.to_formulae_and_casks_and_unavailable(only: args.only_formula_or_cask).each_with_index do |obj, i| puts unless i.zero? case obj @@ -192,7 +192,7 @@ def print_json(args:, only: nil) elsif args.installed? [Formula.installed.sort, Cask::Caskroom.casks.sort_by(&:full_name)] else - args.named.to_formulae_to_casks(only: args.only_path_formula_or_cask) + args.named.to_formulae_to_casks(only: args.only_formula_or_cask) end {
true
Other
Homebrew
brew
7be216fcbec3021df87fb37b17bbbd91202af6f5.json
change function name
Library/Homebrew/cmd/install.rb
@@ -148,7 +148,7 @@ def install EOS end - formulae, casks = args.named.to_formulae_and_casks(only: args.only_path_formula_or_cask) + formulae, casks = args.named.to_formulae_and_casks(only: args.only_formula_or_cask) .partition { |formula_or_cask| formula_or_cask.is_a?(Formula) } if casks.any?
true
Other
Homebrew
brew
7be216fcbec3021df87fb37b17bbbd91202af6f5.json
change function name
Library/Homebrew/cmd/uninstall.rb
@@ -48,7 +48,7 @@ def uninstall args = uninstall_args.parse all_kegs, casks = args.named.to_kegs_to_casks( - only: args.only_path_formula_or_cask, + only: args.only_formula_or_cask, ignore_unavailable: args.force?, all_kegs: args.force?, )
true
Other
Homebrew
brew
7be216fcbec3021df87fb37b17bbbd91202af6f5.json
change function name
Library/Homebrew/cmd/upgrade.rb
@@ -95,7 +95,7 @@ def upgrade_args def upgrade args = upgrade_args.parse - formulae, casks = args.named.to_resolved_formulae_to_casks(only: args.only_path_formula_or_cask) + formulae, casks = args.named.to_resolved_formulae_to_casks(only: args.only_formula_or_cask) # If one or more formulae are specified, but no casks were # specified, we want to make note of that so we don't # try to upgrade all outdated casks.
true