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
3d423b0587d54029cc60616d506318425c22e7a4.json
Add `path` method to `Caskroom` and `Cache`.
Library/Homebrew/compat/hbc/caskroom.rb
@@ -3,42 +3,42 @@ module Caskroom class << self module Compat def migrate_legacy_caskroom - return if Hbc.caskroom.exist? + return if path.exist? - legacy_caskroom = Pathname.new("/opt/homebrew-cask/Caskroom") - return if Hbc.caskroom == legacy_caskroom - return unless legacy_caskroom.exist? - return if legacy_caskroom.symlink? + legacy_caskroom_path = Pathname.new("/opt/homebrew-cask/Caskroom") + return if path == legacy_caskroom_path + return unless legacy_caskroom_path.exist? + return if legacy_caskroom_path.symlink? - ohai "Migrating Caskroom from #{legacy_caskroom} to #{Hbc.caskroom}." - if Hbc.caskroom.parent.writable? - FileUtils.mv legacy_caskroom, Hbc.caskroom + ohai "Migrating Caskroom from #{legacy_caskroom_path} to #{path}." + if path.parent.writable? + FileUtils.mv legacy_caskroom_path, path else - opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom." - SystemCommand.run("/bin/mv", args: [legacy_caskroom, Hbc.caskroom.parent], sudo: true) + opoo "#{path.parent} is not writable, sudo is needed to move the Caskroom." + SystemCommand.run("/bin/mv", args: [legacy_caskroom_path, path.parent], sudo: true) end - ohai "Creating symlink from #{Hbc.caskroom} to #{legacy_caskroom}." - if legacy_caskroom.parent.writable? - FileUtils.ln_s Hbc.caskroom, legacy_caskroom + ohai "Creating symlink from #{path} to #{legacy_caskroom_path}." + if legacy_caskroom_path.parent.writable? + FileUtils.ln_s path, legacy_caskroom_path else - opoo "#{legacy_caskroom.parent} is not writable, sudo is needed to link the Caskroom." - SystemCommand.run("/bin/ln", args: ["-s", Hbc.caskroom, legacy_caskroom], sudo: true) + opoo "#{legacy_caskroom_path.parent} is not writable, sudo is needed to link the Caskroom." + SystemCommand.run("/bin/ln", args: ["-s", path, legacy_caskroom_path], sudo: true) end end def migrate_caskroom_from_repo_to_prefix - repo_caskroom = HOMEBREW_REPOSITORY.join("Caskroom") - return if Hbc.caskroom.exist? - return unless repo_caskroom.directory? + repo_caskroom_path = HOMEBREW_REPOSITORY.join("Caskroom") + return if path.exist? + return unless repo_caskroom_path.directory? ohai "Moving Caskroom from HOMEBREW_REPOSITORY to HOMEBREW_PREFIX" - if Hbc.caskroom.parent.writable? - FileUtils.mv repo_caskroom, Hbc.caskroom + if path.parent.writable? + FileUtils.mv repo_caskroom_path, path else - opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom." - SystemCommand.run("/bin/mv", args: [repo_caskroom, Hbc.caskroom.parent], sudo: true) + opoo "#{path.parent} is not writable, sudo is needed to move the Caskroom." + SystemCommand.run("/bin/mv", args: [repo_caskroom_path, path.parent], sudo: true) end end end
true
Other
Homebrew
brew
3d423b0587d54029cc60616d506318425c22e7a4.json
Add `path` method to `Caskroom` and `Cache`.
Library/Homebrew/test/cask/cask_spec.rb
@@ -74,7 +74,7 @@ it "proposes a versioned metadata directory name for each instance" do cask_token = "local-caffeine" c = Hbc::CaskLoader.load(cask_token) - metadata_timestamped_path = Hbc.caskroom.join(cask_token, ".metadata", c.version) + metadata_timestamped_path = Hbc::Caskroom.path.join(cask_token, ".metadata", c.version) expect(c.metadata_versioned_path.to_s).to eq(metadata_timestamped_path.to_s) end end
true
Other
Homebrew
brew
3d423b0587d54029cc60616d506318425c22e7a4.json
Add `path` method to `Caskroom` and `Cache`.
Library/Homebrew/test/cask/cli/uninstall_spec.rb
@@ -103,7 +103,7 @@ [last_installed_version, "456000"], ] } - let(:caskroom_path) { Hbc.caskroom.join(token).tap(&:mkpath) } + let(:caskroom_path) { Hbc::Caskroom.path.join(token).tap(&:mkpath) } before do timestamped_versions.each do |timestamped_version| @@ -143,7 +143,7 @@ describe "when Casks in Taps have been renamed or removed" do let(:app) { Hbc::Config.global.appdir.join("ive-been-renamed.app") } - let(:caskroom_path) { Hbc.caskroom.join("ive-been-renamed").tap(&:mkpath) } + let(:caskroom_path) { Hbc::Caskroom.path.join("ive-been-renamed").tap(&:mkpath) } let(:saved_caskfile) { caskroom_path.join(".metadata", "latest", "timestamp", "Casks").join("ive-been-renamed.rb") } before do
true
Other
Homebrew
brew
3d423b0587d54029cc60616d506318425c22e7a4.json
Add `path` method to `Caskroom` and `Cache`.
Library/Homebrew/test/cask/installer_spec.rb
@@ -9,7 +9,7 @@ Hbc::Installer.new(caffeine).install - expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).to be_a_directory + expect(Hbc::Caskroom.path.join("local-caffeine", caffeine.version)).to be_a_directory expect(Hbc::Config.global.appdir.join("Caffeine.app")).to be_a_directory end @@ -18,7 +18,7 @@ Hbc::Installer.new(asset).install - expect(Hbc.caskroom.join("container-dmg", asset.version)).to be_a_directory + expect(Hbc::Caskroom.path.join("container-dmg", asset.version)).to be_a_directory expect(Hbc::Config.global.appdir.join("container")).to be_a_file end @@ -27,7 +27,7 @@ Hbc::Installer.new(asset).install - expect(Hbc.caskroom.join("container-tar-gz", asset.version)).to be_a_directory + expect(Hbc::Caskroom.path.join("container-tar-gz", asset.version)).to be_a_directory expect(Hbc::Config.global.appdir.join("container")).to be_a_file end @@ -36,7 +36,7 @@ Hbc::Installer.new(asset).install - expect(Hbc.caskroom.join("container-xar", asset.version)).to be_a_directory + expect(Hbc::Caskroom.path.join("container-xar", asset.version)).to be_a_directory expect(Hbc::Config.global.appdir.join("container")).to be_a_file end @@ -45,7 +45,7 @@ Hbc::Installer.new(asset).install - expect(Hbc.caskroom.join("container-bzip2", asset.version)).to be_a_directory + expect(Hbc::Caskroom.path.join("container-bzip2", asset.version)).to be_a_directory expect(Hbc::Config.global.appdir.join("container-bzip2--#{asset.version}")).to be_a_file end @@ -54,7 +54,7 @@ Hbc::Installer.new(asset).install - expect(Hbc.caskroom.join("container-gzip", asset.version)).to be_a_directory + expect(Hbc::Caskroom.path.join("container-gzip", asset.version)).to be_a_directory expect(Hbc::Config.global.appdir.join("container")).to be_a_file end @@ -167,15 +167,15 @@ Hbc::Installer.new(naked_pkg).install - expect(Hbc.caskroom.join("container-pkg", naked_pkg.version, "container.pkg")).to be_a_file + expect(Hbc::Caskroom.path.join("container-pkg", naked_pkg.version, "container.pkg")).to be_a_file end it "works properly with an overridden container :type" do naked_executable = Hbc::CaskLoader.load(cask_path("naked-executable")) Hbc::Installer.new(naked_executable).install - expect(Hbc.caskroom.join("naked-executable", naked_executable.version, "naked_executable")).to be_a_file + expect(Hbc::Caskroom.path.join("naked-executable", naked_executable.version, "naked_executable")).to be_a_file end it "works fine with a nested container" do @@ -214,9 +214,9 @@ installer.install installer.uninstall - expect(Hbc.caskroom.join("local-caffeine", caffeine.version, "Caffeine.app")).not_to be_a_directory - expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).not_to be_a_directory - expect(Hbc.caskroom.join("local-caffeine")).not_to be_a_directory + expect(Hbc::Caskroom.path.join("local-caffeine", caffeine.version, "Caffeine.app")).not_to be_a_directory + expect(Hbc::Caskroom.path.join("local-caffeine", caffeine.version)).not_to be_a_directory + expect(Hbc::Caskroom.path.join("local-caffeine")).not_to be_a_directory end it "uninstalls all versions if force is set" do @@ -225,17 +225,17 @@ Hbc::Installer.new(caffeine).install - expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).to be_a_directory - expect(Hbc.caskroom.join("local-caffeine", mutated_version)).not_to be_a_directory - FileUtils.mv(Hbc.caskroom.join("local-caffeine", caffeine.version), Hbc.caskroom.join("local-caffeine", mutated_version)) - expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).not_to be_a_directory - expect(Hbc.caskroom.join("local-caffeine", mutated_version)).to be_a_directory + expect(Hbc::Caskroom.path.join("local-caffeine", caffeine.version)).to be_a_directory + expect(Hbc::Caskroom.path.join("local-caffeine", mutated_version)).not_to be_a_directory + FileUtils.mv(Hbc::Caskroom.path.join("local-caffeine", caffeine.version), Hbc::Caskroom.path.join("local-caffeine", mutated_version)) + expect(Hbc::Caskroom.path.join("local-caffeine", caffeine.version)).not_to be_a_directory + expect(Hbc::Caskroom.path.join("local-caffeine", mutated_version)).to be_a_directory Hbc::Installer.new(caffeine, force: true).uninstall - expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).not_to be_a_directory - expect(Hbc.caskroom.join("local-caffeine", mutated_version)).not_to be_a_directory - expect(Hbc.caskroom.join("local-caffeine")).not_to be_a_directory + expect(Hbc::Caskroom.path.join("local-caffeine", caffeine.version)).not_to be_a_directory + expect(Hbc::Caskroom.path.join("local-caffeine", mutated_version)).not_to be_a_directory + expect(Hbc::Caskroom.path.join("local-caffeine")).not_to be_a_directory end end end
true
Other
Homebrew
brew
3d423b0587d54029cc60616d506318425c22e7a4.json
Add `path` method to `Caskroom` and `Cache`.
Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb
@@ -23,7 +23,7 @@ begin HOMEBREW_CASK_DIRS.values.each(&:mkpath) - [Hbc::Config.global.binarydir, Hbc.caskroom, Hbc.cache].each(&:mkpath) + [Hbc::Config.global.binarydir, Hbc::Caskroom.path, Hbc::Cache.path].each(&:mkpath) Hbc.default_tap = Tap.fetch("Homebrew", "cask-spec").tap do |tap| FileUtils.mkdir_p tap.path.dirname @@ -38,7 +38,7 @@ example.run ensure FileUtils.rm_rf HOMEBREW_CASK_DIRS.values - FileUtils.rm_rf [Hbc::Config.global.binarydir, Hbc.caskroom, Hbc.cache] + FileUtils.rm_rf [Hbc::Config.global.binarydir, Hbc::Caskroom.path, Hbc::Cache.path] Hbc.default_tap.path.unlink third_party_tap.path.unlink FileUtils.rm_rf third_party_tap.path.parent
true
Other
Homebrew
brew
845cb99e29b7f37573eb9e499b1aed16ee6e7149.json
Ignore `HOMEBREW_NO_GITHUB_API` when testing.
Library/Homebrew/dev-cmd/tests.rb
@@ -39,16 +39,12 @@ def tests ENV.delete("HOMEBREW_CASK_OPTS") ENV.delete("HOMEBREW_TEMP") ENV.delete("HOMEBREW_LINKAGE_CACHE") + ENV.delete("HOMEBREW_NO_GITHUB_API") ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1" ENV["HOMEBREW_DEVELOPER"] = "1" ENV["HOMEBREW_NO_COMPAT"] = "1" if args.no_compat? ENV["HOMEBREW_TEST_GENERIC_OS"] = "1" if args.generic? - - if args.online? - ENV["HOMEBREW_TEST_ONLINE"] = "1" - else - ENV["HOMEBREW_NO_GITHUB_API"] = "1" - end + ENV["HOMEBREW_TEST_ONLINE"] = "1" if args.online? if args.coverage? ENV["HOMEBREW_TESTS_COVERAGE"] = "1"
true
Other
Homebrew
brew
845cb99e29b7f37573eb9e499b1aed16ee6e7149.json
Ignore `HOMEBREW_NO_GITHUB_API` when testing.
Library/Homebrew/test/cask/cli/search_spec.rb
@@ -3,7 +3,6 @@ describe Hbc::CLI::Search, :cask do before do allow(Tty).to receive(:width).and_return(0) - ENV.delete("HOMEBREW_NO_GITHUB_API") end it_behaves_like "a command that handles invalid options"
true
Other
Homebrew
brew
717032d86dd458539004b67e1ac883937df0121f.json
Use `Searchable` module.
Library/Homebrew/cmd/desc.rb
@@ -30,9 +30,10 @@ def desc results.print elsif search_type.size > 1 odie "Pick one, and only one, of -s/--search, -n/--name, or -d/--description." - elsif arg = ARGV.named.join(" ") - regex = query_regexp(arg) - results = Descriptions.search(regex, search_type.first) + elsif !ARGV.named.empty? + arg = ARGV.named.join(" ") + string_or_regex = query_regexp(arg) + results = Descriptions.search(string_or_regex, search_type.first) results.print else odie "You must provide a search term."
true
Other
Homebrew
brew
717032d86dd458539004b67e1ac883937df0121f.json
Use `Searchable` module.
Library/Homebrew/cmd/install.rb
@@ -68,14 +68,16 @@ #: creating patches to the software. require "missing_formula" -require "cmd/search" require "formula_installer" require "development_tools" require "install" +require "search" module Homebrew module_function + extend Search + def install raise FormulaUnspecifiedError if ARGV.named.empty? @@ -261,10 +263,8 @@ def install return end - regex = query_regexp(e.name) - ohai "Searching for similarly named formulae..." - formulae_search_results = search_formulae(regex) + formulae_search_results = search_formulae(e.name) case formulae_search_results.length when 0 ofail "No similarly named formulae found."
true
Other
Homebrew
brew
717032d86dd458539004b67e1ac883937df0121f.json
Use `Searchable` module.
Library/Homebrew/cmd/search.rb
@@ -55,9 +55,9 @@ def search(argv = ARGV) if args.remaining.empty? puts Formatter.columns(Formula.full_names.sort) elsif args.desc? - query = args.remaining.first - regex = query_regexp(query) - Descriptions.search(regex, :desc).print + query = args.remaining.join(" ") + string_or_regex = query_regexp(query) + Descriptions.search(string_or_regex, :desc).print elsif args.remaining.first =~ HOMEBREW_TAP_FORMULA_REGEX query = args.remaining.first @@ -71,9 +71,9 @@ def search(argv = ARGV) puts Formatter.columns(results) unless results.empty? else - query = args.remaining.first - regex = query_regexp(query) - local_results = search_formulae(regex) + query = args.remaining.join(" ") + string_or_regex = query_regexp(query) + local_results = search_formulae(string_or_regex) puts Formatter.columns(local_results.sort) unless local_results.empty? tap_results = search_taps(query).flatten.sort
true
Other
Homebrew
brew
717032d86dd458539004b67e1ac883937df0121f.json
Use `Searchable` module.
Library/Homebrew/descriptions.rb
@@ -1,6 +1,7 @@ require "formula" require "formula_versions" require "search" +require "searchable" class Descriptions extend Homebrew::Search @@ -97,16 +98,18 @@ def self.uncache_formulae(formula_names, options = { save: true }) end # Given a regex, find all formulae whose specified fields contain a match. - def self.search(regex, field = :either) + def self.search(string_or_regex, field = :either) ensure_cache + @cache.extend(Searchable) + results = case field when :name - @cache.select { |name, _| simplify_string(name).match?(regex) } + @cache.search(string_or_regex) { |name, _| name } when :desc - @cache.select { |_, desc| simplify_string(desc).match?(regex) } + @cache.search(string_or_regex) { |_, desc| desc } when :either - @cache.select { |name, desc| simplify_string(name).match?(regex) || simplify_string(desc).match?(regex) } + @cache.search(string_or_regex) end new(results)
true
Other
Homebrew
brew
717032d86dd458539004b67e1ac883937df0121f.json
Use `Searchable` module.
Library/Homebrew/search.rb
@@ -1,14 +1,12 @@ +require "searchable" + module Homebrew module Search - def simplify_string(string) - string.downcase.gsub(/[^a-z\d]/i, "") - end - def query_regexp(query) if m = query.match(%r{^/(.*)/$}) Regexp.new(m[1]) else - Regexp.new(simplify_string(query), Regexp::IGNORECASE) + query end rescue RegexpError raise "#{query} is not a valid regex." @@ -47,13 +45,14 @@ def search_taps(query, silent: false) [[], []] end - def search_formulae(regex) + def search_formulae(string_or_regex) # Use stderr to avoid breaking parsed output $stderr.puts Formatter.headline("Searching local taps...", color: :blue) aliases = Formula.alias_full_names results = (Formula.full_names + aliases) - .select { |name| simplify_string(name).match?(regex) } + .extend(Searchable) + .search(string_or_regex) .sort results.map do |name|
true
Other
Homebrew
brew
717032d86dd458539004b67e1ac883937df0121f.json
Use `Searchable` module.
Library/Homebrew/test/cask/cli/search_spec.rb
@@ -3,6 +3,7 @@ describe Hbc::CLI::Search, :cask do before do allow(Tty).to receive(:width).and_return(0) + ENV.delete("HOMEBREW_NO_GITHUB_API") end it_behaves_like "a command that handles invalid options" @@ -51,6 +52,8 @@ end it "doesn't output anything to non-TTY stdout when there are no matches" do + allow(GitHub).to receive(:search_code).and_return([]) + expect { Hbc::CLI::Search.run("foo-bar-baz") } .to not_to_output.to_stdout .and not_to_output.to_stderr
true
Other
Homebrew
brew
717032d86dd458539004b67e1ac883937df0121f.json
Use `Searchable` module.
Library/Homebrew/test/search_spec.rb
@@ -49,27 +49,13 @@ end end - describe "#simplify_string" do - it "simplifies a query with dashes" do - expect(mod.query_regexp("que-ry")).to eq(/query/i) - end - - it "simplifies a query with @ symbols" do - expect(mod.query_regexp("query@1")).to eq(/query1/i) - end - end - describe "#query_regexp" do it "correctly parses a regex query" do expect(mod.query_regexp("/^query$/")).to eq(/^query$/) end - it "correctly converts a query string to a regex" do - expect(mod.query_regexp("query")).to eq(/query/i) - end - - it "simplifies a query with special symbols" do - expect(mod.query_regexp("que-ry")).to eq(/query/i) + it "returns the original string if it is not a regex query" do + expect(mod.query_regexp("query")).to eq("query") end it "raises an error if the query is an invalid regex" do
true
Other
Homebrew
brew
46e0de1762c8b2b8d5dfaa4953e9b031489a9a6b.json
Add `Searchable` helper module.
Library/Homebrew/searchable.rb
@@ -0,0 +1,31 @@ +module Searchable + def search(string_or_regex, &block) + case string_or_regex + when Regexp + search_regex(string_or_regex, &block) + else + search_string(string_or_regex.to_str, &block) + end + end + + private + + def simplify_string(string) + string.downcase.gsub(/[^a-z\d]/i, "") + end + + def search_regex(regex) + select do |*args| + args = yield(*args) if block_given? + [*args].any? { |arg| arg.match?(regex) } + end + end + + def search_string(string) + simplified_string = simplify_string(string) + select do |*args| + args = yield(*args) if block_given? + [*args].any? { |arg| simplify_string(arg).include?(simplified_string) } + end + end +end
true
Other
Homebrew
brew
46e0de1762c8b2b8d5dfaa4953e9b031489a9a6b.json
Add `Searchable` helper module.
Library/Homebrew/test/searchable_spec.rb
@@ -0,0 +1,30 @@ +require "searchable" + +describe Searchable do + subject { ary.extend(described_class) } + + let(:ary) { ["with-dashes"] } + + describe "#search" do + context "when given a block" do + let(:ary) { [["with-dashes", "withdashes"]] } + + it "searches by the selected argument" do + expect(subject.search(/withdashes/) { |_, short_name| short_name }).not_to be_empty + expect(subject.search(/withdashes/) { |long_name, _| long_name }).to be_empty + end + end + + context "when given a regex" do + it "does not simplify strings" do + expect(subject.search(/with\-dashes/)).to eq ["with-dashes"] + end + end + + context "when given a string" do + it "simplifies both the query and searched strings" do + expect(subject.search("with dashes")).to eq ["with-dashes"] + end + end + end +end
true
Other
Homebrew
brew
6fcc5d14de042e5328a0d37972af35aa98f5a9eb.json
Simplify strings for search.
Library/Homebrew/cmd/desc.rb
@@ -9,11 +9,13 @@ #: first search, making that search slower than subsequent ones. require "descriptions" -require "cmd/search" +require "search" module Homebrew module_function + extend Search + def desc search_type = [] search_type << :either if ARGV.flag? "--search" @@ -28,8 +30,8 @@ def desc results.print elsif search_type.size > 1 odie "Pick one, and only one, of -s/--search, -n/--name, or -d/--description." - elsif arg = ARGV.named.first - regex = Homebrew.query_regexp(arg) + elsif arg = ARGV.named.join(" ") + regex = query_regexp(arg) results = Descriptions.search(regex, search_type.first) results.print else
true
Other
Homebrew
brew
6fcc5d14de042e5328a0d37972af35aa98f5a9eb.json
Simplify strings for search.
Library/Homebrew/descriptions.rb
@@ -1,7 +1,10 @@ require "formula" require "formula_versions" +require "search" class Descriptions + extend Homebrew::Search + CACHE_FILE = HOMEBREW_CACHE + "desc_cache.json" def self.cache @@ -99,11 +102,11 @@ def self.search(regex, field = :either) results = case field when :name - @cache.select { |name, _| name =~ regex } + @cache.select { |name, _| simplify_string(name).match?(regex) } when :desc - @cache.select { |_, desc| desc =~ regex } + @cache.select { |_, desc| simplify_string(desc).match?(regex) } when :either - @cache.select { |name, desc| (name =~ regex) || (desc =~ regex) } + @cache.select { |name, desc| simplify_string(name).match?(regex) || simplify_string(desc).match?(regex) } end new(results)
true
Other
Homebrew
brew
6fcc5d14de042e5328a0d37972af35aa98f5a9eb.json
Simplify strings for search.
Library/Homebrew/search.rb
@@ -1,10 +1,14 @@ module Homebrew module Search + def simplify_string(string) + string.downcase.gsub(/[^a-z\d]/i, "") + end + def query_regexp(query) if m = query.match(%r{^/(.*)/$}) Regexp.new(m[1]) else - Regexp.new(query.chars.join('[^a-z\d]*'), Regexp::IGNORECASE) + Regexp.new(simplify_string(query), Regexp::IGNORECASE) end rescue RegexpError raise "#{query} is not a valid regex." @@ -48,7 +52,9 @@ def search_formulae(regex) $stderr.puts Formatter.headline("Searching local taps...", color: :blue) aliases = Formula.alias_full_names - results = (Formula.full_names + aliases).grep(regex).sort + results = (Formula.full_names + aliases) + .select { |name| simplify_string(name).match?(regex) } + .sort results.map do |name| begin
true
Other
Homebrew
brew
6fcc5d14de042e5328a0d37972af35aa98f5a9eb.json
Simplify strings for search.
Library/Homebrew/test/search_spec.rb
@@ -49,32 +49,31 @@ end end - describe "#query_regexp" do - it "correctly parses a regex query" do - expect(mod.query_regexp("/^query$/")).to eq(/^query$/) + describe "#simplify_string" do + it "simplifies a query with dashes" do + expect(mod.query_regexp("que-ry")).to eq(/query/i) end - it "correctly converts a query string to a regex" do - expect(mod.query_regexp("query")).to eq(/q[^a-z\d]*u[^a-z\d]*e[^a-z\d]*r[^a-z\d]*y/i) + it "simplifies a query with @ symbols" do + expect(mod.query_regexp("query@1")).to eq(/query1/i) end + end - it "raises an error if the query is an invalid regex" do - expect { mod.query_regexp("/+/") }.to raise_error(/not a valid regex/) + describe "#query_regexp" do + it "correctly parses a regex query" do + expect(mod.query_regexp("/^query$/")).to eq(/^query$/) end - it "correctly matches with special symbols" do - regex = mod.query_regexp("oo-ba") - expect(regex).to match("foo-bar") + it "correctly converts a query string to a regex" do + expect(mod.query_regexp("query")).to eq(/query/i) end - it "correctly matches without special symbols" do - regex = mod.query_regexp("ooba") - expect(regex).to match("foo-bar") + it "simplifies a query with special symbols" do + expect(mod.query_regexp("que-ry")).to eq(/query/i) end - it "keeps special symbols" do - regex = mod.query_regexp("foo-bar") - expect(regex).not_to match("foobar") + it "raises an error if the query is an invalid regex" do + expect { mod.query_regexp("/+/") }.to raise_error(/not a valid regex/) end end end
true
Other
Homebrew
brew
14b3b82fcaa5c3e44c5e89de6b5ca802218f4a0e.json
Remove exact match from `brew cask search`.
Library/Homebrew/cask/lib/hbc/cli/abstract_command.rb
@@ -9,7 +9,7 @@ class AbstractCommand option "--debug", :debug, false option "--verbose", :verbose, false option "--outdated", :outdated_only, false - option "--require-sha", :require_sha, false + option "--require-sha", :require_sha, false def self.command_name @command_name ||= name.sub(/^.*:/, "").gsub(/(.)([A-Z])/, '\1_\2').downcase @@ -49,24 +49,18 @@ def casks(alternative: -> { [] }) casks = args.empty? ? alternative.call : args @casks = casks.map { |cask| CaskLoader.load(cask) } rescue CaskUnavailableError => e - reason = [e.reason, suggestion_message(e.token)].join(" ") + reason = [e.reason, *suggestion_message(e.token)].join(" ") raise e.class.new(e.token, reason) end def suggestion_message(cask_token) - exact_match, partial_matches = Search.search(cask_token) + matches, = Search.search(cask_token) - if exact_match.nil? && partial_matches.count == 1 - exact_match = partial_matches.first - end - - if exact_match - "Did you mean “#{exact_match}”?" - elsif !partial_matches.empty? + if matches.one? + "Did you mean “#{matches.first}”?" + elsif !matches.empty? "Did you mean one of these?\n" - .concat(Formatter.columns(partial_matches.take(20))) - else - "" + .concat(Formatter.columns(matches.take(20))) end end end
true
Other
Homebrew
brew
14b3b82fcaa5c3e44c5e89de6b5ca802218f4a0e.json
Remove exact match from `brew cask search`.
Library/Homebrew/cask/lib/hbc/cli/search.rb
@@ -21,7 +21,6 @@ def self.extract_regexp(string) end def self.search(*arguments) - exact_match = nil partial_matches = [] search_term = arguments.join(" ") search_regexp = extract_regexp arguments.first @@ -32,36 +31,30 @@ def self.search(*arguments) else simplified_tokens = all_tokens.map { |t| t.sub(%r{^.*\/}, "").gsub(/[^a-z0-9]+/i, "") } simplified_search_term = search_term.sub(/\.rb$/i, "").gsub(/[^a-z0-9]+/i, "") - exact_match = simplified_tokens.grep(/^#{simplified_search_term}$/i) { |t| all_tokens[simplified_tokens.index(t)] }.first partial_matches = simplified_tokens.grep(/#{simplified_search_term}/i) { |t| all_tokens[simplified_tokens.index(t)] } - partial_matches.delete(exact_match) end _, remote_matches = Homebrew.search_taps(search_term, silent: true) - [exact_match, partial_matches, remote_matches, search_term] + [partial_matches, remote_matches, search_term] end - def self.render_results(exact_match, partial_matches, remote_matches, search_term) + def self.render_results(partial_matches, remote_matches, search_term) unless $stdout.tty? - puts [*exact_match, *partial_matches, *remote_matches] + puts [*partial_matches, *remote_matches] return end - if !exact_match && partial_matches.empty? && remote_matches.empty? + if partial_matches.empty? && remote_matches.empty? puts "No Cask found for \"#{search_term}\"." return end - if exact_match - ohai "Exact Match" - puts highlight_installed exact_match - end unless partial_matches.empty? if extract_regexp search_term ohai "Regexp Matches" else - ohai "Partial Matches" + ohai "Matches" end puts Formatter.columns(partial_matches.map(&method(:highlight_installed))) end
true
Other
Homebrew
brew
14b3b82fcaa5c3e44c5e89de6b5ca802218f4a0e.json
Remove exact match from `brew cask search`.
Library/Homebrew/test/cask/cli/search_spec.rb
@@ -13,7 +13,7 @@ expect { Hbc::CLI::Search.run("local") }.to output(<<~EOS).to_stdout.as_tty - ==> Partial Matches + ==> Matches local-caffeine local-transmission EOS @@ -94,9 +94,8 @@ expect { Hbc::CLI::Search.run("test-opera") }.to output(<<~EOS).to_stdout.as_tty - ==> Exact Match + ==> Matches test-opera - ==> Partial Matches test-opera-mail EOS end
true
Other
Homebrew
brew
3a361c139e9dad4874c17cb254a8657140354195.json
Extend `search` tests.
Library/Homebrew/test/cmd/search_remote_tap_spec.rb
@@ -1,24 +1,45 @@ require "cmd/search" describe Homebrew do - specify "#search_taps" do - # Otherwise the tested method returns [], regardless of our stub - ENV.delete("HOMEBREW_NO_GITHUB_API") + describe "#search_taps" do + before do + ENV.delete("HOMEBREW_NO_GITHUB_API") + end - json_response = { - "items" => [ - { - "path" => "Formula/some-formula.rb", - "repository" => { - "full_name" => "Homebrew/homebrew-foo", + it "does not raise if `HOMEBREW_NO_GITHUB_API` is set" do + ENV["HOMEBREW_NO_GITHUB_API"] = "1" + expect(described_class.search_taps("some-formula")).to match([[], []]) + end + + it "does not raise if the network fails" do + allow(GitHub).to receive(:open_api).and_raise(GitHub::Error) + + expect(described_class.search_taps("some-formula")) + .to match([[], []]) + end + + it "returns Formulae and Casks separately" do + json_response = { + "items" => [ + { + "path" => "Formula/some-formula.rb", + "repository" => { + "full_name" => "Homebrew/homebrew-foo", + }, + }, + { + "path" => "Casks/some-cask.rb", + "repository" => { + "full_name" => "Homebrew/homebrew-bar", + }, }, - }, - ], - } + ], + } - allow(GitHub).to receive(:open_api).and_yield(json_response) + allow(GitHub).to receive(:open_api).and_yield(json_response) - expect(described_class.search_taps("some-formula")) - .to match([["homebrew/foo/some-formula"], []]) + expect(described_class.search_taps("some-formula")) + .to match([["homebrew/foo/some-formula"], ["homebrew/bar/some-cask"]]) + end end end
true
Other
Homebrew
brew
3a361c139e9dad4874c17cb254a8657140354195.json
Extend `search` tests.
Library/Homebrew/test/cmd/search_spec.rb
@@ -1,3 +1,5 @@ +require "cmd/search" + describe "brew search", :integration_test do before do setup_test_formula "testball" @@ -63,4 +65,18 @@ .and be_a_success end end + + describe "::query_regexp" do + it "correctly parses a regex query" do + expect(Homebrew.query_regexp("/^query$/")).to eq(/^query$/) + end + + it "correctly converts a query string to a regex" do + expect(Homebrew.query_regexp("query")).to eq(/.*query.*/i) + end + + it "raises an error if the query is an invalid regex" do + expect { Homebrew.query_regexp("/+/") }.to raise_error(/not a valid regex/) + end + end end
true
Other
Homebrew
brew
05568420c0f6290cf09c5448c2891e5134360629.json
linkage_checker: fix cache invalidation. Rather than using the name of the keg for the key use the full path. This provides several advantages: - there's no need to invalidate the cache on a `brew upgrade` or `brew switch` - it's easier to figure out what cache entries can be removed and this can be done whenever a keg is removed by `brew uninstall` or `brew cleanup`. Also, ensure that an `install` (or `reinstall`, `upgrade`) always results in the cache being rebuilt for that keg (in case different options were used).
Library/Homebrew/formula_installer.rb
@@ -607,7 +607,7 @@ def finish # Updates the cache for a particular formula after doing an install CacheStoreDatabase.use(:linkage) do |db| break unless db.created? - LinkageChecker.new(keg, formula, cache_db: db) + LinkageChecker.new(keg, formula, cache_db: db, rebuild_cache: true) end # Update tab with actual runtime dependencies
true
Other
Homebrew
brew
05568420c0f6290cf09c5448c2891e5134360629.json
linkage_checker: fix cache invalidation. Rather than using the name of the keg for the key use the full path. This provides several advantages: - there's no need to invalidate the cache on a `brew upgrade` or `brew switch` - it's easier to figure out what cache entries can be removed and this can be done whenever a keg is removed by `brew uninstall` or `brew cleanup`. Also, ensure that an `install` (or `reinstall`, `upgrade`) always results in the cache being rebuilt for that keg (in case different options were used).
Library/Homebrew/keg.rb
@@ -272,6 +272,11 @@ def remove_opt_record end def uninstall + CacheStoreDatabase.use(:linkage) do |db| + break unless db.created? + LinkageCacheStore.new(path, db).flush_cache! + end + path.rmtree path.parent.rmdir_if_possible remove_opt_record if optlinked?
true
Other
Homebrew
brew
05568420c0f6290cf09c5448c2891e5134360629.json
linkage_checker: fix cache invalidation. Rather than using the name of the keg for the key use the full path. This provides several advantages: - there's no need to invalidate the cache on a `brew upgrade` or `brew switch` - it's easier to figure out what cache entries can be removed and this can be done whenever a keg is removed by `brew uninstall` or `brew cleanup`. Also, ensure that an `install` (or `reinstall`, `upgrade`) always results in the cache being rebuilt for that keg (in case different options were used).
Library/Homebrew/linkage_cache_store.rb
@@ -6,19 +6,19 @@ # by the `brew linkage` command # class LinkageCacheStore < CacheStore - # @param [String] keg_name + # @param [String] keg_path # @param [CacheStoreDatabase] database # @return [nil] - def initialize(keg_name, database) - @keg_name = keg_name + def initialize(keg_path, database) + @keg_path = keg_path super(database) end - # Returns `true` if the database has any value for the current `keg_name` + # Returns `true` if the database has any value for the current `keg_path` # # @return [Boolean] def keg_exists? - !database.get(@keg_name).nil? + !database.get(@keg_path).nil? end # Inserts dylib-related information into the cache if it does not exist or @@ -35,7 +35,7 @@ def update!(hash_values) EOS end - database.set @keg_name, ruby_hash_to_json_string(hash_values) + database.set @keg_path, ruby_hash_to_json_string(hash_values) end # @param [Symbol] the type to fetch from the `LinkageCacheStore` @@ -55,7 +55,7 @@ def fetch_type(type) # @return [nil] def flush_cache! - database.delete(@keg_name) + database.delete(@keg_path) end private @@ -65,7 +65,7 @@ def flush_cache! # @param [Symbol] type # @return [Hash] def fetch_hash_values(type) - keg_cache = database.get(@keg_name) + keg_cache = database.get(@keg_path) return {} unless keg_cache json_string_to_ruby_hash(keg_cache)[type.to_s] end
true
Other
Homebrew
brew
05568420c0f6290cf09c5448c2891e5134360629.json
linkage_checker: fix cache invalidation. Rather than using the name of the keg for the key use the full path. This provides several advantages: - there's no need to invalidate the cache on a `brew upgrade` or `brew switch` - it's easier to figure out what cache entries can be removed and this can be done whenever a keg is removed by `brew uninstall` or `brew cleanup`. Also, ensure that an `install` (or `reinstall`, `upgrade`) always results in the cache being rebuilt for that keg (in case different options were used).
Library/Homebrew/linkage_checker.rb
@@ -6,10 +6,11 @@ class LinkageChecker attr_reader :undeclared_deps def initialize(keg, formula = nil, cache_db:, - use_cache: !ENV["HOMEBREW_LINKAGE_CACHE"].nil?) + use_cache: !ENV["HOMEBREW_LINKAGE_CACHE"].nil?, + rebuild_cache: false) @keg = keg @formula = formula || resolve_formula(keg) - @store = LinkageCacheStore.new(keg.name, cache_db) if use_cache + @store = LinkageCacheStore.new(keg.to_s, cache_db) if use_cache @system_dylibs = Set.new @broken_dylibs = Set.new @@ -21,7 +22,7 @@ def initialize(keg, formula = nil, cache_db:, @undeclared_deps = [] @unnecessary_deps = [] - check_dylibs + check_dylibs(rebuild_cache: rebuild_cache) end def display_normal_output @@ -67,9 +68,16 @@ def dylib_to_dep(dylib) Regexp.last_match(2) end - def check_dylibs + def check_dylibs(rebuild_cache:) + keg_files_dylibs = nil + + if rebuild_cache + store&.flush_cache! + else + keg_files_dylibs = store&.fetch_type(:keg_files_dylibs) + end + keg_files_dylibs_was_empty = false - keg_files_dylibs = store&.fetch_type(:keg_files_dylibs) keg_files_dylibs ||= {} if keg_files_dylibs.empty? keg_files_dylibs_was_empty = true
true
Other
Homebrew
brew
99bf57d366b93dad617246dfe10867b6a34ab2b2.json
vendor: Update ruby-macho to 1.2.0 See https://github.com/Homebrew/homebrew-core/issues/28675.
Library/Homebrew/vendor/macho/macho.rb
@@ -12,7 +12,7 @@ # The primary namespace for ruby-macho. module MachO # release version - VERSION = "1.1.0".freeze + VERSION = "1.2.0".freeze # Opens the given filename as a MachOFile or FatFile, depending on its magic. # @param filename [String] the file being opened
true
Other
Homebrew
brew
99bf57d366b93dad617246dfe10867b6a34ab2b2.json
vendor: Update ruby-macho to 1.2.0 See https://github.com/Homebrew/homebrew-core/issues/28675.
Library/Homebrew/vendor/macho/macho/exceptions.rb
@@ -10,7 +10,7 @@ class ModificationError < MachOError # Raised when a Mach-O file modification fails but can be recovered when # operating on multiple Mach-O slices of a fat binary in non-strict mode. class RecoverableModificationError < ModificationError - # @return [Fixnum, nil] The index of the Mach-O slice of a fat binary for + # @return [Integer, nil] The index of the Mach-O slice of a fat binary for # which modification failed or `nil` if not a fat binary. This is used to # make the error message more useful. attr_accessor :macho_slice @@ -40,7 +40,7 @@ def initialize # Raised when a file's magic bytes are not valid Mach-O magic. class MagicError < NotAMachOError - # @param num [Fixnum] the unknown number + # @param num [Integer] the unknown number def initialize(num) super "Unrecognized Mach-O magic: 0x#{"%02x" % num}" end @@ -69,16 +69,16 @@ def initialize # Raised when the CPU type is unknown. class CPUTypeError < MachOError - # @param cputype [Fixnum] the unknown CPU type + # @param cputype [Integer] the unknown CPU type def initialize(cputype) super "Unrecognized CPU type: 0x#{"%08x" % cputype}" end end # Raised when the CPU type/sub-type pair is unknown. class CPUSubtypeError < MachOError - # @param cputype [Fixnum] the CPU type of the unknown pair - # @param cpusubtype [Fixnum] the CPU sub-type of the unknown pair + # @param cputype [Integer] the CPU type of the unknown pair + # @param cpusubtype [Integer] the CPU sub-type of the unknown pair def initialize(cputype, cpusubtype) super "Unrecognized CPU sub-type: 0x#{"%08x" % cpusubtype}" \ " (for CPU type: 0x#{"%08x" % cputype})" @@ -87,15 +87,15 @@ def initialize(cputype, cpusubtype) # Raised when a mach-o file's filetype field is unknown. class FiletypeError < MachOError - # @param num [Fixnum] the unknown number + # @param num [Integer] the unknown number def initialize(num) super "Unrecognized Mach-O filetype code: 0x#{"%02x" % num}" end end # Raised when an unknown load command is encountered. class LoadCommandError < MachOError - # @param num [Fixnum] the unknown number + # @param num [Integer] the unknown number def initialize(num) super "Unrecognized Mach-O load command: 0x#{"%02x" % num}" end @@ -113,8 +113,8 @@ def initialize(cmd_sym) # is wrong. class LoadCommandCreationArityError < MachOError # @param cmd_sym [Symbol] the load command's symbol - # @param expected_arity [Fixnum] the number of arguments expected - # @param actual_arity [Fixnum] the number of arguments received + # @param expected_arity [Integer] the number of arguments expected + # @param actual_arity [Integer] the number of arguments received def initialize(cmd_sym, expected_arity, actual_arity) super "Expected #{expected_arity} arguments for #{cmd_sym} creation," \ " got #{actual_arity}" @@ -140,7 +140,7 @@ def initialize(lc) # Raised when a change at an offset is not valid. class OffsetInsertionError < ModificationError - # @param offset [Fixnum] the invalid offset + # @param offset [Integer] the invalid offset def initialize(offset) super "Insertion at offset #{offset} is not valid" end
true
Other
Homebrew
brew
99bf57d366b93dad617246dfe10867b6a34ab2b2.json
vendor: Update ruby-macho to 1.2.0 See https://github.com/Homebrew/homebrew-core/issues/28675.
Library/Homebrew/vendor/macho/macho/fat_file.rb
@@ -261,11 +261,8 @@ def write(filename) # @raise [MachOError] if the instance was initialized without a file # @note Overwrites all data in the file! def write! - if filename.nil? - raise MachOError, "cannot write to a default file when initialized from a binary string" - else - File.open(@filename, "wb") { |f| f.write(@raw_data) } - end + raise MachOError, "no initial file to write to" if filename.nil? + File.open(@filename, "wb") { |f| f.write(@raw_data) } end private
true
Other
Homebrew
brew
99bf57d366b93dad617246dfe10867b6a34ab2b2.json
vendor: Update ruby-macho to 1.2.0 See https://github.com/Homebrew/homebrew-core/issues/28675.
Library/Homebrew/vendor/macho/macho/headers.rb
@@ -450,10 +450,10 @@ module Headers # Fat binary header structure # @see MachO::FatArch class FatHeader < MachOStructure - # @return [Fixnum] the magic number of the header (and file) + # @return [Integer] the magic number of the header (and file) attr_reader :magic - # @return [Fixnum] the number of fat architecture structures following the header + # @return [Integer] the number of fat architecture structures following the header attr_reader :nfat_arch # always big-endian @@ -481,19 +481,19 @@ def serialize # these, representing one or more internal Mach-O blobs. # @see MachO::Headers::FatHeader class FatArch < MachOStructure - # @return [Fixnum] the CPU type of the Mach-O + # @return [Integer] the CPU type of the Mach-O attr_reader :cputype - # @return [Fixnum] the CPU subtype of the Mach-O + # @return [Integer] the CPU subtype of the Mach-O attr_reader :cpusubtype - # @return [Fixnum] the file offset to the beginning of the Mach-O data + # @return [Integer] the file offset to the beginning of the Mach-O data attr_reader :offset - # @return [Fixnum] the size, in bytes, of the Mach-O data + # @return [Integer] the size, in bytes, of the Mach-O data attr_reader :size - # @return [Fixnum] the alignment, as a power of 2 + # @return [Integer] the alignment, as a power of 2 attr_reader :align # always big-endian @@ -522,25 +522,25 @@ def serialize # 32-bit Mach-O file header structure class MachHeader < MachOStructure - # @return [Fixnum] the magic number + # @return [Integer] the magic number attr_reader :magic - # @return [Fixnum] the CPU type of the Mach-O + # @return [Integer] the CPU type of the Mach-O attr_reader :cputype - # @return [Fixnum] the CPU subtype of the Mach-O + # @return [Integer] the CPU subtype of the Mach-O attr_reader :cpusubtype - # @return [Fixnum] the file type of the Mach-O + # @return [Integer] the file type of the Mach-O attr_reader :filetype - # @return [Fixnum] the number of load commands in the Mach-O + # @return [Integer] the number of load commands in the Mach-O attr_reader :ncmds - # @return [Fixnum] the size of all load commands, in bytes, in the Mach-O + # @return [Integer] the size of all load commands, in bytes, in the Mach-O attr_reader :sizeofcmds - # @return [Fixnum] the header flags associated with the Mach-O + # @return [Integer] the header flags associated with the Mach-O attr_reader :flags # @see MachOStructure::FORMAT @@ -635,7 +635,7 @@ def magic64? Utils.magic64?(magic) end - # @return [Fixnum] the file's internal alignment + # @return [Integer] the file's internal alignment def alignment magic32? ? 4 : 8 end
true
Other
Homebrew
brew
99bf57d366b93dad617246dfe10867b6a34ab2b2.json
vendor: Update ruby-macho to 1.2.0 See https://github.com/Homebrew/homebrew-core/issues/28675.
Library/Homebrew/vendor/macho/macho/load_commands.rb
@@ -58,6 +58,8 @@ module LoadCommands 0x2e => :LC_LINKER_OPTIMIZATION_HINT, 0x2f => :LC_VERSION_MIN_TVOS, 0x30 => :LC_VERSION_MIN_WATCHOS, + 0x31 => :LC_NOTE, + 0x32 => :LC_BUILD_VERSION, }.freeze # association of symbol representations to load command constants @@ -66,20 +68,20 @@ module LoadCommands # load commands responsible for loading dylibs # @api private - DYLIB_LOAD_COMMANDS = [ - :LC_LOAD_DYLIB, - :LC_LOAD_WEAK_DYLIB, - :LC_REEXPORT_DYLIB, - :LC_LAZY_LOAD_DYLIB, - :LC_LOAD_UPWARD_DYLIB, + DYLIB_LOAD_COMMANDS = %i[ + LC_LOAD_DYLIB + LC_LOAD_WEAK_DYLIB + LC_REEXPORT_DYLIB + LC_LAZY_LOAD_DYLIB + LC_LOAD_UPWARD_DYLIB ].freeze # load commands that can be created manually via {LoadCommand.create} # @api private - CREATABLE_LOAD_COMMANDS = DYLIB_LOAD_COMMANDS + [ - :LC_ID_DYLIB, - :LC_RPATH, - :LC_LOAD_DYLINKER, + CREATABLE_LOAD_COMMANDS = DYLIB_LOAD_COMMANDS + %i[ + LC_ID_DYLIB + LC_RPATH + LC_LOAD_DYLINKER ].freeze # association of load command symbols to string representations of classes @@ -141,6 +143,8 @@ module LoadCommands :LC_LINKER_OPTIMIZATION_HINT => "LinkeditDataCommand", :LC_VERSION_MIN_TVOS => "VersionMinCommand", :LC_VERSION_MIN_WATCHOS => "VersionMinCommand", + :LC_NOTE => "LoadCommand", + :LC_BUILD_VERSION => "BuildVersionCommand", }.freeze # association of segment name symbols to names @@ -173,10 +177,10 @@ class LoadCommand < MachOStructure # @return [MachO::MachOView] the raw view associated with the load command attr_reader :view - # @return [Fixnum] the load command's identifying number + # @return [Integer] the load command's identifying number attr_reader :cmd - # @return [Fixnum] the size of the load command, in bytes + # @return [Integer] the size of the load command, in bytes attr_reader :cmdsize # @see MachOStructure::FORMAT @@ -216,8 +220,8 @@ def self.create(cmd_sym, *args) end # @param view [MachO::MachOView] the load command's raw view - # @param cmd [Fixnum] the load command's identifying number - # @param cmdsize [Fixnum] the size of the load command in bytes + # @param cmd [Integer] the load command's identifying number + # @param cmdsize [Integer] the size of the load command in bytes # @api private def initialize(view, cmd, cmdsize) @view = view @@ -241,7 +245,7 @@ def serialize(context) [cmd, SIZEOF].pack(format) end - # @return [Fixnum] the load command's offset in the source file + # @return [Integer] the load command's offset in the source file # @deprecated use {#view} instead def offset view.offset @@ -267,7 +271,7 @@ def to_s # explicit operations on the raw Mach-O data. class LCStr # @param lc [LoadCommand] the load command - # @param lc_str [Fixnum, String] the offset to the beginning of the + # @param lc_str [Integer, String] the offset to the beginning of the # string, or the string itself if not being initialized with a view. # @raise [MachO::LCStrMalformedError] if the string is malformed # @todo devise a solution such that the `lc_str` parameter is not @@ -295,7 +299,7 @@ def to_s @string end - # @return [Fixnum] the offset to the beginning of the string in the + # @return [Integer] the offset to the beginning of the string in the # load command def to_i @string_offset @@ -308,7 +312,7 @@ class SerializationContext # @return [Symbol] the endianness of the serialized load command attr_reader :endianness - # @return [Fixnum] the constant alignment value used to pad the + # @return [Integer] the constant alignment value used to pad the # serialized load command attr_reader :alignment @@ -320,7 +324,7 @@ def self.context_for(macho) end # @param endianness [Symbol] the endianness of the context - # @param alignment [Fixnum] the alignment of the context + # @param alignment [Integer] the alignment of the context # @api private def initialize(endianness, alignment) @endianness = endianness @@ -333,7 +337,7 @@ def initialize(endianness, alignment) # identifying an object produced by static link editor. Corresponds to # LC_UUID. class UUIDCommand < LoadCommand - # @return [Array<Fixnum>] the UUID + # @return [Array<Integer>] the UUID attr_reader :uuid # @see MachOStructure::FORMAT @@ -368,28 +372,28 @@ class SegmentCommand < LoadCommand # @return [String] the name of the segment attr_reader :segname - # @return [Fixnum] the memory address of the segment + # @return [Integer] the memory address of the segment attr_reader :vmaddr - # @return [Fixnum] the memory size of the segment + # @return [Integer] the memory size of the segment attr_reader :vmsize - # @return [Fixnum] the file offset of the segment + # @return [Integer] the file offset of the segment attr_reader :fileoff - # @return [Fixnum] the amount to map from the file + # @return [Integer] the amount to map from the file attr_reader :filesize - # @return [Fixnum] the maximum VM protection + # @return [Integer] the maximum VM protection attr_reader :maxprot - # @return [Fixnum] the initial VM protection + # @return [Integer] the initial VM protection attr_reader :initprot - # @return [Fixnum] the number of sections in the segment + # @return [Integer] the number of sections in the segment attr_reader :nsects - # @return [Fixnum] any flags associated with the segment + # @return [Integer] any flags associated with the segment attr_reader :flags # @see MachOStructure::FORMAT @@ -466,13 +470,13 @@ class DylibCommand < LoadCommand # name as an LCStr attr_reader :name - # @return [Fixnum] the library's build time stamp + # @return [Integer] the library's build time stamp attr_reader :timestamp - # @return [Fixnum] the library's current version number + # @return [Integer] the library's current version number attr_reader :current_version - # @return [Fixnum] the library's compatibility version number + # @return [Integer] the library's compatibility version number attr_reader :compatibility_version # @see MachOStructure::FORMAT @@ -551,10 +555,10 @@ class PreboundDylibCommand < LoadCommand # name as an LCStr attr_reader :name - # @return [Fixnum] the number of modules in the library + # @return [Integer] the number of modules in the library attr_reader :nmodules - # @return [Fixnum] a bit vector of linked modules + # @return [Integer] a bit vector of linked modules attr_reader :linked_modules # @see MachOStructure::FORMAT @@ -591,10 +595,10 @@ class ThreadCommand < LoadCommand # initialization routine and an index into the module table for the module # that defines the routine. Corresponds to LC_ROUTINES. class RoutinesCommand < LoadCommand - # @return [Fixnum] the address of the initialization routine + # @return [Integer] the address of the initialization routine attr_reader :init_address - # @return [Fixnum] the index into the module table that the init routine + # @return [Integer] the index into the module table that the init routine # is defined in attr_reader :init_module @@ -739,10 +743,10 @@ def initialize(view, cmd, cmdsize, sub_client) # A load command containing the offsets and sizes of the link-edit 4.3BSD # "stab" style symbol table information. Corresponds to LC_SYMTAB. class SymtabCommand < LoadCommand - # @return [Fixnum] the symbol table's offset + # @return [Integer] the symbol table's offset attr_reader :symoff - # @return [Fixnum] the number of symbol table entries + # @return [Integer] the number of symbol table entries attr_reader :nsyms # @return the string table's offset @@ -772,58 +776,58 @@ def initialize(view, cmd, cmdsize, symoff, nsyms, stroff, strsize) # A load command containing symbolic information needed to support data # structures used by the dynamic link editor. Corresponds to LC_DYSYMTAB. class DysymtabCommand < LoadCommand - # @return [Fixnum] the index to local symbols + # @return [Integer] the index to local symbols attr_reader :ilocalsym - # @return [Fixnum] the number of local symbols + # @return [Integer] the number of local symbols attr_reader :nlocalsym - # @return [Fixnum] the index to externally defined symbols + # @return [Integer] the index to externally defined symbols attr_reader :iextdefsym - # @return [Fixnum] the number of externally defined symbols + # @return [Integer] the number of externally defined symbols attr_reader :nextdefsym - # @return [Fixnum] the index to undefined symbols + # @return [Integer] the index to undefined symbols attr_reader :iundefsym - # @return [Fixnum] the number of undefined symbols + # @return [Integer] the number of undefined symbols attr_reader :nundefsym - # @return [Fixnum] the file offset to the table of contents + # @return [Integer] the file offset to the table of contents attr_reader :tocoff - # @return [Fixnum] the number of entries in the table of contents + # @return [Integer] the number of entries in the table of contents attr_reader :ntoc - # @return [Fixnum] the file offset to the module table + # @return [Integer] the file offset to the module table attr_reader :modtaboff - # @return [Fixnum] the number of entries in the module table + # @return [Integer] the number of entries in the module table attr_reader :nmodtab - # @return [Fixnum] the file offset to the referenced symbol table + # @return [Integer] the file offset to the referenced symbol table attr_reader :extrefsymoff - # @return [Fixnum] the number of entries in the referenced symbol table + # @return [Integer] the number of entries in the referenced symbol table attr_reader :nextrefsyms - # @return [Fixnum] the file offset to the indirect symbol table + # @return [Integer] the file offset to the indirect symbol table attr_reader :indirectsymoff - # @return [Fixnum] the number of entries in the indirect symbol table + # @return [Integer] the number of entries in the indirect symbol table attr_reader :nindirectsyms - # @return [Fixnum] the file offset to the external relocation entries + # @return [Integer] the file offset to the external relocation entries attr_reader :extreloff - # @return [Fixnum] the number of external relocation entries + # @return [Integer] the number of external relocation entries attr_reader :nextrel - # @return [Fixnum] the file offset to the local relocation entries + # @return [Integer] the file offset to the local relocation entries attr_reader :locreloff - # @return [Fixnum] the number of local relocation entries + # @return [Integer] the number of local relocation entries attr_reader :nlocrel # @see MachOStructure::FORMAT @@ -865,10 +869,10 @@ def initialize(view, cmd, cmdsize, ilocalsym, nlocalsym, iextdefsym, # A load command containing the offset and number of hints in the two-level # namespace lookup hints table. Corresponds to LC_TWOLEVEL_HINTS. class TwolevelHintsCommand < LoadCommand - # @return [Fixnum] the offset to the hint table + # @return [Integer] the offset to the hint table attr_reader :htoffset - # @return [Fixnum] the number of hints in the hint table + # @return [Integer] the number of hints in the hint table attr_reader :nhints # @return [TwolevelHintsTable] @@ -898,8 +902,8 @@ class TwolevelHintsTable attr_reader :hints # @param view [MachO::MachOView] the view into the current Mach-O - # @param htoffset [Fixnum] the offset of the hints table - # @param nhints [Fixnum] the number of two-level hints in the table + # @param htoffset [Integer] the offset of the hints table + # @param nhints [Integer] the number of two-level hints in the table # @api private def initialize(view, htoffset, nhints) format = Utils.specialize_format("L=#{nhints}", view.endianness) @@ -911,13 +915,13 @@ def initialize(view, htoffset, nhints) # An individual two-level namespace lookup hint. class TwolevelHint - # @return [Fixnum] the index into the sub-images + # @return [Integer] the index into the sub-images attr_reader :isub_image - # @return [Fixnum] the index into the table of contents + # @return [Integer] the index into the table of contents attr_reader :itoc - # @param blob [Fixnum] the 32-bit number containing the lookup hint + # @param blob [Integer] the 32-bit number containing the lookup hint # @api private def initialize(blob) @isub_image = blob >> 24 @@ -930,7 +934,7 @@ def initialize(blob) # A load command containing the value of the original checksum for prebound # files, or zero. Corresponds to LC_PREBIND_CKSUM. class PrebindCksumCommand < LoadCommand - # @return [Fixnum] the checksum or 0 + # @return [Integer] the checksum or 0 attr_reader :cksum # @see MachOStructure::FORMAT @@ -987,10 +991,10 @@ def serialize(context) # LC_SEGMENT_SPLIT_INFO, LC_FUNCTION_STARTS, LC_DATA_IN_CODE, # LC_DYLIB_CODE_SIGN_DRS, and LC_LINKER_OPTIMIZATION_HINT. class LinkeditDataCommand < LoadCommand - # @return [Fixnum] offset to the data in the __LINKEDIT segment + # @return [Integer] offset to the data in the __LINKEDIT segment attr_reader :dataoff - # @return [Fixnum] size of the data in the __LINKEDIT segment + # @return [Integer] size of the data in the __LINKEDIT segment attr_reader :datasize # @see MachOStructure::FORMAT @@ -1012,13 +1016,13 @@ def initialize(view, cmd, cmdsize, dataoff, datasize) # A load command representing the offset to and size of an encrypted # segment. Corresponds to LC_ENCRYPTION_INFO. class EncryptionInfoCommand < LoadCommand - # @return [Fixnum] the offset to the encrypted segment + # @return [Integer] the offset to the encrypted segment attr_reader :cryptoff - # @return [Fixnum] the size of the encrypted segment + # @return [Integer] the size of the encrypted segment attr_reader :cryptsize - # @return [Fixnum] the encryption system, or 0 if not encrypted yet + # @return [Integer] the encryption system, or 0 if not encrypted yet attr_reader :cryptid # @see MachOStructure::FORMAT @@ -1041,16 +1045,16 @@ def initialize(view, cmd, cmdsize, cryptoff, cryptsize, cryptid) # A load command representing the offset to and size of an encrypted # segment. Corresponds to LC_ENCRYPTION_INFO_64. class EncryptionInfoCommand64 < LoadCommand - # @return [Fixnum] the offset to the encrypted segment + # @return [Integer] the offset to the encrypted segment attr_reader :cryptoff - # @return [Fixnum] the size of the encrypted segment + # @return [Integer] the size of the encrypted segment attr_reader :cryptsize - # @return [Fixnum] the encryption system, or 0 if not encrypted yet + # @return [Integer] the encryption system, or 0 if not encrypted yet attr_reader :cryptid - # @return [Fixnum] 64-bit padding value + # @return [Integer] 64-bit padding value attr_reader :pad # @see MachOStructure::FORMAT @@ -1075,10 +1079,10 @@ def initialize(view, cmd, cmdsize, cryptoff, cryptsize, cryptid, pad) # was built to run. Corresponds to LC_VERSION_MIN_MACOSX and # LC_VERSION_MIN_IPHONEOS. class VersionMinCommand < LoadCommand - # @return [Fixnum] the version X.Y.Z packed as x16.y8.z8 + # @return [Integer] the version X.Y.Z packed as x16.y8.z8 attr_reader :version - # @return [Fixnum] the SDK version X.Y.Z packed as x16.y8.z8 + # @return [Integer] the SDK version X.Y.Z packed as x16.y8.z8 attr_reader :sdk # @see MachOStructure::FORMAT @@ -1119,38 +1123,129 @@ def sdk_string end end + # A load command containing the minimum OS version on which + # the binary was built for its platform. + # Corresponds to LC_BUILD_VERSION. + class BuildVersionCommand < LoadCommand + # @return [Integer] + attr_reader :platform + + # @return [Integer] the minimum OS version X.Y.Z packed as x16.y8.z8 + attr_reader :minos + + # @return [Integer] the SDK version X.Y.Z packed as x16.y8.z8 + attr_reader :sdk + + # @return [ToolEntries] tool entries + attr_reader :tool_entries + + # @see MachOStructure::FORMAT + # @api private + FORMAT = "L=6".freeze + + # @see MachOStructure::SIZEOF + # @api private + SIZEOF = 24 + + # @api private + def initialize(view, cmd, cmdsize, platform, minos, sdk, ntools) + super(view, cmd, cmdsize) + @platform = platform + @minos = minos + @sdk = sdk + @tool_entries = ToolEntries.new(view, ntools) + end + + # A representation of the tool versions exposed + # by a {BuildVersionCommand} (`LC_BUILD_VERSION`). + class ToolEntries + # @return [Array<Tool>] all tools + attr_reader :tools + + # @param view [MachO::MachOView] the view into the current Mach-O + # @param ntools [Integer] the number of tools + # @api private + def initialize(view, ntools) + format = Utils.specialize_format("L=#{ntools * 2}", view.endianness) + raw_table = view.raw_data[view.offset + 24, ntools * 8] + blobs = raw_table.unpack(format).each_slice(2).to_a + + @tools = blobs.map { |b| Tool.new(*b) } + end + + # An individual tool. + class Tool + # @return [Integer] the enum for the tool + attr_reader :tool + + # @return [Integer] the tool's version number + attr_reader :version + + # @param tool 32-bit integer + # # @param version 32-bit integer + # @api private + def initialize(tool, version) + @tool = tool + @version = version + end + end + end + + # A string representation of the binary's minimum OS version. + # @return [String] a string representing the minimum OS version. + def minos_string + binary = "%032b" % minos + segs = [ + binary[0..15], binary[16..23], binary[24..31] + ].map { |s| s.to_i(2) } + + segs.join(".") + end + + # A string representation of the binary's SDK version. + # @return [String] a string representing the SDK version. + def sdk_string + binary = "%032b" % sdk + segs = [ + binary[0..15], binary[16..23], binary[24..31] + ].map { |s| s.to_i(2) } + + segs.join(".") + end + end + # A load command containing the file offsets and sizes of the new # compressed form of the information dyld needs to load the image. # Corresponds to LC_DYLD_INFO and LC_DYLD_INFO_ONLY. class DyldInfoCommand < LoadCommand - # @return [Fixnum] the file offset to the rebase information + # @return [Integer] the file offset to the rebase information attr_reader :rebase_off - # @return [Fixnum] the size of the rebase information + # @return [Integer] the size of the rebase information attr_reader :rebase_size - # @return [Fixnum] the file offset to the binding information + # @return [Integer] the file offset to the binding information attr_reader :bind_off - # @return [Fixnum] the size of the binding information + # @return [Integer] the size of the binding information attr_reader :bind_size - # @return [Fixnum] the file offset to the weak binding information + # @return [Integer] the file offset to the weak binding information attr_reader :weak_bind_off - # @return [Fixnum] the size of the weak binding information + # @return [Integer] the size of the weak binding information attr_reader :weak_bind_size - # @return [Fixnum] the file offset to the lazy binding information + # @return [Integer] the file offset to the lazy binding information attr_reader :lazy_bind_off - # @return [Fixnum] the size of the lazy binding information + # @return [Integer] the size of the lazy binding information attr_reader :lazy_bind_size - # @return [Fixnum] the file offset to the export information + # @return [Integer] the file offset to the export information attr_reader :export_off - # @return [Fixnum] the size of the export information + # @return [Integer] the size of the export information attr_reader :export_size # @see MachOStructure::FORMAT @@ -1182,7 +1277,7 @@ def initialize(view, cmd, cmdsize, rebase_off, rebase_size, bind_off, # A load command containing linker options embedded in object files. # Corresponds to LC_LINKER_OPTION. class LinkerOptionCommand < LoadCommand - # @return [Fixnum] the number of strings + # @return [Integer] the number of strings attr_reader :count # @see MachOStructure::FORMAT @@ -1202,10 +1297,10 @@ def initialize(view, cmd, cmdsize, count) # A load command specifying the offset of main(). Corresponds to LC_MAIN. class EntryPointCommand < LoadCommand - # @return [Fixnum] the file (__TEXT) offset of main() + # @return [Integer] the file (__TEXT) offset of main() attr_reader :entryoff - # @return [Fixnum] if not 0, the initial stack size. + # @return [Integer] if not 0, the initial stack size. attr_reader :stacksize # @see MachOStructure::FORMAT @@ -1227,7 +1322,7 @@ def initialize(view, cmd, cmdsize, entryoff, stacksize) # A load command specifying the version of the sources used to build the # binary. Corresponds to LC_SOURCE_VERSION. class SourceVersionCommand < LoadCommand - # @return [Fixnum] the version packed as a24.b10.c10.d10.e10 + # @return [Integer] the version packed as a24.b10.c10.d10.e10 attr_reader :version # @see MachOStructure::FORMAT @@ -1260,10 +1355,10 @@ def version_string # An obsolete load command containing the offset and size of the (GNU style) # symbol table information. Corresponds to LC_SYMSEG. class SymsegCommand < LoadCommand - # @return [Fixnum] the offset to the symbol segment + # @return [Integer] the offset to the symbol segment attr_reader :offset - # @return [Fixnum] the size of the symbol segment in bytes + # @return [Integer] the size of the symbol segment in bytes attr_reader :size # @see MachOStructure::FORMAT @@ -1301,7 +1396,7 @@ class FvmfileCommand < LoadCommand # @return [LCStr] the pathname of the file being loaded attr_reader :name - # @return [Fixnum] the virtual address being loaded at + # @return [Integer] the virtual address being loaded at attr_reader :header_addr # @see MachOStructure::FORMAT @@ -1325,10 +1420,10 @@ class FvmlibCommand < LoadCommand # @return [LCStr] the library's target pathname attr_reader :name - # @return [Fixnum] the library's minor version number + # @return [Integer] the library's minor version number attr_reader :minor_version - # @return [Fixnum] the library's header address + # @return [Integer] the library's header address attr_reader :header_addr # @see MachOStructure::FORMAT
true
Other
Homebrew
brew
99bf57d366b93dad617246dfe10867b6a34ab2b2.json
vendor: Update ruby-macho to 1.2.0 See https://github.com/Homebrew/homebrew-core/issues/28675.
Library/Homebrew/vendor/macho/macho/macho_file.rb
@@ -134,7 +134,7 @@ def command(name) alias [] command # Inserts a load command at the given offset. - # @param offset [Fixnum] the offset to insert at + # @param offset [Integer] the offset to insert at # @param lc [LoadCommands::LoadCommand] the load command to insert # @param options [Hash] # @option options [Boolean] :repopulate (true) whether or not to repopulate @@ -404,11 +404,8 @@ def write(filename) # @raise [MachOError] if the instance was initialized without a file # @note Overwrites all data in the file! def write! - if @filename.nil? - raise MachOError, "cannot write to a default file when initialized from a binary string" - else - File.open(@filename, "wb") { |f| f.write(@raw_data) } - end + raise MachOError, "no initial file to write to" if @filename.nil? + File.open(@filename, "wb") { |f| f.write(@raw_data) } end private @@ -434,7 +431,7 @@ def populate_mach_header end # Read just the file's magic number and check its validity. - # @return [Fixnum] the magic + # @return [Integer] the magic # @raise [MagicError] if the magic is not valid Mach-O magic # @raise [FatBinaryError] if the magic is for a Fat file # @api private @@ -450,15 +447,15 @@ def populate_and_check_magic end # Check the file's CPU type. - # @param cputype [Fixnum] the CPU type + # @param cputype [Integer] the CPU type # @raise [CPUTypeError] if the CPU type is unknown # @api private def check_cputype(cputype) raise CPUTypeError, cputype unless Headers::CPU_TYPES.key?(cputype) end # Check the file's CPU type/subtype pair. - # @param cpusubtype [Fixnum] the CPU subtype + # @param cpusubtype [Integer] the CPU subtype # @raise [CPUSubtypeError] if the CPU sub-type is unknown # @api private def check_cpusubtype(cputype, cpusubtype) @@ -467,7 +464,7 @@ def check_cpusubtype(cputype, cpusubtype) end # Check the file's type. - # @param filetype [Fixnum] the file type + # @param filetype [Integer] the file type # @raise [FiletypeError] if the file type is unknown # @api private def check_filetype(filetype) @@ -503,7 +500,7 @@ def populate_load_commands end # The low file offset (offset to first section data). - # @return [Fixnum] the offset + # @return [Integer] the offset # @api private def low_fileoff offset = @raw_data.size @@ -523,7 +520,7 @@ def low_fileoff end # Updates the number of load commands in the raw data. - # @param ncmds [Fixnum] the new number of commands + # @param ncmds [Integer] the new number of commands # @return [void] # @api private def update_ncmds(ncmds) @@ -533,7 +530,7 @@ def update_ncmds(ncmds) end # Updates the size of all load commands in the raw data. - # @param size [Fixnum] the new size, in bytes + # @param size [Integer] the new size, in bytes # @return [void] # @api private def update_sizeofcmds(size)
true
Other
Homebrew
brew
99bf57d366b93dad617246dfe10867b6a34ab2b2.json
vendor: Update ruby-macho to 1.2.0 See https://github.com/Homebrew/homebrew-core/issues/28675.
Library/Homebrew/vendor/macho/macho/sections.rb
@@ -76,25 +76,25 @@ class Section < MachOStructure # pad bytes attr_reader :segname - # @return [Fixnum] the memory address of the section + # @return [Integer] the memory address of the section attr_reader :addr - # @return [Fixnum] the size, in bytes, of the section + # @return [Integer] the size, in bytes, of the section attr_reader :size - # @return [Fixnum] the file offset of the section + # @return [Integer] the file offset of the section attr_reader :offset - # @return [Fixnum] the section alignment (power of 2) of the section + # @return [Integer] the section alignment (power of 2) of the section attr_reader :align - # @return [Fixnum] the file offset of the section's relocation entries + # @return [Integer] the file offset of the section's relocation entries attr_reader :reloff - # @return [Fixnum] the number of relocation entries + # @return [Integer] the number of relocation entries attr_reader :nreloc - # @return [Fixnum] flags for type and attributes of the section + # @return [Integer] flags for type and attributes of the section attr_reader :flags # @return [void] reserved (for offset or index)
true
Other
Homebrew
brew
99bf57d366b93dad617246dfe10867b6a34ab2b2.json
vendor: Update ruby-macho to 1.2.0 See https://github.com/Homebrew/homebrew-core/issues/28675.
Library/Homebrew/vendor/macho/macho/structure.rb
@@ -8,11 +8,11 @@ class MachOStructure FORMAT = "".freeze # The size of the data structure, in bytes. - # @return [Fixnum] the size, in bytes + # @return [Integer] the size, in bytes # @api private SIZEOF = 0 - # @return [Fixnum] the size, in bytes, of the represented structure. + # @return [Integer] the size, in bytes, of the represented structure. def self.bytesize self::SIZEOF end
true
Other
Homebrew
brew
99bf57d366b93dad617246dfe10867b6a34ab2b2.json
vendor: Update ruby-macho to 1.2.0 See https://github.com/Homebrew/homebrew-core/issues/28675.
Library/Homebrew/vendor/macho/macho/tools.rb
@@ -88,7 +88,7 @@ def self.delete_rpath(filename, old_path, options = {}) # Merge multiple Mach-Os into one universal (Fat) binary. # @param filename [String] the fat binary to create - # @param files [Array<MachO::MachOFile, MachO::FatFile>] the files to merge + # @param files [Array<String>] the files to merge # @return [void] def self.merge_machos(filename, *files) machos = files.map do |file|
true
Other
Homebrew
brew
99bf57d366b93dad617246dfe10867b6a34ab2b2.json
vendor: Update ruby-macho to 1.2.0 See https://github.com/Homebrew/homebrew-core/issues/28675.
Library/Homebrew/vendor/macho/macho/utils.rb
@@ -2,9 +2,9 @@ module MachO # A collection of utility functions used throughout ruby-macho. module Utils # Rounds a value to the next multiple of the given round. - # @param value [Fixnum] the number being rounded - # @param round [Fixnum] the number being rounded with - # @return [Fixnum] the rounded value + # @param value [Integer] the number being rounded + # @param round [Integer] the number being rounded with + # @return [Integer] the rounded value # @see http://www.opensource.apple.com/source/cctools/cctools-870/libstuff/rnd.c def self.round(value, round) round -= 1 @@ -15,9 +15,9 @@ def self.round(value, round) # Returns the number of bytes needed to pad the given size to the given # alignment. - # @param size [Fixnum] the unpadded size - # @param alignment [Fixnum] the number to alignment the size with - # @return [Fixnum] the number of pad bytes required + # @param size [Integer] the unpadded size + # @param alignment [Integer] the number to alignment the size with + # @return [Integer] the number of pad bytes required def self.padding_for(size, alignment) round(size, alignment) - size end @@ -33,9 +33,9 @@ def self.specialize_format(format, endianness) end # Packs tagged strings into an aligned payload. - # @param fixed_offset [Fixnum] the baseline offset for the first packed + # @param fixed_offset [Integer] the baseline offset for the first packed # string - # @param alignment [Fixnum] the alignment value to use for packing + # @param alignment [Integer] the alignment value to use for packing # @param strings [Hash] the labeled strings to pack # @return [Array<String, Hash>] the packed string and labeled offsets def self.pack_strings(fixed_offset, alignment, strings = {}) @@ -55,42 +55,42 @@ def self.pack_strings(fixed_offset, alignment, strings = {}) end # Compares the given number to valid Mach-O magic numbers. - # @param num [Fixnum] the number being checked + # @param num [Integer] the number being checked # @return [Boolean] whether `num` is a valid Mach-O magic number def self.magic?(num) Headers::MH_MAGICS.key?(num) end # Compares the given number to valid Fat magic numbers. - # @param num [Fixnum] the number being checked + # @param num [Integer] the number being checked # @return [Boolean] whether `num` is a valid Fat magic number def self.fat_magic?(num) num == Headers::FAT_MAGIC end # Compares the given number to valid 32-bit Mach-O magic numbers. - # @param num [Fixnum] the number being checked + # @param num [Integer] the number being checked # @return [Boolean] whether `num` is a valid 32-bit magic number def self.magic32?(num) num == Headers::MH_MAGIC || num == Headers::MH_CIGAM end # Compares the given number to valid 64-bit Mach-O magic numbers. - # @param num [Fixnum] the number being checked + # @param num [Integer] the number being checked # @return [Boolean] whether `num` is a valid 64-bit magic number def self.magic64?(num) num == Headers::MH_MAGIC_64 || num == Headers::MH_CIGAM_64 end # Compares the given number to valid little-endian magic numbers. - # @param num [Fixnum] the number being checked + # @param num [Integer] the number being checked # @return [Boolean] whether `num` is a valid little-endian magic number def self.little_magic?(num) num == Headers::MH_CIGAM || num == Headers::MH_CIGAM_64 end # Compares the given number to valid big-endian magic numbers. - # @param num [Fixnum] the number being checked + # @param num [Integer] the number being checked # @return [Boolean] whether `num` is a valid big-endian magic number def self.big_magic?(num) num == Headers::MH_CIGAM || num == Headers::MH_CIGAM_64
true
Other
Homebrew
brew
99bf57d366b93dad617246dfe10867b6a34ab2b2.json
vendor: Update ruby-macho to 1.2.0 See https://github.com/Homebrew/homebrew-core/issues/28675.
Library/Homebrew/vendor/macho/macho/view.rb
@@ -7,13 +7,13 @@ class MachOView # @return [Symbol] the endianness of the data (`:big` or `:little`) attr_reader :endianness - # @return [Fixnum] the offset of the relevant data (in {#raw_data}) + # @return [Integer] the offset of the relevant data (in {#raw_data}) attr_reader :offset # Creates a new MachOView. # @param raw_data [String] the raw Mach-O data # @param endianness [Symbol] the endianness of the data - # @param offset [Fixnum] the offset of the relevant data + # @param offset [Integer] the offset of the relevant data def initialize(raw_data, endianness, offset) @raw_data = raw_data @endianness = endianness
true
Other
Homebrew
brew
7f2cebd4dfd444adc8e19ffbdc16485d8725042e.json
Xcode: fix version detection with unknown clang
Library/Homebrew/os/mac/xcode.rb
@@ -147,6 +147,7 @@ def detect_version end def detect_version_from_clang_version + return "dunno" if DevelopmentTools.clang_version.null? # This logic provides a fake Xcode version based on the # installed CLT version. This is useful as they are packaged # simultaneously so workarounds need to apply to both based on their
false
Other
Homebrew
brew
b092f1d0a979ac5259242c0791537e3e5b30dc19.json
pkg-config: add initial files for 10.14
Library/Homebrew/os/mac/pkgconfig/10.14/libcurl.pc
@@ -0,0 +1,39 @@ +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) 2004 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at http://curl.haxx.se/docs/copyright.html. +# +# You may opt to use, copy, modify, merge, publish, distribute and/or sell +# copies of the Software, and permit persons to whom the Software is +# furnished to do so, under the terms of the COPYING file. +# +# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +# KIND, either express or implied. +# +########################################################################### + +# This should most probably benefit from getting a "Requires:" field added +# dynamically by configure. +# +prefix=/usr +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include +supported_protocols="DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS LDAP LDAPS POP3 POP3S RTSP SMB SMBS SMTP SMTPS TELNET TFTP" +supported_features="AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz HTTP2 UnixSockets HTTPS-proxy" + +Name: libcurl +URL: https://curl.haxx.se/ +Description: Library to transfer files with ftp, http, etc. +Version: 7.54.0 +Libs: -L${libdir} -lcurl +Libs.private: -lldap -lz +Cflags: -I${includedir}
true
Other
Homebrew
brew
b092f1d0a979ac5259242c0791537e3e5b30dc19.json
pkg-config: add initial files for 10.14
Library/Homebrew/os/mac/pkgconfig/10.14/libexslt.pc
@@ -0,0 +1,12 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + + +Name: libexslt +Version: 0.8.17 +Description: EXSLT Extension library +Requires: libxml-2.0 +Libs: -L${libdir} -lexslt -lxslt -lxml2 -lz -lpthread -licucore -lm +Cflags: -I${includedir}
true
Other
Homebrew
brew
b092f1d0a979ac5259242c0791537e3e5b30dc19.json
pkg-config: add initial files for 10.14
Library/Homebrew/os/mac/pkgconfig/10.14/libxml-2.0.pc
@@ -0,0 +1,13 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include +modules=1 + +Name: libXML +Version: 2.9.4 +Description: libXML library version2. +Requires: +Libs: -L${libdir} -lxml2 +Libs.private: -lz -lpthread -licucore -lm +Cflags: -I${includedir}/libxml2
true
Other
Homebrew
brew
b092f1d0a979ac5259242c0791537e3e5b30dc19.json
pkg-config: add initial files for 10.14
Library/Homebrew/os/mac/pkgconfig/10.14/libxslt.pc
@@ -0,0 +1,12 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + + +Name: libxslt +Version: 1.1.29 +Description: XSLT library version 2. +Requires: libxml-2.0 +Libs: -L${libdir} -lxslt -lxml2 -lz -lpthread -licucore -lm +Cflags: -I${includedir}
true
Other
Homebrew
brew
b092f1d0a979ac5259242c0791537e3e5b30dc19.json
pkg-config: add initial files for 10.14
Library/Homebrew/os/mac/pkgconfig/10.14/sqlite3.pc
@@ -0,0 +1,11 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: SQLite +Description: SQL database engine +Version: 3.22.0 +Libs: -L${libdir} -lsqlite3 +Libs.private: +Cflags: -I${includedir}
true
Other
Homebrew
brew
b092f1d0a979ac5259242c0791537e3e5b30dc19.json
pkg-config: add initial files for 10.14
Library/Homebrew/os/mac/pkgconfig/10.14/zlib.pc
@@ -0,0 +1,13 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +sharedlibdir=${libdir} +includedir=${prefix}/include + +Name: zlib +Description: zlib compression library +Version: 1.2.11 + +Requires: +Libs: -L${libdir} -L${sharedlibdir} -lz +Cflags: -I${includedir}
true
Other
Homebrew
brew
194c48e9d291f126151f1c2dc1a7829b92d8184d.json
xcode: add initial support for Xcode 10.0
Library/Homebrew/os/mac/xcode.rb
@@ -19,16 +19,18 @@ def latest_version when "10.11" then "8.2.1" when "10.12" then "9.2" when "10.13" then "9.3" + when "10.14" then "10.0" else raise "macOS '#{MacOS.version}' is invalid" unless OS::Mac.prerelease? # Default to newest known version of Xcode for unreleased macOS versions. - "9.3" + "10.0" end end def minimum_version case MacOS.version + when "10.14" then "10.0" when "10.13" then "9.0" when "10.12" then "8.0" else "2.0" @@ -171,7 +173,8 @@ def detect_version_from_clang_version when 81 then "8.3" when 90 then "9.2" when 91 then "9.3" - else "9.3" + when 100 then "10.0" + else "10.0" end end @@ -222,6 +225,7 @@ def latest_version # on the older supported platform for that Xcode release, i.e there's no # CLT package for 10.11 that contains the Clang version from Xcode 8. case MacOS.version + when "10.14" then "1000.10.25.5" when "10.13" then "902.0.39.1" when "10.12" then "900.0.39.2" when "10.11" then "800.0.42.1"
false
Other
Homebrew
brew
9391ac01a987769f1a9dd3b4459433dcdb71bcf2.json
test: add symlink for macOS Mojave bottle
Library/Homebrew/test/support/fixtures/bottles/testball_bottle-0.1.mojave.bottle.tar.gz
@@ -0,0 +1 @@ +testball_bottle-0.1.yosemite.bottle.tar.gz \ No newline at end of file
false
Other
Homebrew
brew
0c12ab5e83c0117ca7839cf9763677113baa87db.json
mac/version: add symbol for macOS Mojave
Library/Homebrew/os/mac/version.rb
@@ -4,6 +4,7 @@ module OS module Mac class Version < ::Version SYMBOLS = { + mojave: "10.14", high_sierra: "10.13", sierra: "10.12", el_capitan: "10.11",
false
Other
Homebrew
brew
e05f72bc5232a7fd880da28050e59e45123ef0d7.json
create: Move FormulaCreator to formula_creator.rb
Library/Homebrew/dev-cmd/create.rb
@@ -20,10 +20,9 @@ #: the specified tap. require "formula" +require "formula_creator" require "missing_formula" require "cli_parser" -require "digest" -require "erb" module Homebrew module_function @@ -41,7 +40,7 @@ def create switch :debug flag "--set-name=" flag "--set-version=" - flag "--tag=" + flag "--tap=" end raise UsageError if ARGV.named.empty? @@ -103,153 +102,4 @@ def __gets gots = $stdin.gets.chomp gots.empty? ? nil : gots end - - class FormulaCreator - attr_reader :url, :sha256, :desc, :homepage - attr_accessor :name, :version, :tap, :path, :mode - - def url=(url) - @url = url - path = Pathname.new(url) - if @name.nil? - case url - when %r{github\.com/(\S+)/(\S+)\.git} - @user = Regexp.last_match(1) - @name = Regexp.last_match(2) - @head = true - @github = true - when %r{github\.com/(\S+)/(\S+)/(archive|releases)/} - @user = Regexp.last_match(1) - @name = Regexp.last_match(2) - @github = true - else - @name = path.basename.to_s[/(.*?)[-_.]?#{Regexp.escape(path.version.to_s)}/, 1] - end - end - update_path - if @version - @version = Version.create(@version) - else - @version = Version.detect(url, {}) - end - end - - def update_path - return if @name.nil? || @tap.nil? - @path = Formulary.path "#{@tap}/#{@name}" - end - - def fetch? - !Homebrew.args.no_fetch? - end - - def head? - @head || Homebrew.args.head? - end - - def generate! - raise "#{path} already exists" if path.exist? - - if version.nil? || version.null? - opoo "Version cannot be determined from URL." - puts "You'll need to add an explicit 'version' to the formula." - elsif fetch? - unless head? - r = Resource.new - r.url(url) - r.version(version) - r.owner = self - @sha256 = r.fetch.sha256 if r.download_strategy == CurlDownloadStrategy - end - - if @user && @name - begin - metadata = GitHub.repository(@user, @name) - @desc = metadata["description"] - @homepage = metadata["homepage"] - rescue GitHub::HTTPNotFoundError - # If there was no repository found assume the network connection is at - # fault rather than the input URL. - nil - end - end - end - - path.write ERB.new(template, nil, ">").result(binding) - end - - def template - <<~EOS - # Documentation: https://docs.brew.sh/Formula-Cookbook - # http://www.rubydoc.info/github/Homebrew/brew/master/Formula - # PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST! - class #{Formulary.class_s(name)} < Formula - desc "#{desc}" - homepage "#{homepage}" - <% if head? %> - head "#{url}" - <% else %> - url "#{url}" - <% unless version.nil? or version.detected_from_url? %> - version "#{version}" - <% end %> - sha256 "#{sha256}" - <% end %> - <% if mode == :cmake %> - depends_on "cmake" => :build - <% elsif mode == :meson %> - depends_on "meson-internal" => :build - depends_on "ninja" => :build - depends_on "python" => :build - <% elsif mode.nil? %> - # depends_on "cmake" => :build - <% end %> - - def install - # ENV.deparallelize # if your formula fails when building in parallel - <% if mode == :cmake %> - system "cmake", ".", *std_cmake_args - <% elsif mode == :autotools %> - # Remove unrecognized options if warned by configure - system "./configure", "--disable-debug", - "--disable-dependency-tracking", - "--disable-silent-rules", - "--prefix=\#{prefix}" - <% elsif mode == :meson %> - ENV.refurbish_args - - mkdir "build" do - system "meson", "--prefix=\#{prefix}", ".." - system "ninja" - system "ninja", "install" - end - <% else %> - # Remove unrecognized options if warned by configure - system "./configure", "--disable-debug", - "--disable-dependency-tracking", - "--disable-silent-rules", - "--prefix=\#{prefix}" - # system "cmake", ".", *std_cmake_args - <% end %> - <% if mode != :meson %> - system "make", "install" # if this fails, try separate make/make install steps - <% end %> - end - - test do - # `test do` will create, run in and delete a temporary directory. - # - # This test will fail and we won't accept that! For Homebrew/homebrew-core - # this will need to be a test that verifies the functionality of the - # software. Run the test with `brew test #{name}`. Options passed - # to `brew install` such as `--HEAD` also need to be provided to `brew test`. - # - # The installed folder is not in the path, so use the entire path to any - # executables being tested: `system "\#{bin}/program", "do", "something"`. - system "false" - end - end - EOS - end - end end
true
Other
Homebrew
brew
e05f72bc5232a7fd880da28050e59e45123ef0d7.json
create: Move FormulaCreator to formula_creator.rb
Library/Homebrew/formula_creator.rb
@@ -0,0 +1,153 @@ +require "digest" +require "erb" + +module Homebrew + class FormulaCreator + attr_reader :url, :sha256, :desc, :homepage + attr_accessor :name, :version, :tap, :path, :mode + + def url=(url) + @url = url + path = Pathname.new(url) + if @name.nil? + case url + when %r{github\.com/(\S+)/(\S+)\.git} + @user = Regexp.last_match(1) + @name = Regexp.last_match(2) + @head = true + @github = true + when %r{github\.com/(\S+)/(\S+)/(archive|releases)/} + @user = Regexp.last_match(1) + @name = Regexp.last_match(2) + @github = true + else + @name = path.basename.to_s[/(.*?)[-_.]?#{Regexp.escape(path.version.to_s)}/, 1] + end + end + update_path + if @version + @version = Version.create(@version) + else + @version = Version.detect(url, {}) + end + end + + def update_path + return if @name.nil? || @tap.nil? + @path = Formulary.path "#{@tap}/#{@name}" + end + + def fetch? + !Homebrew.args.no_fetch? + end + + def head? + @head || Homebrew.args.HEAD? + end + + def generate! + raise "#{path} already exists" if path.exist? + + if version.nil? || version.null? + opoo "Version cannot be determined from URL." + puts "You'll need to add an explicit 'version' to the formula." + elsif fetch? + unless head? + r = Resource.new + r.url(url) + r.version(version) + r.owner = self + @sha256 = r.fetch.sha256 if r.download_strategy == CurlDownloadStrategy + end + + if @user && @name + begin + metadata = GitHub.repository(@user, @name) + @desc = metadata["description"] + @homepage = metadata["homepage"] + rescue GitHub::HTTPNotFoundError + # If there was no repository found assume the network connection is at + # fault rather than the input URL. + nil + end + end + end + + path.write ERB.new(template, nil, ">").result(binding) + end + + def template + <<~EOS + # Documentation: https://docs.brew.sh/Formula-Cookbook + # http://www.rubydoc.info/github/Homebrew/brew/master/Formula + # PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST! + class #{Formulary.class_s(name)} < Formula + desc "#{desc}" + homepage "#{homepage}" + <% if head? %> + head "#{url}" + <% else %> + url "#{url}" + <% unless version.nil? or version.detected_from_url? %> + version "#{version}" + <% end %> + sha256 "#{sha256}" + <% end %> + <% if mode == :cmake %> + depends_on "cmake" => :build + <% elsif mode == :meson %> + depends_on "meson-internal" => :build + depends_on "ninja" => :build + depends_on "python" => :build + <% elsif mode.nil? %> + # depends_on "cmake" => :build + <% end %> + + def install + # ENV.deparallelize # if your formula fails when building in parallel + <% if mode == :cmake %> + system "cmake", ".", *std_cmake_args + <% elsif mode == :autotools %> + # Remove unrecognized options if warned by configure + system "./configure", "--disable-debug", + "--disable-dependency-tracking", + "--disable-silent-rules", + "--prefix=\#{prefix}" + <% elsif mode == :meson %> + ENV.refurbish_args + + mkdir "build" do + system "meson", "--prefix=\#{prefix}", ".." + system "ninja" + system "ninja", "install" + end + <% else %> + # Remove unrecognized options if warned by configure + system "./configure", "--disable-debug", + "--disable-dependency-tracking", + "--disable-silent-rules", + "--prefix=\#{prefix}" + # system "cmake", ".", *std_cmake_args + <% end %> + <% if mode != :meson %> + system "make", "install" # if this fails, try separate make/make install steps + <% end %> + end + + test do + # `test do` will create, run in and delete a temporary directory. + # + # This test will fail and we won't accept that! For Homebrew/homebrew-core + # this will need to be a test that verifies the functionality of the + # software. Run the test with `brew test #{name}`. Options passed + # to `brew install` such as `--HEAD` also need to be provided to `brew test`. + # + # The installed folder is not in the path, so use the entire path to any + # executables being tested: `system "\#{bin}/program", "do", "something"`. + system "false" + end + end + EOS + end + end +end
true
Other
Homebrew
brew
1d3e8c5550a0c32a227f0cf3db97c2c0410fb886.json
Add test for locale.detect
Library/Homebrew/test/locale_spec.rb
@@ -72,4 +72,14 @@ expect(subject.eql?("zh_CN_Hans")).to be false end end + + describe "#detect" do + let(:locale_groups) { [["zh"], ["zh-TW"]] } + + it "finds best matching language code, independent of order" do + expect(described_class.new("zh", "TW", nil).detect(locale_groups)).to eql(["zh-TW"]) + expect(described_class.new("zh", "TW", nil).detect(locale_groups.reverse)).to eql(["zh-TW"]) + expect(described_class.new("zh", "CN", "Hans").detect(locale_groups)).to eql(["zh"]) + end + end end
false
Other
Homebrew
brew
f60751d91c1c2cd8d0f20cc634be303d6665dfa4.json
create: Use Parser to parse args
Library/Homebrew/dev-cmd/create.rb
@@ -21,6 +21,7 @@ require "formula" require "missing_formula" +require "cli_parser" require "digest" require "erb" @@ -29,16 +30,29 @@ module Homebrew # Create a formula from a tarball URL def create + Homebrew::CLI::Parser.parse do + switch "--autotools" + switch "--cmake" + switch "--meson" + switch "--no-fetch" + switch "--HEAD" + switch :force + switch :verbose + switch :debug + flag "--set-name=" + flag "--set-version=" + flag "--tag=" + end raise UsageError if ARGV.named.empty? # Ensure that the cache exists so we can fetch the tarball HOMEBREW_CACHE.mkpath url = ARGV.named.first # Pull the first (and only) url from ARGV - version = ARGV.next if ARGV.include? "--set-version" - name = ARGV.next if ARGV.include? "--set-name" - tap = ARGV.next if ARGV.include? "--tap" + version = args.set_version + name = args.set_name + tap = args.tap fc = FormulaCreator.new fc.name = name @@ -47,11 +61,11 @@ def create raise TapUnavailableError, tap unless fc.tap.installed? fc.url = url - fc.mode = if ARGV.include? "--cmake" + fc.mode = if args.cmake? :cmake - elsif ARGV.include? "--autotools" + elsif args.autotools? :autotools - elsif ARGV.include? "--meson" + elsif args.meson? :meson end @@ -64,7 +78,7 @@ def create # Don't allow blacklisted formula, or names that shadow aliases, # unless --force is specified. - unless ARGV.force? + unless args.force? if reason = MissingFormula.blacklisted_reason(fc.name) raise "#{fc.name} is blacklisted for creation.\n#{reason}\nIf you really want to create this formula use --force." end @@ -89,153 +103,153 @@ def __gets gots = $stdin.gets.chomp gots.empty? ? nil : gots end -end -class FormulaCreator - attr_reader :url, :sha256, :desc, :homepage - attr_accessor :name, :version, :tap, :path, :mode - - def url=(url) - @url = url - path = Pathname.new(url) - if @name.nil? - case url - when %r{github\.com/(\S+)/(\S+)\.git} - @user = Regexp.last_match(1) - @name = Regexp.last_match(2) - @head = true - @github = true - when %r{github\.com/(\S+)/(\S+)/(archive|releases)/} - @user = Regexp.last_match(1) - @name = Regexp.last_match(2) - @github = true + class FormulaCreator + attr_reader :url, :sha256, :desc, :homepage + attr_accessor :name, :version, :tap, :path, :mode + + def url=(url) + @url = url + path = Pathname.new(url) + if @name.nil? + case url + when %r{github\.com/(\S+)/(\S+)\.git} + @user = Regexp.last_match(1) + @name = Regexp.last_match(2) + @head = true + @github = true + when %r{github\.com/(\S+)/(\S+)/(archive|releases)/} + @user = Regexp.last_match(1) + @name = Regexp.last_match(2) + @github = true + else + @name = path.basename.to_s[/(.*?)[-_.]?#{Regexp.escape(path.version.to_s)}/, 1] + end + end + update_path + if @version + @version = Version.create(@version) else - @name = path.basename.to_s[/(.*?)[-_.]?#{Regexp.escape(path.version.to_s)}/, 1] + @version = Version.detect(url, {}) end end - update_path - if @version - @version = Version.create(@version) - else - @version = Version.detect(url, {}) - end - end - def update_path - return if @name.nil? || @tap.nil? - @path = Formulary.path "#{@tap}/#{@name}" - end + def update_path + return if @name.nil? || @tap.nil? + @path = Formulary.path "#{@tap}/#{@name}" + end - def fetch? - !ARGV.include?("--no-fetch") - end + def fetch? + !Homebrew.args.no_fetch? + end - def head? - @head || ARGV.build_head? - end + def head? + @head || Homebrew.args.head? + end - def generate! - raise "#{path} already exists" if path.exist? - - if version.nil? || version.null? - opoo "Version cannot be determined from URL." - puts "You'll need to add an explicit 'version' to the formula." - elsif fetch? - unless head? - r = Resource.new - r.url(url) - r.version(version) - r.owner = self - @sha256 = r.fetch.sha256 if r.download_strategy == CurlDownloadStrategy - end + def generate! + raise "#{path} already exists" if path.exist? + + if version.nil? || version.null? + opoo "Version cannot be determined from URL." + puts "You'll need to add an explicit 'version' to the formula." + elsif fetch? + unless head? + r = Resource.new + r.url(url) + r.version(version) + r.owner = self + @sha256 = r.fetch.sha256 if r.download_strategy == CurlDownloadStrategy + end - if @user && @name - begin - metadata = GitHub.repository(@user, @name) - @desc = metadata["description"] - @homepage = metadata["homepage"] - rescue GitHub::HTTPNotFoundError - # If there was no repository found assume the network connection is at - # fault rather than the input URL. - nil + if @user && @name + begin + metadata = GitHub.repository(@user, @name) + @desc = metadata["description"] + @homepage = metadata["homepage"] + rescue GitHub::HTTPNotFoundError + # If there was no repository found assume the network connection is at + # fault rather than the input URL. + nil + end end end - end - path.write ERB.new(template, nil, ">").result(binding) - end + path.write ERB.new(template, nil, ">").result(binding) + end - def template - <<~EOS - # Documentation: https://docs.brew.sh/Formula-Cookbook - # http://www.rubydoc.info/github/Homebrew/brew/master/Formula - # PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST! - class #{Formulary.class_s(name)} < Formula - desc "#{desc}" - homepage "#{homepage}" - <% if head? %> - head "#{url}" - <% else %> - url "#{url}" - <% unless version.nil? or version.detected_from_url? %> - version "#{version}" - <% end %> - sha256 "#{sha256}" - <% end %> - <% if mode == :cmake %> - depends_on "cmake" => :build - <% elsif mode == :meson %> - depends_on "meson-internal" => :build - depends_on "ninja" => :build - depends_on "python" => :build - <% elsif mode.nil? %> - # depends_on "cmake" => :build - <% end %> - - def install - # ENV.deparallelize # if your formula fails when building in parallel - <% if mode == :cmake %> - system "cmake", ".", *std_cmake_args - <% elsif mode == :autotools %> - # Remove unrecognized options if warned by configure - system "./configure", "--disable-debug", - "--disable-dependency-tracking", - "--disable-silent-rules", - "--prefix=\#{prefix}" - <% elsif mode == :meson %> - ENV.refurbish_args - - mkdir "build" do - system "meson", "--prefix=\#{prefix}", ".." - system "ninja" - system "ninja", "install" + def template + <<~EOS + # Documentation: https://docs.brew.sh/Formula-Cookbook + # http://www.rubydoc.info/github/Homebrew/brew/master/Formula + # PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST! + class #{Formulary.class_s(name)} < Formula + desc "#{desc}" + homepage "#{homepage}" + <% if head? %> + head "#{url}" + <% else %> + url "#{url}" + <% unless version.nil? or version.detected_from_url? %> + version "#{version}" + <% end %> + sha256 "#{sha256}" + <% end %> + <% if mode == :cmake %> + depends_on "cmake" => :build + <% elsif mode == :meson %> + depends_on "meson-internal" => :build + depends_on "ninja" => :build + depends_on "python" => :build + <% elsif mode.nil? %> + # depends_on "cmake" => :build + <% end %> + + def install + # ENV.deparallelize # if your formula fails when building in parallel + <% if mode == :cmake %> + system "cmake", ".", *std_cmake_args + <% elsif mode == :autotools %> + # Remove unrecognized options if warned by configure + system "./configure", "--disable-debug", + "--disable-dependency-tracking", + "--disable-silent-rules", + "--prefix=\#{prefix}" + <% elsif mode == :meson %> + ENV.refurbish_args + + mkdir "build" do + system "meson", "--prefix=\#{prefix}", ".." + system "ninja" + system "ninja", "install" + end + <% else %> + # Remove unrecognized options if warned by configure + system "./configure", "--disable-debug", + "--disable-dependency-tracking", + "--disable-silent-rules", + "--prefix=\#{prefix}" + # system "cmake", ".", *std_cmake_args + <% end %> + <% if mode != :meson %> + system "make", "install" # if this fails, try separate make/make install steps + <% end %> end - <% else %> - # Remove unrecognized options if warned by configure - system "./configure", "--disable-debug", - "--disable-dependency-tracking", - "--disable-silent-rules", - "--prefix=\#{prefix}" - # system "cmake", ".", *std_cmake_args - <% end %> - <% if mode != :meson %> - system "make", "install" # if this fails, try separate make/make install steps - <% end %> - end - test do - # `test do` will create, run in and delete a temporary directory. - # - # This test will fail and we won't accept that! For Homebrew/homebrew-core - # this will need to be a test that verifies the functionality of the - # software. Run the test with `brew test #{name}`. Options passed - # to `brew install` such as `--HEAD` also need to be provided to `brew test`. - # - # The installed folder is not in the path, so use the entire path to any - # executables being tested: `system "\#{bin}/program", "do", "something"`. - system "false" + test do + # `test do` will create, run in and delete a temporary directory. + # + # This test will fail and we won't accept that! For Homebrew/homebrew-core + # this will need to be a test that verifies the functionality of the + # software. Run the test with `brew test #{name}`. Options passed + # to `brew install` such as `--HEAD` also need to be provided to `brew test`. + # + # The installed folder is not in the path, so use the entire path to any + # executables being tested: `system "\#{bin}/program", "do", "something"`. + system "false" + end end - end - EOS + EOS + end end end
false
Other
Homebrew
brew
39a6f7f83f7c33d4b0367fb3d1cd2d71801167e0.json
linkage: Use Parser to parse args
Library/Homebrew/dev-cmd/linkage.rb
@@ -15,22 +15,31 @@ require "cache_store" require "linkage_checker" +require "cli_parser" module Homebrew module_function def linkage + Homebrew::CLI::Parser.parse do + switch "--test" + switch "--reverse" + switch "--cached" + switch :verbose + switch :debug + end + CacheStoreDatabase.use(:linkage) do |db| ARGV.kegs.each do |keg| ohai "Checking #{keg.name} linkage" if ARGV.kegs.size > 1 - use_cache = ARGV.include?("--cached") || ENV["HOMEBREW_LINKAGE_CACHE"] + use_cache = args.cached? || ENV["HOMEBREW_LINKAGE_CACHE"] result = LinkageChecker.new(keg, use_cache: use_cache, cache_db: db) - if ARGV.include?("--test") + if args.test? result.display_test_output Homebrew.failed = true if result.broken_library_linkage? - elsif ARGV.include?("--reverse") + elsif args.reverse? result.display_reverse_output else result.display_normal_output
false
Other
Homebrew
brew
d98c45b2d3e06385fd2026ed6f431b93a4614c46.json
Fix code style in `audit` spec.
Library/Homebrew/test/dev-cmd/audit_spec.rb
@@ -4,7 +4,7 @@ module Count def self.increment @count ||= 0 - @count += 1 + @count += 1 end end @@ -350,23 +350,22 @@ class Foo < Formula end describe "#audit_revision_and_version_scheme" do - subject do + subject { fa = described_class.new(Formulary.factory(formula_path)) fa.audit_revision_and_version_scheme fa.problems.first - end + } let(:origin_tap_path) { Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" } - let(:formula_subpath) { "Formula/foo#{@foo_version}.rb" } + let(:foo_version) { Count.increment } + let(:formula_subpath) { "Formula/foo#{foo_version}.rb" } let(:origin_formula_path) { origin_tap_path/formula_subpath } let(:tap_path) { Tap::TAP_DIRECTORY/"homebrew/homebrew-bar" } let(:formula_path) { tap_path/formula_subpath } before do - @foo_version = Count.increment - origin_formula_path.write <<~EOS - class Foo#{@foo_version} < Formula + class Foo#{foo_version} < Formula url "https://example.com/foo-1.0.tar.gz" revision 2 version_scheme 1
false
Other
Homebrew
brew
61617a257ec361b2c9701a42814f24415e2eddad.json
linkage_checker: use default use_cache parameter for callers.
Library/Homebrew/extend/os/mac/formula_cellar_checks.rb
@@ -67,9 +67,7 @@ def check_linkage keg = Keg.new(formula.prefix) CacheStoreDatabase.use(:linkage) do |db| - checker = LinkageChecker.new( - keg, formula, cache_db: db, use_cache: !ENV["HOMEBREW_LINKAGE_CACHE"].nil? - ) + checker = LinkageChecker.new(keg, formula, cache_db: db) next unless checker.broken_library_linkage? output = <<~EOS
true
Other
Homebrew
brew
61617a257ec361b2c9701a42814f24415e2eddad.json
linkage_checker: use default use_cache parameter for callers.
Library/Homebrew/formula.rb
@@ -1537,9 +1537,7 @@ def undeclared_runtime_dependencies return [] unless keg undeclared_deps = CacheStoreDatabase.use(:linkage) do |db| - linkage_checker = LinkageChecker.new( - keg, self, cache_db: db, use_cache: !ENV["HOMEBREW_LINKAGE_CACHE"].nil? - ) + linkage_checker = LinkageChecker.new(keg, self, cache_db: db) linkage_checker.undeclared_deps.map { |n| Dependency.new(n) } end
true
Other
Homebrew
brew
33cf882e348ae854f127ce7c1feec4235f552adc.json
bump-formula-pr: improve bad argument handling.
Library/Homebrew/dev-cmd/bump-formula-pr.rb
@@ -339,6 +339,9 @@ def inreplace_pairs(path, replacement_pairs) unless Homebrew.args.quiet? ohai "replace #{old.inspect} with #{new.inspect}" end + unless old + raise "No old value for new value #{new}! Did you pass the wrong arguments?" + end contents.gsub!(old, new) end unless contents.errors.empty? @@ -352,6 +355,9 @@ def inreplace_pairs(path, replacement_pairs) unless Homebrew.args.quiet? ohai "replace #{old.inspect} with #{new.inspect}" end + unless old + raise "No old value for new value #{new}! Did you pass the wrong arguments?" + end s.gsub!(old, new) end end
false
Other
Homebrew
brew
9e57be73eccbfebc2a8772d71a7eacebceba3ff6.json
shims/super/cc: Add support for Linux
Library/Homebrew/shims/linux/super/cc
@@ -1,366 +0,0 @@ -#!/bin/sh -# Make sure this shim uses the same Ruby interpreter that is used by Homebrew. -unset RUBYLIB -unset RUBYOPT -if [ -z "$HOMEBREW_RUBY_PATH" ] -then - echo "${0##*/}: The build tool has reset ENV; --env=std required." >&2 - exit 1 -fi -exec "$HOMEBREW_RUBY_PATH" -x "$0" "$@" -#!/usr/bin/env ruby -W0 - -require "pathname" -require "set" - -class Cmd - attr_reader :config, :prefix, :cellar, :opt, :tmpdir, :deps - attr_reader :archflags, :optflags, :keg_regex, :formula_prefix - - def initialize(arg0, args) - @arg0 = arg0 - @args = args.freeze - @config = ENV.fetch("HOMEBREW_CCCFG") { "" } - @prefix = ENV["HOMEBREW_PREFIX"] - @cellar = ENV["HOMEBREW_CELLAR"] - @opt = ENV["HOMEBREW_OPT"] - @tmpdir = ENV["HOMEBREW_TEMP"] - @archflags = ENV.fetch("HOMEBREW_ARCHFLAGS") { "" }.split(" ") - @optflags = ENV.fetch("HOMEBREW_OPTFLAGS") { "" }.split(" ") - @deps = Set.new(ENV.fetch("HOMEBREW_DEPENDENCIES") { "" }.split(",")) - @formula_prefix = ENV["HOMEBREW_FORMULA_PREFIX"] - # matches opt or cellar prefix and formula name - @keg_regex = %r[(#{Regexp.escape(opt)}|#{Regexp.escape(cellar)})/([\w+-.@]+)] - end - - def mode - if @arg0 == "cpp" || @arg0 == "ld" - @arg0.to_sym - elsif @arg0 == "gold" || @arg0 == "ld.gold" - :ld - elsif @args.include? "-c" - if @arg0 =~ /(?:c|g|clang)\+\+/ - :cxx - else - :cc - end - elsif @args.include?("-xc++-header") || @args.each_cons(2).include?(["-x", "c++-header"]) - :cxx - elsif @args.include? "-E" - :ccE - else - if @arg0 =~ /(?:c|g|clang)\+\+/ - :cxxld - else - :ccld - end - end - end - - def tool - @tool ||= case @arg0 - when "ld" then "ld" - when "gold", "ld.gold" then "ld.gold" - when "cpp" then "cpp" - when /llvm_(clang(\+\+)?)/ - "#{ENV["HOMEBREW_PREFIX"]}/opt/llvm/bin/#{$1}" - when /\w\+\+(-\d(\.\d)?)?$/ - case ENV["HOMEBREW_CC"] - when /clang/ - "clang++" - when /llvm-gcc/ - "llvm-g++-4.2" - when /gcc(-\d(\.\d)?)?$/ - "g++" + $1.to_s - end - else - # Note that this is a universal fallback, so that we'll always invoke - # HOMEBREW_CC regardless of what name under which the tool was invoked. - ENV["HOMEBREW_CC"] - end - end - - def args - if @args.length == 1 && @args[0] == "-v" - # Don't add linker arguments if -v passed as sole option. This stops gcc - # -v with no other arguments from outputting a linker error. Some - # software uses gcc -v (wrongly) to sniff the GCC version. - return @args.dup - end - - if !refurbish_args? || tool == "ld" || configure? - args = @args.dup - else - args = refurbished_args - end - - case mode - when :ccld - cflags + args + cppflags + ldflags - when :cxxld - cxxflags + args + cppflags + ldflags - when :cc - cflags + args + cppflags - when :cxx - cxxflags + args + cppflags - when :ccE - args + cppflags - when :cpp - args + cppflags - when :ld - ldflags + args - end - end - - def refurbished_args - @lset = Set.new(library_paths) - @iset = Set.new(isystem_paths + include_paths) - - args = [] - enum = @args.each - - loop do - case arg = enum.next - when "-arch" - if permit_arch_flags? - args << arg << enum.next - else - enum.next - end - when "-m32", "-m64" - args << arg if permit_arch_flags? - when /^-Xarch_/ - refurbished = refurbish_arg(enum.next, enum) - unless refurbished.empty? - args << arg - args += refurbished - end - else - args += refurbish_arg(arg, enum) - end - end - - args - end - - def refurbish_arg(arg, enum) - args = [] - - case arg - when /^-g\d?$/, /^-gstabs\d+/, "-gstabs+", /^-ggdb\d?/, - /^-march=.+/, /^-mtune=.+/, /^-mcpu=.+/, - /^-O[0-9zs]?$/, "-fast", "-no-cpp-precomp", - "-pedantic", "-pedantic-errors", "-Wno-long-double", - "-Wno-unused-but-set-variable" - when "-fopenmp", "-lgomp", "-mno-fused-madd", "-fforce-addr", "-fno-defer-pop", - "-mno-dynamic-no-pic", "-fearly-inlining", /^-f(?:no-)?inline-functions-called-once/, - /^-finline-limit/, /^-f(?:no-)?check-new/, "-fno-delete-null-pointer-checks", - "-fcaller-saves", "-fthread-jumps", "-fno-reorder-blocks", "-fcse-skip-blocks", - "-frerun-cse-after-loop", "-frerun-loop-opt", "-fcse-follow-jumps", - "-fno-regmove", "-fno-for-scope", "-fno-tree-pre", "-fno-tree-dominator-opts", - "-fuse-linker-plugin", "-frounding-math" - # clang doesn't support these flags - args << arg unless tool =~ /^clang/ - when "--fast-math" - arg = "-ffast-math" if tool =~ /^clang/ - args << arg - when "-Wno-deprecated-register" - # older gccs don't support these flags - args << arg unless tool =~ /^g..-4.[02]/ - when /^-Wl,-z,defs/ - # -Wl,-undefined,error is already the default - when /^-W[alp],/, /^-Wno-/ - args << arg - when /^-W.*/ - # prune warnings - when "-macosx_version_min", "-dylib_install_name" - args << "-Wl,#{arg},#{enum.next}" - when "-multiply_definedsuppress" - args << "-Wl,-multiply_defined,suppress" - when "-undefineddynamic_lookup" - args << "-Wl,-undefined,dynamic_lookup" - when /^-I(.+)?/ - # Support both "-Ifoo" (one argument) and "-I foo" (two arguments) - val = chuzzle($1) || enum.next - path = canonical_path(val) - args << "-I#{val}" if keep?(path) && @iset.add?(path) - when /^-L(.+)?/ - val = chuzzle($1) || enum.next - path = canonical_path(val) - args << "-L#{val}" if keep?(path) && @lset.add?(path) - else - args << arg - end - - args - end - - def keep?(path) - # Allow references to self - if formula_prefix && path.start_with?("#{formula_prefix}/") - true - # first two paths: reject references to Cellar or opt paths - # for unspecified dependencies - elsif path.start_with?(cellar) || path.start_with?(opt) - dep = path[keg_regex, 2] - dep && @deps.include?(dep) - else - path.start_with?(prefix, tmpdir) - end - end - - def cflags - args = [] - - return args unless refurbish_args? || configure? - - args << "-pipe" - args << "-w" unless configure? - args << "-#{ENV["HOMEBREW_OPTIMIZATION_LEVEL"]}" - args.concat(optflags) - args.concat(archflags) - args << "-std=#{@arg0}" if @arg0 =~ /c[89]9/ - args - end - - def cxxflags - args = cflags - args << "-std=c++11" if cxx11? - args << "-stdlib=libc++" if libcxx? - args << "-stdlib=libstdc++" if libstdcxx? - args - end - - def cppflags - path_flags("-isystem", isystem_paths) + path_flags("-I", include_paths) - end - - def ldflags - wl = "-Wl," unless mode == :ld - args = [] - args += ["#{wl}--dynamic-linker=#{dynamic_linker_path}"] if dynamic_linker_path - args << "-B#{@opt}/glibc/lib" unless mode == :ld - args += path_flags("-L", library_paths) - args += rpath_flags("#{wl}-rpath=", rpath_paths) - end - - def isystem_paths - path_split("HOMEBREW_ISYSTEM_PATHS") - end - - def include_paths - path_split("HOMEBREW_INCLUDE_PATHS") - end - - def library_paths - path_split("HOMEBREW_LIBRARY_PATHS") - end - - def rpath_paths - path_split("HOMEBREW_RPATH_PATHS") - end - - def dynamic_linker_path - chuzzle(ENV["HOMEBREW_DYNAMIC_LINKER"]) - end - - def configure? - # configure scripts generated with autoconf 2.61 or later export as_nl - ENV.key? "as_nl" - end - - def refurbish_args? - config.include?("O") - end - - def cxx11? - config.include?("x") - end - - def libcxx? - config.include?("g") - end - - def libstdcxx? - config.include?("h") - end - - def permit_arch_flags? - config.include?("K") - end - - def canonical_path(path) - path = Pathname.new(path) - path = path.realpath if path.exist? - path.to_s - end - - def path_flags(prefix, paths) - paths = paths.uniq.select { |path| File.directory?(path) } - paths.map! { |path| prefix + path } - end - - # Unlike path_flags, do not prune non-existant directories. - # formula.lib for example does not yet exist, but should not be pruned. - def rpath_flags(prefix, paths) - paths.uniq.map { |path| prefix + path } - end - - def path_split(key) - ENV.fetch(key) { "" }.split(File::PATH_SEPARATOR) - end - - def chuzzle(val) - return val if val.nil? - val = val.chomp - return val unless val.empty? - end -end - -def log(basename, argv, tool, args) - return unless ENV.key?("HOMEBREW_CC_LOG_PATH") - - adds = args - argv - dels = argv - args - - s = "" - s << "#{basename} called with: #{argv.join(" ")}\n" - s << "superenv removed: #{dels.join(" ")}\n" unless dels.empty? - s << "superenv added: #{adds.join(" ")}\n" unless adds.empty? - s << "superenv executed: #{tool} #{args.join(" ")}\n\n" - File.open("#{ENV["HOMEBREW_CC_LOG_PATH"]}.cc", "a+") { |f| f.write(s) } -end - -def remove_superbin_from_path(paths) - superbin = Pathname.new(__FILE__).dirname.realpath - paths.reject do |x| - path = Pathname.new(x) - path.directory? && path.realpath == superbin - end -end - -if __FILE__ == $PROGRAM_NAME - ##################################################################### sanity - - if (cc = ENV["HOMEBREW_CC"]).nil? || cc.empty? || cc == "cc" - # those values are not allowed - ENV["HOMEBREW_CC"] = "clang" - end - - ####################################################################### main - - dirname, basename = File.split($0) - - cmd = Cmd.new(basename, ARGV) - tool = cmd.tool - args = cmd.args - - log(basename, ARGV, tool, args) - - paths = ENV["PATH"].split(":") - paths = remove_superbin_from_path(paths) - paths.unshift "#{ENV["HOMEBREW_PREFIX"]}/bin" - ENV["PATH"] = paths.join(":") - args << { :close_others => false } - exec tool, *args -end
true
Other
Homebrew
brew
9e57be73eccbfebc2a8772d71a7eacebceba3ff6.json
shims/super/cc: Add support for Linux
Library/Homebrew/shims/linux/super/cc
@@ -0,0 +1 @@ +../../super/cc \ No newline at end of file
true
Other
Homebrew
brew
9e57be73eccbfebc2a8772d71a7eacebceba3ff6.json
shims/super/cc: Add support for Linux
Library/Homebrew/shims/super/cc
@@ -13,6 +13,14 @@ exec "$HOMEBREW_RUBY_PATH" -x "$0" "$@" require "pathname" require "set" +def mac? + RUBY_PLATFORM[/darwin/] +end + +def linux? + RUBY_PLATFORM[/linux/] +end + class Cmd attr_reader :config, :prefix, :cellar, :opt, :tmpdir, :sysroot, :deps attr_reader :archflags, :optflags, :keg_regex, :formula_prefix @@ -35,8 +43,10 @@ class Cmd end def mode - if @arg0 == "cpp" || @arg0 == "ld" - @arg0.to_sym + if @arg0 == "cpp" + :cpp + elsif ["ld", "ld.gold", "gold"].include? @arg0 + :ld elsif @args.include? "-c" if @arg0 =~ /(?:c|g|clang)\+\+/ :cxx @@ -59,6 +69,7 @@ class Cmd def tool @tool ||= case @arg0 when "ld" then "ld" + when "gold", "ld.gold" then "ld.gold" when "cpp" then "cpp" when /llvm_(clang(\+\+)?)/ "#{ENV["HOMEBREW_PREFIX"]}/opt/llvm/bin/#{$1}" @@ -190,9 +201,13 @@ class Cmd when "-undefineddynamic_lookup" args << "-Wl,-undefined,dynamic_lookup" when /^-isysroot/, /^--sysroot/ - sdk = enum.next - # We set the sysroot for macOS SDKs - args << "-isysroot" << sdk unless sdk.downcase.include? "osx" + if mac? + sdk = enum.next + # We set the sysroot for macOS SDKs + args << "-isysroot" << sdk unless sdk.downcase.include? "osx" + else + args << arg << enum.next + end when "-dylib" args << "-Wl,#{arg}" when /^-I(.+)?/ @@ -220,11 +235,15 @@ class Cmd elsif path.start_with?(cellar) || path.start_with?(opt) dep = path[keg_regex, 2] dep && @deps.include?(dep) - elsif path.start_with?(prefix) + elsif path.start_with?(prefix, tmpdir) true - else + elsif path.start_with?("/opt/local", "/opt/boxen/homebrew", "/opt/X11", "/sw", "/usr/X11") # ignore MacPorts, Boxen's Homebrew, X11, fink - !path.start_with?("/opt/local", "/opt/boxen/homebrew", "/opt/X11", "/sw", "/usr/X11") + false + elsif mac? + true + else + false end end @@ -254,8 +273,7 @@ class Cmd path_flags("-isystem", isystem_paths) + path_flags("-I", include_paths) end - def ldflags - args = path_flags("-L", library_paths) + def ldflags_mac(args) case mode when :ld args << "-headerpad_max_install_names" @@ -267,6 +285,27 @@ class Cmd args end + def ldflags_linux(args) + unless mode == :ld + wl = "-Wl," + args << "-B#{@opt}/glibc/lib" + end + args += rpath_flags("#{wl}-rpath=", rpath_paths) + args += ["#{wl}--dynamic-linker=#{dynamic_linker_path}"] if dynamic_linker_path + args + end + + def ldflags + args = path_flags("-L", library_paths) + if mac? + ldflags_mac(args) + elsif linux? + ldflags_linux(args) + else + args + end + end + def isystem_paths path_split("HOMEBREW_ISYSTEM_PATHS") end @@ -279,6 +318,14 @@ class Cmd path_split("HOMEBREW_LIBRARY_PATHS") end + def rpath_paths + path_split("HOMEBREW_RPATH_PATHS") + end + + def dynamic_linker_path + chuzzle(ENV["HOMEBREW_DYNAMIC_LINKER"]) + end + def system_library_paths paths = ["#{sysroot}/usr/lib"] paths << "/usr/local/lib" unless sysroot || ENV["SDKROOT"] @@ -325,6 +372,12 @@ class Cmd paths.map! { |path| prefix + path } end + # Unlike path_flags, do not prune non-existant directories. + # formula.lib for example does not yet exist, but should not be pruned. + def rpath_flags(prefix, paths) + paths.uniq.map { |path| prefix + path } + end + def path_split(key) ENV.fetch(key) { "" }.split(File::PATH_SEPARATOR) end @@ -350,6 +403,14 @@ def log(basename, argv, tool, args) File.open("#{ENV["HOMEBREW_CC_LOG_PATH"]}.cc", "a+") { |f| f.write(s) } end +def remove_superbin_from_path(paths) + superbin = Pathname.new(__FILE__).dirname.realpath + paths.reject do |x| + path = Pathname.new(x) + path.directory? && path.realpath == superbin + end +end + if __FILE__ == $PROGRAM_NAME ##################################################################### sanity @@ -369,5 +430,13 @@ if __FILE__ == $PROGRAM_NAME log(basename, ARGV, tool, args) args << { :close_others => false } - exec "#{dirname}/xcrun", tool, *args + if mac? + exec "#{dirname}/xcrun", tool, *args + else + paths = ENV["PATH"].split(":") + paths = remove_superbin_from_path(paths) + paths.unshift "#{ENV["HOMEBREW_PREFIX"]}/bin" + ENV["PATH"] = paths.join(":") + exec tool, *args + end end
true
Other
Homebrew
brew
f308aa4800ad9e35b4d6fb98e7372f690048c1c2.json
Tty.width: use `tput cols` when `stty size` returns 0; bin/brew: add 'COLUMNS' and 'LINES' to env variables Signed-off-by: lukertty <lukertty@gmail.com>
Library/Homebrew/utils/tty.rb
@@ -7,7 +7,7 @@ def strip_ansi(string) def width width = `/bin/stty size 2>/dev/null`.split[1] - width ||= `/usr/bin/tput cols 2>/dev/null`.split[0] + width = `/usr/bin/tput cols 2>/dev/null`.split[0] if width.to_i.zero? width ||= 80 width.to_i end
true
Other
Homebrew
brew
f308aa4800ad9e35b4d6fb98e7372f690048c1c2.json
Tty.width: use `tput cols` when `stty size` returns 0; bin/brew: add 'COLUMNS' and 'LINES' to env variables Signed-off-by: lukertty <lukertty@gmail.com>
bin/brew
@@ -72,7 +72,7 @@ then FILTERED_ENV=() # Filter all but the specific variables. - for VAR in HOME SHELL PATH TERM LOGNAME USER CI TRAVIS SSH_AUTH_SOCK SUDO_ASKPASS \ + for VAR in HOME SHELL PATH TERM COLUMNS LINES LOGNAME USER CI TRAVIS SSH_AUTH_SOCK SUDO_ASKPASS \ http_proxy https_proxy ftp_proxy no_proxy all_proxy HTTPS_PROXY FTP_PROXY ALL_PROXY \ "${!HOMEBREW_@}" "${!TRAVIS_@}" do
true
Other
Homebrew
brew
f8f77ea52d2e8a8798fb216d73d2da0961f627d0.json
cmd/list: add common `ls` options. We need to manually specify these now so let's add a few that we'd either previously documented or we've caught being used in the wild and adjust the documentation accordingly.
Library/Homebrew/cmd/list.rb
@@ -1,7 +1,7 @@ -#: * `list`, `ls` [`--full-name`]: +#: * `list`, `ls` [`--full-name`] [`-1`] [`-l`] [`-t`] [`-r`]: #: List all installed formulae. If `--full-name` is passed, print formulae -#: with fully-qualified names. If `--full-name` is not passed, any other -#: options (e.g. `-t`) are passed to `ls` which produces the actual output. +#: with fully-qualified names. If `--full-name` is not passed, other +#: options (i.e. `-1`, `-l`, `-t` and `-r`) are passed to `ls` which produces the actual output. #: #: * `list`, `ls` `--unbrewed`: #: List all files in the Homebrew prefix not installed by Homebrew. @@ -33,6 +33,11 @@ def list switch "--full-name" switch "--multiple", depends_on: "--versions" switch :verbose + # passed through to ls + switch "-1" + switch "-l" + switch "-t" + switch "-r" end # Use of exec means we don't explicitly exit
true
Other
Homebrew
brew
f8f77ea52d2e8a8798fb216d73d2da0961f627d0.json
cmd/list: add common `ls` options. We need to manually specify these now so let's add a few that we'd either previously documented or we've caught being used in the wild and adjust the documentation accordingly.
docs/Manpage.md
@@ -302,10 +302,10 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note If `--force` (or `-f`) is passed, Homebrew will allow keg-only formulae to be linked. - * `list`, `ls` [`--full-name`]: + * `list`, `ls` [`--full-name`] [`-1`] [`-l`] [`-t`] [`-r`]: List all installed formulae. If `--full-name` is passed, print formulae - with fully-qualified names. If `--full-name` is not passed, any other - options (e.g. `-t`) are passed to `ls` which produces the actual output. + with fully-qualified names. If `--full-name` is not passed, other + options (i.e. `-1`, `-l`, `-t` and `-r`) are passed to `ls` which produces the actual output. * `list`, `ls` `--unbrewed`: List all files in the Homebrew prefix not installed by Homebrew.
true
Other
Homebrew
brew
f8f77ea52d2e8a8798fb216d73d2da0961f627d0.json
cmd/list: add common `ls` options. We need to manually specify these now so let's add a few that we'd either previously documented or we've caught being used in the wild and adjust the documentation accordingly.
manpages/brew.1
@@ -311,8 +311,8 @@ If \fB\-\-dry\-run\fR or \fB\-n\fR is passed, Homebrew will list all files which If \fB\-\-force\fR (or \fB\-f\fR) is passed, Homebrew will allow keg\-only formulae to be linked\. . .TP -\fBlist\fR, \fBls\fR [\fB\-\-full\-name\fR] -List all installed formulae\. If \fB\-\-full\-name\fR is passed, print formulae with fully\-qualified names\. If \fB\-\-full\-name\fR is not passed, any other options (e\.g\. \fB\-t\fR) are passed to \fBls\fR which produces the actual output\. +\fBlist\fR, \fBls\fR [\fB\-\-full\-name\fR] [\fB\-1\fR] [\fB\-l\fR] [\fB\-t\fR] [\fB\-r\fR] +List all installed formulae\. If \fB\-\-full\-name\fR is passed, print formulae with fully\-qualified names\. If \fB\-\-full\-name\fR is not passed, other options (i\.e\. \fB\-1\fR, \fB\-l\fR, \fB\-t\fR and \fB\-r\fR) are passed to \fBls\fR which produces the actual output\. . .TP \fBlist\fR, \fBls\fR \fB\-\-unbrewed\fR
true
Other
Homebrew
brew
81d467abbaa6410fc3734314b8a7605163d6c64f.json
with-languages.rb: remove trailing whitespace
Library/Homebrew/test/support/fixtures/cask/Casks/with-languages.rb
@@ -1,6 +1,6 @@ cask 'with-languages' do version '1.2.3' - + language "zh" do sha256 "abc123" "zh-CN" @@ -13,6 +13,6 @@ url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" homepage 'http://example.com/local-caffeine' - + app 'Caffeine.app' end
false
Other
Homebrew
brew
ecbd9b9a2675142e4f23eca1a181a210247bdcf8.json
Add gtk-mac-integration to gnome_devel_whitelist
Library/Homebrew/dev-cmd/audit.rb
@@ -606,6 +606,7 @@ def audit_specs libart 2.3.21 pygtkglext 1.1.0 libepoxy 1.5.0 + gtk-mac-integration 2.1.2 ].each_slice(2).to_a.map do |formula, version| [formula, version.split(".")[0..1].join(".")] end
false
Other
Homebrew
brew
d1fb1d2abc9eeffde4f2318f09d72978dd68949b.json
Use simpler check.
Library/Homebrew/cmd/search.rb
@@ -122,7 +122,7 @@ def search_taps(query, silent: false) matches.map do |match| filename = File.basename(match["path"], ".rb") tap = Tap.fetch(match["repository"]["full_name"]) - next if tap.installed? && !(tap.user == "Homebrew" && tap.repo.start_with?("cask")) + next if tap.installed? && !tap.name.start_with?("homebrew/cask") "#{tap.name}/#{filename}" end.compact end
false
Other
Homebrew
brew
50a43cf6780cc5380bb00d192296d91ebb3cddc9.json
Reset `repo_var` in `clear_cache`.
Library/Homebrew/compat/tap.rb
@@ -15,10 +15,9 @@ def initialize(user, repo) old_path = path old_remote = path.git_origin + clear_cache super(new_user, new_repo) - @repo_var = nil - new_initial_revision_var = "HOMEBREW_UPDATE_BEFORE#{repo_var}" new_current_revision_var = "HOMEBREW_UPDATE_AFTER#{repo_var}"
true
Other
Homebrew
brew
50a43cf6780cc5380bb00d192296d91ebb3cddc9.json
Reset `repo_var` in `clear_cache`.
Library/Homebrew/tap.rb
@@ -84,6 +84,7 @@ def initialize(user, repo) # clear internal cache def clear_cache @remote = nil + @repo_var = nil @formula_dir = nil @cask_dir = nil @formula_files = nil
true
Other
Homebrew
brew
27f1613cd3aba7e7141d27babc9dd728b5ceab83.json
Reset `repo_var` so it actually is re-computed.
Library/Homebrew/compat/tap.rb
@@ -17,6 +17,8 @@ def initialize(user, repo) super(new_user, new_repo) + @repo_var = nil + new_initial_revision_var = "HOMEBREW_UPDATE_BEFORE#{repo_var}" new_current_revision_var = "HOMEBREW_UPDATE_AFTER#{repo_var}"
false
Other
Homebrew
brew
54834ccbe3b97707bae1482d3bc10039ec1c01d6.json
Move `repo_var` method to `Tap` class.
Library/Homebrew/cmd/update-report.rb
@@ -327,11 +327,11 @@ def initialize(var_name) def initialize(tap) @tap = tap - initial_revision_var = "HOMEBREW_UPDATE_BEFORE#{repo_var}" + initial_revision_var = "HOMEBREW_UPDATE_BEFORE#{tap.repo_var}" @initial_revision = ENV[initial_revision_var].to_s raise ReporterRevisionUnsetError, initial_revision_var if @initial_revision.empty? - current_revision_var = "HOMEBREW_UPDATE_AFTER#{repo_var}" + current_revision_var = "HOMEBREW_UPDATE_AFTER#{tap.repo_var}" @current_revision = ENV[current_revision_var].to_s raise ReporterRevisionUnsetError, current_revision_var if @current_revision.empty? end @@ -531,13 +531,6 @@ def migrate_formula_rename private - def repo_var - @repo_var ||= tap.path.to_s - .strip_prefix(Tap::TAP_DIRECTORY.to_s) - .tr("^A-Za-z0-9", "_") - .upcase - end - def diff Utils.popen_read( "git", "-C", tap.path, "diff-tree", "-r", "--name-status", "--diff-filter=AMDR",
true
Other
Homebrew
brew
54834ccbe3b97707bae1482d3bc10039ec1c01d6.json
Move `repo_var` method to `Tap` class.
Library/Homebrew/tap.rb
@@ -111,6 +111,13 @@ def default_remote "https://github.com/#{full_name}" end + def repo_var + @repo_var ||= path.to_s + .strip_prefix(TAP_DIRECTORY.to_s) + .tr("^A-Za-z0-9", "_") + .upcase + end + # True if this {Tap} is a git repository. def git? path.git?
true
Other
Homebrew
brew
54834ccbe3b97707bae1482d3bc10039ec1c01d6.json
Move `repo_var` method to `Tap` class.
Library/Homebrew/test/cmd/update-report_spec.rb
@@ -20,8 +20,8 @@ def perform_update(fixture_name = "") def initialize(tap) @tap = tap - ENV["HOMEBREW_UPDATE_BEFORE#{repo_var}"] = "12345678" - ENV["HOMEBREW_UPDATE_AFTER#{repo_var}"] = "abcdef00" + ENV["HOMEBREW_UPDATE_BEFORE#{tap.repo_var}"] = "12345678" + ENV["HOMEBREW_UPDATE_AFTER#{tap.repo_var}"] = "abcdef00" super(tap) end
true
Other
Homebrew
brew
f7e308ab44f15db2e2d3536e1d8deb829705102e.json
list.rb: use new syntax correctly
Library/Homebrew/cmd/list.rb
@@ -31,7 +31,7 @@ def list switch "--pinned" switch "--versions" switch "--full-name" - switch "--multiple", required_for: "--versions" + switch "--multiple", depends_on: "--versions" switch :verbose end
false
Other
Homebrew
brew
0408b78a23092fb345bee7af3dcac7c62c175848.json
tests: remove linkage cache env. Otherwise this will mess with `brew tests`.
Library/Homebrew/dev-cmd/tests.rb
@@ -38,6 +38,7 @@ def tests ENV.delete("VERBOSE") ENV.delete("HOMEBREW_CASK_OPTS") ENV.delete("HOMEBREW_TEMP") + ENV.delete("HOMEBREW_LINKAGE_CACHE") ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1" ENV["HOMEBREW_DEVELOPER"] = "1" ENV["HOMEBREW_NO_COMPAT"] = "1" if args.no_compat?
true
Other
Homebrew
brew
0408b78a23092fb345bee7af3dcac7c62c175848.json
tests: remove linkage cache env. Otherwise this will mess with `brew tests`.
Library/Homebrew/test/spec_helper.rb
@@ -43,8 +43,8 @@ config.filter_run_when_matching :focus - # TODO when https://github.com/rspec/rspec-expectations/pull/1056 makes - # it into a stable release: + # TODO: when https://github.com/rspec/rspec-expectations/pull/1056 + # makes it into a stable release: # config.expect_with :rspec do |c| # c.max_formatted_output_length = 200 # end
true
Other
Homebrew
brew
f6bf9893780e17c0ae853a45944229286fbd5f88.json
Remove some integration tests We have an awful lot of integration tests and they are (comparatively) really slow. Let's kill those that test edge case conditions and focus on those that test that our functionality works as expected. Edge cases can be better tested with unit tests.
Library/Homebrew/test/cmd/analytics_spec.rb
@@ -30,20 +30,6 @@ end end - it "fails when running `brew analytics on off`" do - expect { brew "analytics", "on", "off" } - .to output(/Invalid usage/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - end - - it "fails when running `brew analytics testball`" do - expect { brew "analytics", "testball" } - .to output(/Invalid usage/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - end - it "can generate a new UUID" do expect { brew "analytics", "regenerate-uuid" }.to be_a_success end
true
Other
Homebrew
brew
f6bf9893780e17c0ae853a45944229286fbd5f88.json
Remove some integration tests We have an awful lot of integration tests and they are (comparatively) really slow. Let's kill those that test edge case conditions and focus on those that test that our functionality works as expected. Edge cases can be better tested with unit tests.
Library/Homebrew/test/cmd/command_spec.rb
@@ -4,10 +4,4 @@ .to output(%r{#{Regexp.escape(HOMEBREW_LIBRARY_PATH)}/cmd/info.rb}).to_stdout .and be_a_success end - - it "fails when the given command is unknown" do - expect { brew "command", "does-not-exist" } - .to output(/Unknown command/).to_stderr - .and be_a_failure - end end
true
Other
Homebrew
brew
f6bf9893780e17c0ae853a45944229286fbd5f88.json
Remove some integration tests We have an awful lot of integration tests and they are (comparatively) really slow. Let's kill those that test edge case conditions and focus on those that test that our functionality works as expected. Edge cases can be better tested with unit tests.
Library/Homebrew/test/cmd/desc_spec.rb
@@ -10,22 +10,6 @@ .and be_a_success end - it "fails when both --search and --name are specified" do - expect { brew "desc", "--search", "--name" } - .to output(/Pick one, and only one/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - end - - describe "--search" do - it "fails when no search term is given" do - expect { brew "desc", "--search" } - .to output(/You must provide a search term/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - end - end - describe "--description" do it "creates a description cache" do expect(desc_cache).not_to exist
true
Other
Homebrew
brew
f6bf9893780e17c0ae853a45944229286fbd5f88.json
Remove some integration tests We have an awful lot of integration tests and they are (comparatively) really slow. Let's kill those that test edge case conditions and focus on those that test that our functionality works as expected. Edge cases can be better tested with unit tests.
Library/Homebrew/test/cmd/install_spec.rb
@@ -2,21 +2,6 @@ it "installs Formulae" do setup_test_formula "testball1" - expect { brew "install", "testball1", "--head" } - .to output(/Specify `\-\-HEAD`/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - - expect { brew "install", "testball1", "--HEAD" } - .to output(/No head is defined/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - - expect { brew "install", "testball1", "--devel" } - .to output(/No devel block/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - expect { brew "install", "testball1" } .to output(%r{#{HOMEBREW_CELLAR}/testball1/0\.1}).to_stdout .and not_to_output.to_stderr @@ -27,27 +12,12 @@ .and not_to_output.to_stdout .and be_a_success - expect { brew "install", "macruby" } - .to output(/MacRuby is not packaged/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - expect { brew "install", "formula" } .to output(/No available formula/).to_stderr .and output(/Searching for similarly named formulae/).to_stdout .and be_a_failure - expect { brew "install", "testball" } - .to output(/This similarly named formula was found/).to_stdout - .and output(/No available formula/).to_stderr - .and be_a_failure - setup_test_formula "testball2" - expect { brew "install", "testball" } - .to output(/These similarly named formulae were found/).to_stdout - .and output(/No available formula/).to_stderr - .and be_a_failure - install_and_rename_coretap_formula "testball1", "testball2" expect { brew "install", "testball2" } .to output(/testball1 already installed, it's just not migrated/).to_stderr
true
Other
Homebrew
brew
f6bf9893780e17c0ae853a45944229286fbd5f88.json
Remove some integration tests We have an awful lot of integration tests and they are (comparatively) really slow. Let's kill those that test edge case conditions and focus on those that test that our functionality works as expected. Edge cases can be better tested with unit tests.
Library/Homebrew/test/cmd/link_spec.rb
@@ -1,11 +1,4 @@ describe "brew link", :integration_test do - it "fails when no argument is given" do - expect { brew "link" } - .to output(/This command requires a keg argument/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - end - it "does not fail if the given Formula is already linked" do setup_test_formula "testball1"
true
Other
Homebrew
brew
f6bf9893780e17c0ae853a45944229286fbd5f88.json
Remove some integration tests We have an awful lot of integration tests and they are (comparatively) really slow. Let's kill those that test edge case conditions and focus on those that test that our functionality works as expected. Edge cases can be better tested with unit tests.
Library/Homebrew/test/cmd/migrate_spec.rb
@@ -4,27 +4,6 @@ setup_test_formula "testball2" end - it "fails when no argument is given" do - expect { brew "migrate" } - .to output(/Invalid usage/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - end - - it "fails when a given Formula doesn't exist" do - expect { brew "migrate", "testball" } - .to output(/No available formula with the name "testball"/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - end - - it "fails if a given Formula doesn't replace another one" do - expect { brew "migrate", "testball1" } - .to output(/testball1 doesn't replace any formula/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - end - it "migrates a renamed Formula" do install_and_rename_coretap_formula "testball1", "testball2" @@ -33,14 +12,4 @@ .and not_to_output.to_stderr .and be_a_success end - - it "fails if a given Formula is not installed" do - install_and_rename_coretap_formula "testball1", "testball2" - (HOMEBREW_CELLAR/"testball1").rmtree - - expect { brew "migrate", "testball1" } - .to output(/Error: No such keg/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - end end
true
Other
Homebrew
brew
f6bf9893780e17c0ae853a45944229286fbd5f88.json
Remove some integration tests We have an awful lot of integration tests and they are (comparatively) really slow. Let's kill those that test edge case conditions and focus on those that test that our functionality works as expected. Edge cases can be better tested with unit tests.
Library/Homebrew/test/cmd/switch_spec.rb
@@ -1,15 +1,5 @@ describe "brew switch", :integration_test do it "allows switching between Formula versions" do - expect { brew "switch" } - .to output(/Usage: brew switch <formula> <version>/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - - expect { brew "switch", "testball", "0.1" } - .to output(/testball not found/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - setup_test_formula "testball", <<~EOS keg_only "just because" EOS @@ -23,10 +13,5 @@ .to output(/link created/).to_stdout .and not_to_output.to_stderr .and be_a_success - - expect { brew "switch", "testball", "0.3" } - .to output("testball installed versions: 0.1, 0.2\n").to_stdout - .and output(/testball does not have a version "0.3"/).to_stderr - .and be_a_failure end end
true
Other
Homebrew
brew
f6bf9893780e17c0ae853a45944229286fbd5f88.json
Remove some integration tests We have an awful lot of integration tests and they are (comparatively) really slow. Let's kill those that test edge case conditions and focus on those that test that our functionality works as expected. Edge cases can be better tested with unit tests.
Library/Homebrew/test/deps_spec.rb
@@ -15,13 +15,6 @@ .and not_to_output.to_stderr end - it "outputs a dependency for a Formula that has one dependency" do - expect { brew "deps", "bar" } - .to be_a_success - .and output("foo\n").to_stdout - .and not_to_output.to_stderr - end - it "outputs all of a Formula's dependencies and their dependencies on separate lines" do expect { brew "deps", "baz" } .to be_a_success
true
Other
Homebrew
brew
f6bf9893780e17c0ae853a45944229286fbd5f88.json
Remove some integration tests We have an awful lot of integration tests and they are (comparatively) really slow. Let's kill those that test edge case conditions and focus on those that test that our functionality works as expected. Edge cases can be better tested with unit tests.
Library/Homebrew/test/dev-cmd/pull_spec.rb
@@ -1,11 +1,4 @@ describe "brew pull", :integration_test do - it "fails when no argument is given" do - expect { brew "pull" } - .to output(/This command requires at least one argument/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - end - it "fetches a patch from a GitHub commit or pull request and applies it", :needs_network, retry: 3 do CoreTap.instance.path.cd do system "git", "init" @@ -22,11 +15,6 @@ .and output(/Current branch is new\-branch/).to_stderr .and be_a_failure - expect { brew "pull", "--bump", "https://github.com/Homebrew/homebrew-core/pull/8" } - .to output(/Fetching patch/).to_stdout - .and output(/No changed formulae found to bump/).to_stderr - .and be_a_failure - expect { brew "pull", "--bump", "https://api.github.com/repos/Homebrew/homebrew-core/pulls/122" } .to output(/Fetching patch/).to_stdout .and output(/Can only bump one changed formula/).to_stderr @@ -37,20 +25,4 @@ .and output(/Patch failed to apply/).to_stderr .and be_a_failure end - - describe "--rebase" do - it "fails" do - expect { brew "pull", "--rebase" } - .to output(/You meant `git pull --rebase`./).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - end - end - - it "fails when given 0" do - expect { brew "pull", "0" } - .to output(/Not a GitHub pull request or commit/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - end end
true
Other
Homebrew
brew
f6bf9893780e17c0ae853a45944229286fbd5f88.json
Remove some integration tests We have an awful lot of integration tests and they are (comparatively) really slow. Let's kill those that test edge case conditions and focus on those that test that our functionality works as expected. Edge cases can be better tested with unit tests.
Library/Homebrew/test/dev-cmd/ruby_spec.rb
@@ -4,10 +4,5 @@ .to be_a_success .and not_to_output.to_stdout .and not_to_output.to_stderr - - expect { brew "ruby", "-e", "exit 1" } - .to be_a_failure - .and not_to_output.to_stdout - .and not_to_output.to_stderr end end
true
Other
Homebrew
brew
f6bf9893780e17c0ae853a45944229286fbd5f88.json
Remove some integration tests We have an awful lot of integration tests and they are (comparatively) really slow. Let's kill those that test edge case conditions and focus on those that test that our functionality works as expected. Edge cases can be better tested with unit tests.
Library/Homebrew/test/dev-cmd/tap_spec.rb
@@ -69,15 +69,5 @@ .to be_a_success .and not_to_output.to_stdout .and not_to_output.to_stderr - - expect { brew "tap", "--force-auto-update", "homebrew/bar" } - .to be_a_success - .and not_to_output.to_stdout - .and not_to_output.to_stderr - - expect { brew "untap", "homebrew/bar" } - .to output(/Untapped/).to_stdout - .and not_to_output.to_stderr - .and be_a_success end end
true
Other
Homebrew
brew
f6bf9893780e17c0ae853a45944229286fbd5f88.json
Remove some integration tests We have an awful lot of integration tests and they are (comparatively) really slow. Let's kill those that test edge case conditions and focus on those that test that our functionality works as expected. Edge cases can be better tested with unit tests.
Library/Homebrew/test/dev-cmd/test_spec.rb
@@ -1,27 +1,4 @@ describe "brew test", :integration_test do - it "fails when no argument is given" do - expect { brew "test" } - .to output(/This command requires a formula argument/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - end - - it "fails when a Formula is not installed" do - expect { brew "test", testball } - .to output(/Testing requires the latest version of testball/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - end - - it "fails when a Formula has no test" do - expect { brew "install", testball }.to be_a_success - - expect { brew "test", testball } - .to output(/testball defines no test/).to_stderr - .and not_to_output.to_stdout - .and be_a_failure - end - it "tests a given Formula" do setup_test_formula "testball", <<~EOS head "https://github.com/example/testball2.git"
true
Other
Homebrew
brew
434e8d8e2fc4dbd51e3193e8560ecad65f916e7e.json
test/cmd/install: Fix a test failure on Linux Fix the error: Error: Homebrew GCC requested, but formula gcc not found!
Library/Homebrew/test/cmd/install_spec.rb
@@ -207,7 +207,7 @@ def install it "succeeds when a non-fatal requirement isn't satisfied" do setup_test_formula "testball1", <<~EOS class NonFatalRequirement < Requirement - satisfy { false } + satisfy(build_env: false) { false } end depends_on NonFatalRequirement
false
Other
Homebrew
brew
b01446d059ef66480624585d1aa6e42990c6006b.json
audit: Add condition check on new_formula_audits
Library/Homebrew/dev-cmd/audit.rb
@@ -123,8 +123,7 @@ def audit options[:style_offenses] = style_results.file_offenses(f.path) fa = FormulaAuditor.new(f, options) fa.audit - - next if fa.problems.empty? + next if fa.problems.empty? && fa.new_formula_problems.empty? fa.problems formula_count += 1 problem_count += fa.problems.size @@ -155,7 +154,7 @@ def audit errors_summary = "#{Formatter.pluralize(problem_count, "problem")} in #{Formatter.pluralize(formula_count, "formula")}" return if problem_count.zero? - ofail errors_summary unless strict + ofail errors_summary unless created_pr_comment end def format_problem_lines(problems)
false
Other
Homebrew
brew
36e961ad985325f3087317f42b56266189936c75.json
Doco: add a Shell Completion doc This describes how to configure your shell to use Homebrew-managed completion definitions. Needed because this is a manual step the user has to do.
docs/README.md
@@ -6,6 +6,7 @@ - [Installation](Installation.md) - [Frequently Asked Questions](FAQ.md) - [Common Issues](Common-Issues.md) +- [`brew` Shell Completion](Shell-Completion.md) - [Tips and Tricks](Tips-N'-Tricks.md) - [Bottles (binary packages)](Bottles.md)
true
Other
Homebrew
brew
36e961ad985325f3087317f42b56266189936c75.json
Doco: add a Shell Completion doc This describes how to configure your shell to use Homebrew-managed completion definitions. Needed because this is a manual step the user has to do.
docs/Shell-Completion.md
@@ -0,0 +1,44 @@ +# Homebrew Shell Completion + +Homebrew comes with completion definitions for the `brew` command. Some packages also provide completion definitions for their own programs. + +`zsh`, `bash` and `fish` are currently supported. (Homebrew provides `brew` completions for `zsh` and `bash`; `fish` provides its own `brew` completions.) + +You must configure your shell to enable the completion support. This is because the Homebrew-managed completions are stored under `HOMEBREW_PREFIX`, which your system shell may not be aware of, and because it is difficult to automatically configure `bash` and `zsh` completions in a robust manner, so the Homebrew installer cannot do it for you. + +## Configuring Completions in `bash` +To make Homebrew's completions available in `bash`, you must source the definitions as part of your shell startup. Add the following to your `~/.bashrc` file: + +```sh +if type brew 2&>/dev/null; then + for completion_file in $(brew --prefix)/etc/bash_completion.d/*; do + source "$completion_file" + done +fi +``` + +## Configuring Completions in `zsh` +To make Homebrew's completions available in `zsh`, you must get the Homebrew-managed zsh site-functions on your `$FPATH` before initializing `zsh`'s completion facility. Add the following to your `~/.zshrc` file: + +```sh +if type brew &>/dev/null; then + FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH +fi +``` + +This must be done before `compinit` is called. (Note: if you are using Oh My Zsh, it will call `compinit` for you, so this must be done before you call `oh-my-zsh.sh`.) + +You may also need to forcibly rebuild `zcompdump`: + +```sh + rm -f ~/.zcompdump; compinit +``` + +Additionally, if you receive "zsh compinit: insecure directories" warnings when attempting to load these completions, you may need to run this: + +```sh + chmod go-w "$(brew --prefix)/share" +``` + +## Configuring Completions in `fish` +No configuration is needed in `fish`. Friendly!
true
Other
Homebrew
brew
b109e6da5d24baad2fbb76b9b502e817c1f2b902.json
Handle Tap migration in `Tap#initialize`.
Library/Homebrew/compat/tap.rb
@@ -1,18 +1,38 @@ -module CaskTapMigrationExtension - def parse_user_repo(*args) - user, repo = super +module CaskTapMigration + def initialize(user, repo) + super - if user == "caskroom" - user = "Homebrew" - repo = "cask-#{repo}" unless repo == "cask" - end + return unless user == "caskroom" - [user, repo] + # TODO: Remove this check after migration. + return unless repo == "tap-migration-test" + + new_user = "Homebrew" + new_repo = (repo == "cask") ? repo : "cask-#{repo}" + + old_name = name + old_path = path + old_remote = path.git_origin + + super(new_user, new_repo) + + return unless old_path.git? + + new_name = name + new_path = path + new_remote = default_remote + + ohai "Migrating Tap #{old_name} to #{new_name} …" + + puts "Moving #{old_path} to #{new_path} …" + path.dirname.mkpath + FileUtils.mv old_path, new_path + + puts "Changing remote from #{old_remote} to #{new_remote} …" + new_path.git_origin = new_remote end end class Tap - class << self - prepend CaskTapMigrationExtension - end + prepend CaskTapMigration end
true
Other
Homebrew
brew
b109e6da5d24baad2fbb76b9b502e817c1f2b902.json
Handle Tap migration in `Tap#initialize`.
Library/Homebrew/extend/git_repository.rb
@@ -13,6 +13,13 @@ def git_origin end end + def git_origin=(origin) + return unless git? && Utils.git_available? + cd do + Utils.popen_read("git", "remote", "set-url", "origin", origin).chuzzle + end + end + def git_head return unless git? && Utils.git_available? cd do
true
Other
Homebrew
brew
b109e6da5d24baad2fbb76b9b502e817c1f2b902.json
Handle Tap migration in `Tap#initialize`.
Library/Homebrew/tap.rb
@@ -12,7 +12,7 @@ class Tap TAP_DIRECTORY = HOMEBREW_LIBRARY/"Taps" - def self.parse_user_repo(*args) + def self.fetch(*args) case args.length when 1 user, repo = args.first.split("/", 2) @@ -29,13 +29,6 @@ def self.parse_user_repo(*args) user = user.capitalize if ["homebrew", "linuxbrew"].include? user repo = repo.strip_prefix "homebrew-" - [user, repo] - end - private_class_method :parse_user_repo - - def self.fetch(*args) - user, repo = parse_user_repo(*args) - if ["Homebrew", "Linuxbrew"].include?(user) && ["core", "homebrew"].include?(repo) return CoreTap.instance end
true
Other
Homebrew
brew
76bfd0cecbe8ca74af5b8ea35a4a7251dd1fc729.json
Add superenv for Linux
Library/Homebrew/build.rb
@@ -68,6 +68,7 @@ def expand_deps def install formula_deps = deps.map(&:to_formula) keg_only_deps = formula_deps.select(&:keg_only?) + run_time_deps = deps.reject(&:build?).map(&:to_formula) formula_deps.each do |dep| fixopt(dep) unless dep.opt_prefix.directory? @@ -78,6 +79,7 @@ def install if superenv? ENV.keg_only_deps = keg_only_deps ENV.deps = formula_deps + ENV.run_time_deps = run_time_deps ENV.x11 = reqs.any? { |rq| rq.is_a?(X11Requirement) } ENV.setup_build_environment(formula) post_superenv_hacks
true
Other
Homebrew
brew
76bfd0cecbe8ca74af5b8ea35a4a7251dd1fc729.json
Add superenv for Linux
Library/Homebrew/extend/ENV/super.rb
@@ -15,12 +15,13 @@ module Superenv include SharedEnvExtension # @private - attr_accessor :keg_only_deps, :deps + attr_accessor :keg_only_deps, :deps, :run_time_deps attr_accessor :x11 def self.extended(base) base.keg_only_deps = [] base.deps = [] + base.run_time_deps = [] end # @private @@ -61,6 +62,8 @@ def setup_build_environment(formula = nil) self["HOMEBREW_ISYSTEM_PATHS"] = determine_isystem_paths self["HOMEBREW_INCLUDE_PATHS"] = determine_include_paths self["HOMEBREW_LIBRARY_PATHS"] = determine_library_paths + self["HOMEBREW_RPATH_PATHS"] = determine_rpath_paths(formula) + self["HOMEBREW_DYNAMIC_LINKER"] = determine_dynamic_linker_path self["HOMEBREW_DEPENDENCIES"] = determine_dependencies self["HOMEBREW_FORMULA_PREFIX"] = formula.prefix unless formula.nil? @@ -178,20 +181,22 @@ def determine_library_paths keg_only_deps.map(&:opt_lib), HOMEBREW_PREFIX/"lib", ] - - if compiler == :llvm_clang - if MacOS::CLT.installed? - paths << "/usr/lib" - else - paths << "#{MacOS.sdk_path}/usr/lib" - end - paths << Formula["llvm"].opt_lib.to_s - end - paths += homebrew_extra_library_paths PATH.new(paths).existing end + def determine_extra_rpath_paths(_formula) + [] + end + + def determine_rpath_paths(formula) + PATH.new(determine_extra_rpath_paths(formula)) + end + + def determine_dynamic_linker_path + nil + end + def determine_dependencies deps.map(&:name).join(",") end
true