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
e5c42895a86bb32b68a46ef00ee486d1608e00f5.json
Add doctor check for unbrewed header files
Library/Homebrew/cmd/doctor.rb
@@ -178,6 +178,18 @@ def check_for_stray_las EOS end +def check_for_stray_headers + white_list = {} # TODO whitelist MacFuse/OSXFuse headers + + __check_stray_files "/usr/local/include/**/*.h", white_list, <<-EOS.undent + Unbrewed header files were found in /usr/local/include. + If you didn't put them there on purpose they could cause problems when + building Homebrew formulae, and may need to be deleted. + + Unexpected header files: + EOS +end + def check_for_other_package_managers ponk = MacOS.macports_or_fink unless ponk.empty?
false
Other
Homebrew
brew
a6a4cd4c917259910a79f712a142fd75b5764379.json
Remove incorrect comment from example formula You can use any number of "/" operators, just as you can "+".
Library/Contributions/example-formula.rb
@@ -345,9 +345,6 @@ def install # Further possibilities with the pathnames: # http://www.ruby-doc.org/stdlib-1.8.7/libdoc/pathname/rdoc/Pathname.html - # Sometime you will see that instead of `+` we build up a path with `/` - # because it looks nicer (but you can't nest more than two `/`): - (var/"foo").mkpath # Copy `./example_code/simple/ones` to share/demos (share/"demos").install "example_code/simple/ones" # Copy `./example_code/simple/ones` to share/demos/examples
false
Other
Homebrew
brew
fef8b0871de845dd7e9f5f6a40dbcda7620a4960.json
Remove obsolete nil guard This was added in 3a7a3619f7016c75c3e53e944221bf7f6354a63b to make the tests pass, but this method is now stubbed out in the tests, so we can assume $? will be non-nil.
Library/Homebrew/cmd/update.rb
@@ -220,8 +220,8 @@ def diff def `(cmd) out = super - if $? && !$?.success? - $stderr.puts out + unless $?.success? + $stderr.puts(out) unless out.empty? raise ErrorDuringExecution.new(cmd) end ohai(cmd, out) if ARGV.verbose?
false
Other
Homebrew
brew
1abcb0b348c0d0b07ee92ed274c5d97550b39ee4.json
Remove workaround for old debugger
Library/Homebrew/formula.rb
@@ -548,7 +548,7 @@ def system cmd, *args raise BuildError.new(self, cmd, args, ENV.to_hash) end ensure - log.close unless log.closed? + log.close end end
false
Other
Homebrew
brew
0031e1947df198f16b86d9c1bf2b39ad15b1178e.json
brew-test-bot: build changed dependencies first. And don't uninstall them in-between. This should fix the issues where if e.g. OpenSSL changes in a pull request then it's only the dependents after it alphabetically would be built against the new version.
Library/Contributions/cmd/brew-test-bot.rb
@@ -136,7 +136,7 @@ def run end class Test - attr_reader :log_root, :category, :name, :formulae, :steps + attr_reader :log_root, :category, :name, :steps def initialize argument, tap=nil @hash = nil @@ -341,7 +341,6 @@ def formula formula reqs |= formula_object.devel.requirements.to_a end - begin deps.each {|f| CompilerSelector.new(f.to_formula).compiler } CompilerSelector.new(formula_object).compiler @@ -362,7 +361,7 @@ def formula formula end test "brew", "fetch", "--retry", *unchanged_dependencies unless unchanged_dependencies.empty? - test "brew", "fetch", "--retry", "--build-from-source", *changed_dependences unless changed_dependences.empty? + test "brew", "fetch", "--retry", "--build-bottle", *changed_dependences unless changed_dependences.empty? formula_fetch_options = [] formula_fetch_options << "--build-bottle" unless ARGV.include? "--no-bottle" formula_fetch_options << "--force" if ARGV.include? "--cleanup" @@ -406,7 +405,7 @@ def formula formula test "brew", "uninstall", "--devel", "--force", formula end end - test "brew", "uninstall", "--force", *dependencies unless dependencies.empty? + test "brew", "uninstall", "--force", *unchanged_dependencies unless unchanged_dependencies.empty? end def homebrew @@ -473,6 +472,29 @@ def check_results status == :passed end + def formulae + changed_formulae_dependents = {} + dependencies = [] + non_dependencies = [] + + @formulae.each do |formula| + formula_dependencies = `brew deps #{formula}`.split("\n") + unchanged_dependencies = formula_dependencies - @formulae + changed_dependences = formula_dependencies - unchanged_dependencies + changed_dependences.each do |changed_formula| + changed_formulae_dependents[changed_formula] ||= 0 + changed_formulae_dependents[changed_formula] += 1 + end + end + + changed_formulae = changed_formulae_dependents.sort do |a1,a2| + a2[1].to_i <=> a1[1].to_i + end + changed_formulae.map!(&:first) + unchanged_formulae = @formulae - changed_formulae + changed_formulae + unchanged_formulae + end + def run cleanup_before download
false
Other
Homebrew
brew
e717508b7b63b5bb0f84b2c62d3c621857baa67c.json
audit: access the homepage attribute once
Library/Homebrew/cmd/audit.rb
@@ -181,19 +181,21 @@ def audit_conflicts end def audit_urls - unless f.homepage =~ %r[^https?://] - problem "The homepage should start with http or https (url is #{f.homepage})." + homepage = f.homepage + + unless homepage =~ %r[^https?://] + problem "The homepage should start with http or https (URL is #{homepage})." end # Check for http:// GitHub homepage urls, https:// is preferred. # Note: only check homepages that are repo pages, not *.github.com hosts - if f.homepage =~ %r[^http://github\.com/] - problem "Use https:// URLs for homepages on GitHub (url is #{f.homepage})." + if homepage =~ %r[^http://github\.com/] + problem "Use https:// URLs for homepages on GitHub (URL is #{homepage})." end # Google Code homepages should end in a slash - if f.homepage =~ %r[^https?://code\.google\.com/p/[^/]+[^/]$] - problem "Google Code homepage should end with a slash (url is #{f.homepage})." + if homepage =~ %r[^https?://code\.google\.com/p/[^/]+[^/]$] + problem "Google Code homepage should end with a slash (URL is #{homepage})." end urls = @specs.map(&:url)
false
Other
Homebrew
brew
976bb9b05725da843e51512f5a2d2b51633fe34d.json
Print each line of --env output atomically
Library/Homebrew/cmd/--env.rb
@@ -36,12 +36,12 @@ def dump_build_env env keys.each do |key| value = env[key] - print "#{key}: #{value}" + s = "#{key}: #{value}" case key when "CC", "CXX", "LD" - print " => #{Pathname.new(value).realpath}" if File.symlink?(value) + s << " => #{Pathname.new(value).realpath}" if File.symlink?(value) end - puts + puts s end end end
false
Other
Homebrew
brew
529b060dbb445ccad7c0da4d66e7e2dc52b8382f.json
Remove unnecessary conditional If ARGV.named.empty?, then ARGV.formulae.map(&:name) == [].
Library/Homebrew/cmd/--env.rb
@@ -3,13 +3,10 @@ module Homebrew def __env ENV.activate_extensions! - - if superenv? - ENV.deps = ARGV.formulae.map(&:name) unless ARGV.named.empty? - end - + ENV.deps = ARGV.formulae.map(&:name) if superenv? ENV.setup_build_environment ENV.universal_binary if ARGV.build_universal? + if $stdout.tty? dump_build_env ENV else
false
Other
Homebrew
brew
081036c81c7f5a8ce96c912fdacf1e1331ddde96.json
Remove InstallationError superclass None of these subclasses share any behavior other than what is inherited from RuntimeError, so we can just get rid of the superclass.
Library/Homebrew/exceptions.rb
@@ -79,46 +79,33 @@ def initialize name end end -module Homebrew - class InstallationError < RuntimeError - attr_reader :formula - - def initialize(formula, message) - super message - @formula = formula - end - end -end - class CannotInstallFormulaError < RuntimeError; end class FormulaAlreadyInstalledError < RuntimeError; end -class FormulaInstallationAlreadyAttemptedError < Homebrew::InstallationError +class FormulaInstallationAlreadyAttemptedError < RuntimeError def initialize(formula) - super formula, "Formula installation already attempted: #{formula}" + super "Formula installation already attempted: #{formula}" end end -class UnsatisfiedRequirements < Homebrew::InstallationError - attr_reader :reqs - - def initialize formula, reqs - @reqs = reqs - message = (reqs.length == 1) \ - ? "An unsatisfied requirement failed this build." \ - : "Unsatisifed requirements failed this build." - super formula, message +class UnsatisfiedRequirements < RuntimeError + def initialize(reqs) + if reqs.length == 1 + super "An unsatisfied requirement failed this build." + else + super "Unsatisified requirements failed this build." + end end end -class FormulaConflictError < Homebrew::InstallationError - attr_reader :conflicts +class FormulaConflictError < RuntimeError + attr_reader :formula, :conflicts def initialize(formula, conflicts) - @conflicts = conflicts @formula = formula - super formula, message + @conflicts = conflicts + super message end def conflict_message(conflict) @@ -144,13 +131,14 @@ def message end end -class BuildError < Homebrew::InstallationError - attr_reader :env +class BuildError < RuntimeError + attr_reader :formula, :env def initialize(formula, cmd, args, env) + @formula = formula @env = env args = args.map{ |arg| arg.to_s.gsub " ", "\\ " }.join(" ") - super formula, "Failed executing: #{cmd} #{args}" + super "Failed executing: #{cmd} #{args}" end def issues @@ -202,13 +190,13 @@ def dump # raised by CompilerSelector if the formula fails with all of # the compilers available on the user's system -class CompilerSelectionError < Homebrew::InstallationError - def initialize formula - super formula, <<-EOS.undent - #{formula.name} cannot be built with any available compilers. - To install this formula, you may need to: - brew install gcc - EOS +class CompilerSelectionError < RuntimeError + def initialize(formula) + super <<-EOS.undent + #{formula.name} cannot be built with any available compilers. + To install this formula, you may need to: + brew install gcc + EOS end end
true
Other
Homebrew
brew
081036c81c7f5a8ce96c912fdacf1e1331ddde96.json
Remove InstallationError superclass None of these subclasses share any behavior other than what is inherited from RuntimeError, so we can just get rid of the superclass.
Library/Homebrew/formula_installer.rb
@@ -232,7 +232,7 @@ def check_requirements(req_map) end end - raise UnsatisfiedRequirements.new(f, fatals) unless fatals.empty? + raise UnsatisfiedRequirements.new(fatals) unless fatals.empty? end def install_requirement_default_formula?(req, build)
true
Other
Homebrew
brew
909c2bd59e5e8a99af320f828b2a67ab0ebfb5f7.json
Replace loop + delete with array difference
Library/Homebrew/cmd/--env.rb
@@ -35,10 +35,7 @@ def build_env_keys env def dump_build_env env keys = build_env_keys(env) - - if env["CC"] == env["HOMEBREW_CC"] - %w[CC CXX OBJC OBJCXX].each { |key| keys.delete(key) } - end + keys -= %w[CC CXX OBJC OBJCXX] if env["CC"] == env["HOMEBREW_CC"] keys.each do |key| value = env[key]
false
Other
Homebrew
brew
2332e6525d6460790e8d7be44291fd63a06c5eea.json
Remove unused attribute from BuildError
Library/Homebrew/exceptions.rb
@@ -145,13 +145,12 @@ def message end class BuildError < Homebrew::InstallationError - attr_reader :command, :env + attr_reader :env def initialize(formula, cmd, args, env) - @command = cmd @env = env args = args.map{ |arg| arg.to_s.gsub " ", "\\ " }.join(" ") - super formula, "Failed executing: #{command} #{args}" + super formula, "Failed executing: #{cmd} #{args}" end def issues
false
Other
Homebrew
brew
a607c71123ff42fe7060f8c49a12a247c13104a6.json
Pass the ENV hash into the BuildError constructor
Library/Homebrew/exceptions.rb
@@ -147,9 +147,9 @@ def message class BuildError < Homebrew::InstallationError attr_reader :command, :env - def initialize formula, cmd, args + def initialize(formula, cmd, args, env) @command = cmd - @env = ENV.to_hash + @env = env args = args.map{ |arg| arg.to_s.gsub " ", "\\ " }.join(" ") super formula, "Failed executing: #{command} #{args}" end
true
Other
Homebrew
brew
a607c71123ff42fe7060f8c49a12a247c13104a6.json
Pass the ENV hash into the BuildError constructor
Library/Homebrew/formula.rb
@@ -545,7 +545,7 @@ def system cmd, *args log.puts require 'cmd/config' Homebrew.dump_build_config(log) - raise BuildError.new(self, cmd, args) + raise BuildError.new(self, cmd, args, ENV.to_hash) end ensure log.close unless log.closed?
true
Other
Homebrew
brew
20516ee39be4b411f72a94e05353e5745079382f.json
Use the superclass properly
Library/Homebrew/exceptions.rb
@@ -95,8 +95,8 @@ class CannotInstallFormulaError < RuntimeError; end class FormulaAlreadyInstalledError < RuntimeError; end class FormulaInstallationAlreadyAttemptedError < Homebrew::InstallationError - def message - "Formula installation already attempted: #{formula}" + def initialize(formula) + super formula, "Formula installation already attempted: #{formula}" end end
false
Other
Homebrew
brew
759b6ce1a96e4623cf15ef76e8f98374bae5975b.json
Use safe_system when invoking install_name_tool
Library/Homebrew/keg_fix_install_names.rb
@@ -100,7 +100,7 @@ def each_unique_file_matching string end def install_name_tool(*args) - system(MacOS.locate("install_name_tool"), *args) + safe_system(MacOS.locate("install_name_tool"), *args) end # If file is a dylib or bundle itself, look for the dylib named by
false
Other
Homebrew
brew
28c1c4ee15acb6c3a7e7c8bad855e66d9d49b585.json
Use only strings in ENV.x11
Library/Homebrew/extend/ENV/std.rb
@@ -210,29 +210,29 @@ def libxml2 def x11 # There are some config scripts here that should go in the PATH - append_path 'PATH', MacOS::X11.bin + append_path "PATH", MacOS::X11.bin.to_s # Append these to PKG_CONFIG_LIBDIR so they are searched # *after* our own pkgconfig directories, as we dupe some of the # libs in XQuartz. - append_path 'PKG_CONFIG_LIBDIR', MacOS::X11.lib/'pkgconfig' - append_path 'PKG_CONFIG_LIBDIR', MacOS::X11.share/'pkgconfig' + append_path "PKG_CONFIG_LIBDIR", "#{MacOS::X11.lib}/pkgconfig" + append_path "PKG_CONFIG_LIBDIR", "#{MacOS::X11.share}/pkgconfig" - append 'LDFLAGS', "-L#{MacOS::X11.lib}" - append_path 'CMAKE_PREFIX_PATH', MacOS::X11.prefix - append_path 'CMAKE_INCLUDE_PATH', MacOS::X11.include - append_path 'CMAKE_INCLUDE_PATH', MacOS::X11.include/'freetype2' + append "LDFLAGS", "-L#{MacOS::X11.lib}" + append_path "CMAKE_PREFIX_PATH", MacOS::X11.prefix.to_s + append_path "CMAKE_INCLUDE_PATH", MacOS::X11.include.to_s + append_path "CMAKE_INCLUDE_PATH", "#{MacOS::X11.include}/freetype2" - append 'CPPFLAGS', "-I#{MacOS::X11.include}" - append 'CPPFLAGS', "-I#{MacOS::X11.include}/freetype2" + append "CPPFLAGS", "-I#{MacOS::X11.include}" + append "CPPFLAGS", "-I#{MacOS::X11.include}/freetype2" - append_path 'ACLOCAL_PATH', MacOS::X11.share/'aclocal' + append_path "ACLOCAL_PATH", "#{MacOS::X11.share}/aclocal" if MacOS::XQuartz.provided_by_apple? and not MacOS::CLT.installed? - append_path 'CMAKE_PREFIX_PATH', MacOS.sdk_path/'usr/X11' + append_path "CMAKE_PREFIX_PATH", "#{MacOS.sdk_path}/usr/X11" end - append 'CFLAGS', "-I#{MacOS::X11.include}" unless MacOS::CLT.installed? + append "CFLAGS", "-I#{MacOS::X11.include}" unless MacOS::CLT.installed? end alias_method :libpng, :x11
false
Other
Homebrew
brew
c5885757e5586cb69c4d9a09d66772ea712c89bb.json
Store the object itself in the failed download set Patches don't respond to "name".
Library/Homebrew/cmd/fetch.rb
@@ -61,7 +61,7 @@ def fetch_patch p def retry_fetch? f @fetch_failed ||= Set.new - if ARGV.include?("--retry") && @fetch_failed.add?(f.name) + if ARGV.include?("--retry") && @fetch_failed.add?(f) ohai "Retrying download" f.clear_cache true
false
Other
Homebrew
brew
9531ecc72ae0cacf2da72a7f8998b9b4f40a56c5.json
Use bundler for test gem dependencies. Closes Homebrew/homebrew#31986. References Homebrew/homebrew#31981.
Library/Homebrew/cmd/tests.rb
@@ -2,7 +2,14 @@ module Homebrew def tests (HOMEBREW_LIBRARY/'Homebrew/test').cd do ENV['TESTOPTS'] = '-v' if ARGV.verbose? - system "rake", "deps", "test" + quiet_system("gem", "list", "--installed", "bundler") || \ + system("gem", "install", "--no-ri", "--no-rdoc", + "--user-install", "bundler") + require 'rubygems' + ENV["PATH"] = "#{Gem.user_dir}/bin:#{ENV["PATH"]}" + quiet_system("bundle", "check") || \ + system("bundle", "install", "--path", "vendor/bundle") + system "bundle", "exec", "rake", "test" exit $?.exitstatus end end
true
Other
Homebrew
brew
9531ecc72ae0cacf2da72a7f8998b9b4f40a56c5.json
Use bundler for test gem dependencies. Closes Homebrew/homebrew#31986. References Homebrew/homebrew#31981.
Library/Homebrew/test/.gitignore
@@ -1,2 +1,5 @@ +/.bundle/ +/bin/ /coverage /prof +/vendor/
true
Other
Homebrew
brew
9531ecc72ae0cacf2da72a7f8998b9b4f40a56c5.json
Use bundler for test gem dependencies. Closes Homebrew/homebrew#31986. References Homebrew/homebrew#31981.
Library/Homebrew/test/Gemfile
@@ -0,0 +1,5 @@ +source "https://rubygems.org" + +gem "mocha", "~> 1.1" +gem "minitest", "~> 5.3" +gem "rake", "~> 10.3"
true
Other
Homebrew
brew
9531ecc72ae0cacf2da72a7f8998b9b4f40a56c5.json
Use bundler for test gem dependencies. Closes Homebrew/homebrew#31986. References Homebrew/homebrew#31981.
Library/Homebrew/test/Gemfile.lock
@@ -0,0 +1,16 @@ +GEM + remote: https://rubygems.org/ + specs: + metaclass (0.0.4) + minitest (5.4.1) + mocha (1.1.0) + metaclass (~> 0.0.1) + rake (10.3.2) + +PLATFORMS + ruby + +DEPENDENCIES + minitest (~> 5.3) + mocha (~> 1.1) + rake (~> 10.3)
true
Other
Homebrew
brew
9531ecc72ae0cacf2da72a7f8998b9b4f40a56c5.json
Use bundler for test gem dependencies. Closes Homebrew/homebrew#31986. References Homebrew/homebrew#31981.
Library/Homebrew/test/Rakefile
@@ -3,22 +3,9 @@ require 'rake/testtask' TEST_DIRECTORY = File.dirname(File.expand_path(__FILE__)) TEST_FILES = Dir["#{TEST_DIRECTORY}/test_*.rb"] -GEM_DEPS = { - "mocha" => "~> 1.1", - "minitest" => "~> 5.3", - "rake" => "~> 10.3", -} task :default => :test -task :deps do - GEM_DEPS.each do |dep, version| - `gem list --installed #{dep} -v '#{version}'` - next if $?.success? - sh "gem", "install", "--no-ri", "--no-rdoc", "--user-install", dep, "-v", version - end -end - Rake::TestTask.new(:test) do |t| t.libs << TEST_DIRECTORY t.test_files = TEST_FILES
true
Other
Homebrew
brew
8205ebabcb3d090901e983b7946de1978df108f4.json
Prefer Xcode 6.1 on 10.10 More Yosemite changes. Within two weeks or so, Xcode should be made available on the App Store, at which point 10.9 will need to go from “5.1.1” to “6.0” but whilst Yosemite is in Beta *everyone* should be using the Xcode Beta builds according to Apple, so Yosemite should be on 6.1 for the foreseeable, even when Apple releases Xcode 6.0 to 10.9 & below. 6.1 is still using the same Clang version number at this point. Closes Homebrew/homebrew#32201. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Library/Homebrew/os/mac.rb
@@ -207,6 +207,7 @@ def preferred_arch "5.1" => { :clang => "5.1", :clang_build => 503 }, "5.1.1" => { :clang => "5.1", :clang_build => 503 }, "6.0" => { :clang => "6.0", :clang_build => 600 }, + "6.1" => { :clang => "6.0", :clang_build => 600 }, } def compilers_standard?
true
Other
Homebrew
brew
8205ebabcb3d090901e983b7946de1978df108f4.json
Prefer Xcode 6.1 on 10.10 More Yosemite changes. Within two weeks or so, Xcode should be made available on the App Store, at which point 10.9 will need to go from “5.1.1” to “6.0” but whilst Yosemite is in Beta *everyone* should be using the Xcode Beta builds according to Apple, so Yosemite should be on 6.1 for the foreseeable, even when Apple releases Xcode 6.0 to 10.9 & below. 6.1 is still using the same Clang version number at this point. Closes Homebrew/homebrew#32201. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Library/Homebrew/os/mac/xcode.rb
@@ -14,11 +14,11 @@ def latest_version when "10.7" then "4.6.3" when "10.8" then "5.1.1" when "10.9" then "5.1.1" - when "10.10" then "6.0" + when "10.10" then "6.1" else # Default to newest known version of Xcode for unreleased OSX versions. if MacOS.version > "10.10" - "6.0" + "6.1" else raise "Mac OS X '#{MacOS.version}' is invalid" end
true
Other
Homebrew
brew
4fd78c9690e6f5393956d9859747deacffa9297c.json
Provide more information about link errors References Homebrew/homebrew#32046.
Library/Homebrew/keg.rb
@@ -16,10 +16,13 @@ def initialize(keg) class LinkError < RuntimeError attr_reader :keg, :src, :dst - def initialize(keg, src, dst) + def initialize(keg, src, dst, cause) @src = src @dst = dst @keg = keg + @cause = cause + super(cause.message) + set_backtrace(cause.backtrace) end end @@ -361,17 +364,17 @@ def make_relative_symlink dst, src, mode dst.delete if mode.overwrite && (dst.exist? || dst.symlink?) dst.make_relative_symlink(src) - rescue Errno::EEXIST + rescue Errno::EEXIST => e if dst.exist? - raise ConflictError.new(self, src.relative_path_from(path), dst) + raise ConflictError.new(self, src.relative_path_from(path), dst, e) elsif dst.symlink? dst.unlink retry end - rescue Errno::EACCES - raise DirectoryNotWritableError.new(self, src.relative_path_from(path), dst) - rescue SystemCallError - raise LinkError.new(self, src.relative_path_from(path), dst) + rescue Errno::EACCES => e + raise DirectoryNotWritableError.new(self, src.relative_path_from(path), dst, e) + rescue SystemCallError => e + raise LinkError.new(self, src.relative_path_from(path), dst, e) end protected
false
Other
Homebrew
brew
9321873eef1c895b8d0fae23069dcfcf291f9a40.json
Use predicate method and eliminate local
Library/Contributions/cmd/brew-test-bot.rb
@@ -116,13 +116,12 @@ def run @time = Time.now - start_time - success = $?.success? - @status = success ? :passed : :failed + @status = $?.success? ? :passed : :failed puts_result if File.exist?(log) @output = File.read(log) - if has_output? and (not success or @puts_output_on_success) + if has_output? and (failed? or @puts_output_on_success) puts @output end FileUtils.rm(log) unless ARGV.include? "--keep-logs"
false
Other
Homebrew
brew
f6eedf946487980c740f5e0595fb46a5a2710597.json
Avoid early return
Library/Contributions/cmd/brew-test-bot.rb
@@ -120,12 +120,13 @@ def run @status = success ? :passed : :failed puts_result - return unless File.exist?(log) - @output = File.read(log) - if has_output? and (not success or @puts_output_on_success) - puts @output + if File.exist?(log) + @output = File.read(log) + if has_output? and (not success or @puts_output_on_success) + puts @output + end + FileUtils.rm(log) unless ARGV.include? "--keep-logs" end - FileUtils.rm(log) unless ARGV.include? "--keep-logs" end end
false
Other
Homebrew
brew
758608815f24a8823918c76e710a8f2fba890b0b.json
Move gnunet to the boneyard Closes Homebrew/homebrew#30418.
Library/Homebrew/tap_migrations.rb
@@ -20,6 +20,7 @@ "drizzle" => "homebrew/boneyard", "drush" => "homebrew/php", "dsniff" => "homebrew/boneyard", + "gnunet" => "homebrew/boneyard", "grads" => "homebrew/binary", "gromacs" => "homebrew/science", "hllib" => "homebrew/boneyard",
false
Other
Homebrew
brew
24a133f1199117f202639642577643cc9543d718.json
gist-logs: send an Accept header with the request
Library/Contributions/cmd/brew-gist-logs.rb
@@ -63,12 +63,17 @@ def http end def make_request(path, data) - request = Net::HTTP::Post.new(path) - request['User-Agent'] = HOMEBREW_USER_AGENT - request['Content-Type'] = 'application/json' + headers = { + "User-Agent" => HOMEBREW_USER_AGENT, + "Accept" => "application/vnd.github.v3+json", + "Content-Type" => "application/json", + } + if HOMEBREW_GITHUB_API_TOKEN - request['Authorization'] = "token #{HOMEBREW_GITHUB_API_TOKEN}" + headers["Authorization"] = "token #{HOMEBREW_GITHUB_API_TOKEN}" end + + request = Net::HTTP::Post.new(path, headers) request.body = Utils::JSON.dump(data) request end
false
Other
Homebrew
brew
1dd924b9bd843a20f232272a2958e2c61fbc1a3d.json
gist-logs: remove unnecessary exception class
Library/Contributions/cmd/brew-gist-logs.rb
@@ -79,7 +79,7 @@ def post path, data end request.body = Utils::JSON.dump(data) response = http.request(request) - raise HTTP_Error, response if response.code != '201' + raise "HTTP #{response.code} #{response.message}" if response.code != "201" if !response.body.respond_to?(:force_encoding) body = response.body @@ -92,12 +92,6 @@ def post path, data Utils::JSON.load(body) end -class HTTP_Error < RuntimeError - def initialize response - super "HTTP #{response.code} #{response.message}" - end -end - def usage puts "usage: brew gist-logs [options] <formula>" puts
false
Other
Homebrew
brew
c0c5298ae5cf12f4a058732072d55ba3a6a02d77.json
gist-logs: pull ternary out of hash literal
Library/Contributions/cmd/brew-gist-logs.rb
@@ -29,9 +29,10 @@ def gist_logs f def load_logs name logs = {} - dir = (HOMEBREW_LOGS/name) + dir = HOMEBREW_LOGS/name dir.children.sort.each do |file| - logs[file.basename.to_s] = {:content => (file.size == 0 ? "empty log" : file.read)} + contents = file.size? ? file.read : "empty log" + logs[file.basename.to_s] = { :content => contents } end if dir.exist? raise 'No logs.' if logs.empty? logs
false
Other
Homebrew
brew
944ac75b2460859151c103efc2b49b31e133e9ec.json
Use Formula#tap to get the repository name
Library/Contributions/cmd/brew-gist-logs.rb
@@ -11,7 +11,6 @@ def gist_logs f puts 'and then set HOMEBREW_GITHUB_API_TOKEN to use --new-issue option.' exit 1 end - repo = repo_name(f) end files = load_logs(f.name) @@ -22,7 +21,7 @@ def gist_logs f url = create_gist(files) if ARGV.include? '--new-issue' - url = new_issue(repo, "#{f.name} failed to build on #{MACOS_FULL_VERSION}", url) + url = new_issue(f.tap, "#{f.name} failed to build on #{MACOS_FULL_VERSION}", url) end ensure puts url if url @@ -98,15 +97,6 @@ def initialize response end end -def repo_name f - dir = f.path.dirname - url = dir.cd { `git config --get remote.origin.url` } - unless url =~ %r{github.com(?:/|:)([\w\d]+)/([\-\w\d]+)} - raise 'Unable to determine formula repository.' - end - "#{$1}/#{$2}" -end - def usage puts "usage: brew gist-logs [options] <formula>" puts
false
Other
Homebrew
brew
20923363c90d5c2e7263914adadeed3c2d729093.json
Avoid intermediate array
Library/Homebrew/language/go.rb
@@ -7,8 +7,7 @@ module Go # The resource names should be the import name of the package, # e.g. `resource "github.com/foo/bar"` def self.stage_deps resources, target - godeps = resources.grep(Resource::Go) - godeps.each {|resource| resource.stage target} + resources.grep(Resource::Go) { |resource| resource.stage(target) } end end end
false
Other
Homebrew
brew
d0ecd08c90be87780e8b911aa8659ae3dd10cf6c.json
Avoid intermediate array
Library/Homebrew/formula.rb
@@ -589,7 +589,7 @@ def patch active_spec.add_legacy_patches(patches) return if patchlist.empty? - active_spec.patches.grep(DATAPatch).each { |p| p.path = path } + active_spec.patches.grep(DATAPatch) { |p| p.path = path } active_spec.patches.select(&:external?).each do |patch| patch.verify_download_integrity(patch.fetch)
false
Other
Homebrew
brew
4652be33b9919254e69572302305ebe8a15975b4.json
brew-test-bot: install hg before fetching if necessary
Library/Contributions/cmd/brew-test-bot.rb
@@ -345,6 +345,10 @@ def formula formula return end + if deps.any? { |d| d.name == "mercurial" && d.build? } + test "brew", "install", "mercurial" + end + test "brew", "fetch", "--retry", *unchanged_dependencies unless unchanged_dependencies.empty? test "brew", "fetch", "--retry", "--build-from-source", *changed_dependences unless changed_dependences.empty? formula_fetch_options = []
false
Other
Homebrew
brew
a316a072517e4ea82d619c6b0f97104474d7f479.json
Fix comma splice in outdated brew message Closes Homebrew/homebrew#32123. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Library/Homebrew/cmd/doctor.rb
@@ -1040,7 +1040,7 @@ def check_for_outdated_homebrew if Time.now.to_i - timestamp > 60 * 60 * 24 then <<-EOS.undent Your Homebrew is outdated. - You haven't updated for at least 24 hours, this is a long time in brewland! + You haven't updated for at least 24 hours. This is a long time in brewland! To update Homebrew, run `brew update`. EOS end
false
Other
Homebrew
brew
effddda4f9efc336bef6e39eb93a6a9985b3ed44.json
Promote log stream to a local
Library/Homebrew/formula.rb
@@ -514,33 +514,32 @@ def system cmd, *args pid = fork { exec_cmd(cmd, args, rd, wr, logfn) } wr.close - File.open(logfn, 'w') do |f| - f.puts Time.now, "", cmd, args, "" - - if ARGV.verbose? - while buf = rd.gets - f.puts buf - puts buf - end - elsif IO.respond_to?(:copy_stream) - IO.copy_stream(rd, f) - else - buf = "" - f.write(buf) while rd.read(1024, buf) + log = File.open(logfn, "w") + log.puts Time.now, "", cmd, args, "" + + if ARGV.verbose? + while buf = rd.gets + log.puts buf + puts buf end + elsif IO.respond_to?(:copy_stream) + IO.copy_stream(rd, log) + else + buf = "" + log.write(buf) while rd.read(1024, buf) + end - Process.wait(pid) + Process.wait(pid) - $stdout.flush + $stdout.flush - unless $?.success? - f.flush - Kernel.system "/usr/bin/tail", "-n", "5", logfn unless ARGV.verbose? - f.puts - require 'cmd/config' - Homebrew.dump_build_config(f) - raise BuildError.new(self, cmd, args) - end + unless $?.success? + log.flush + Kernel.system "/usr/bin/tail", "-n", "5", logfn unless ARGV.verbose? + log.puts + require 'cmd/config' + Homebrew.dump_build_config(log) + raise BuildError.new(self, cmd, args) end ensure rd.close unless rd.closed?
false
Other
Homebrew
brew
479ad0265b4998531be1682d9ac96f8dec10a553.json
Reduce effective scope of pipe variables
Library/Homebrew/formula.rb
@@ -493,8 +493,6 @@ def test_defined? # Pretty titles the command and buffers stdout/stderr # Throws if there's an error def system cmd, *args - rd, wr = IO.pipe - # remove "boring" arguments so that the important ones are more likely to # be shown considering that we trim long ohai lines to the terminal width pretty_args = args.dup @@ -510,39 +508,43 @@ def system cmd, *args logfn = "#{logd}/%02d.%s" % [@exec_count, File.basename(cmd).split(' ').first] mkdir_p(logd) - pid = fork { exec_cmd(cmd, args, rd, wr, logfn) } - wr.close - - File.open(logfn, 'w') do |f| - f.puts Time.now, "", cmd, args, "" + rd, wr = IO.pipe - if ARGV.verbose? - while buf = rd.gets - f.puts buf - puts buf + begin + pid = fork { exec_cmd(cmd, args, rd, wr, logfn) } + wr.close + + File.open(logfn, 'w') do |f| + f.puts Time.now, "", cmd, args, "" + + if ARGV.verbose? + while buf = rd.gets + f.puts buf + puts buf + end + elsif IO.respond_to?(:copy_stream) + IO.copy_stream(rd, f) + else + buf = "" + f.write(buf) while rd.read(1024, buf) end - elsif IO.respond_to?(:copy_stream) - IO.copy_stream(rd, f) - else - buf = "" - f.write(buf) while rd.read(1024, buf) - end - Process.wait(pid) + Process.wait(pid) - $stdout.flush + $stdout.flush - unless $?.success? - f.flush - Kernel.system "/usr/bin/tail", "-n", "5", logfn unless ARGV.verbose? - f.puts - require 'cmd/config' - Homebrew.dump_build_config(f) - raise BuildError.new(self, cmd, args) + unless $?.success? + f.flush + Kernel.system "/usr/bin/tail", "-n", "5", logfn unless ARGV.verbose? + f.puts + require 'cmd/config' + Homebrew.dump_build_config(f) + raise BuildError.new(self, cmd, args) + end end + ensure + rd.close unless rd.closed? end - ensure - rd.close unless rd.closed? end private
false
Other
Homebrew
brew
03abf834724714b29e7d44720953affc01dd7415.json
Add timestamp and argument list to log files
Library/Homebrew/formula.rb
@@ -536,6 +536,8 @@ def system cmd, *args wr.close File.open(logfn, 'w') do |f| + f.puts Time.now, "", cmd, args, "" + while buf = rd.gets f.puts buf puts buf if ARGV.verbose?
false
Other
Homebrew
brew
fe1bf57a1547bec01c80f42c75ee2e3d9afa0bb1.json
audit: fix line number off-by-one
Library/Homebrew/cmd/audit.rb
@@ -567,7 +567,7 @@ def audit audit_conflicts audit_patches audit_text - text.split("\n").each_with_index { |line, lineno| audit_line(line, lineno) } + text.split("\n").each_with_index { |line, lineno| audit_line(line+1, lineno) } audit_installed end
false
Other
Homebrew
brew
329e357d9acdd7989cb3ba6394f3b4839bb1e83f.json
plist_caveats: simplify the block and add a comment Closes Homebrew/homebrew#30630. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Library/Homebrew/caveats.rb
@@ -104,22 +104,20 @@ def plist_caveats else s << " launchctl load #{plist_link}" end - else - if f.plist_startup + # For startup plists, we cannot tell whether it's running on launchd, + # as it requires for `sudo launchctl list` to get real result. + elsif f.plist_startup s << "To reload #{f.name} after an upgrade:" s << " sudo launchctl unload #{plist_link}" s << " sudo cp -fv #{f.opt_prefix}/*.plist #{destination}" s << " sudo launchctl load #{plist_link}" - else - if Kernel.system "/bin/launchctl list #{plist_domain} &>/dev/null" - s << "To reload #{f.name} after an upgrade:" - s << " launchctl unload #{plist_link}" - s << " launchctl load #{plist_link}" - else - s << "To load #{f.name}:" - s << " launchctl load #{plist_link}" - end - end + elsif Kernel.system "/bin/launchctl list #{plist_domain} &>/dev/null" + s << "To reload #{f.name} after an upgrade:" + s << " launchctl unload #{plist_link}" + s << " launchctl load #{plist_link}" + else + s << "To load #{f.name}:" + s << " launchctl load #{plist_link}" end if f.plist_manual
false
Other
Homebrew
brew
372945299dc52b04338ad58ac666f105e2f463f2.json
Use the accessors to update the test double
Library/Homebrew/test/test_compiler_selector.rb
@@ -88,7 +88,7 @@ def test_mixed_failures_4 end def test_older_clang_precedence - @versions = CompilerVersions.new(:clang_build_version => 211) + @versions.clang_build_version = 211 @f << :gcc << { :gcc => "4.8" } assert_equal :llvm, actual_cc end @@ -99,16 +99,13 @@ def test_llvm_precedence end def test_missing_gcc - @versions = CompilerVersions.new(:gcc_build_version => nil) + @versions.gcc_build_version = nil @f << :clang << :llvm << { :gcc => "4.8" } assert_raises(CompilerSelectionError) { actual_cc } end def test_missing_llvm_and_gcc - @versions = CompilerVersions.new( - :gcc_build_version => nil, - :llvm_build_version => nil - ) + @versions.gcc_build_version = @versions.llvm_build_version = nil @f << :clang << { :gcc => "4.8" } assert_raises(CompilerSelectionError) { actual_cc } end
false
Other
Homebrew
brew
eec50f0a9a80098665b80c28f2684111480ea5be.json
Remove unnecessary empty block
Library/Homebrew/test/test_fails_with.rb
@@ -35,7 +35,7 @@ def test_fails_with_build end def test_fails_with_block_without_build - fails_with(:clang) { } + fails_with(:clang) cc = build_cc(:clang, 425) assert_fails_with cc end
false
Other
Homebrew
brew
b4a634903e83f80279d27f550069ad5e7b3e77b1.json
Remove obsolete nil check
Library/Homebrew/test/test_compiler_selector.rb
@@ -15,7 +15,6 @@ def <<(cc) end def fails_with?(cc) - return false if cc.nil? @failures.include?(cc.name) end end
false
Other
Homebrew
brew
7bfb12aa4565cb0c4a7edbdda1cbd267f10d2a20.json
Install dependencies before an interactive install Closes Homebrew/homebrew#29121.
Library/Homebrew/cmd/install.rb
@@ -104,7 +104,7 @@ def perform_preinstall_checks def install_formula f fi = FormulaInstaller.new(f) fi.options = f.build.used_options - fi.ignore_deps = ARGV.ignore_deps? || ARGV.interactive? + fi.ignore_deps = ARGV.ignore_deps? fi.only_deps = ARGV.only_deps? fi.build_bottle = ARGV.build_bottle? fi.build_from_source = ARGV.build_from_source?
false
Other
Homebrew
brew
73956a1b77af135600888750148cc303b2d999f1.json
Use different variable name
Library/Contributions/cmd/brew-test-bot.rb
@@ -326,11 +326,11 @@ def formula formula installed_gcc = false begin - dependencies = formula_object.stable.deps + deps = formula_object.stable.deps if formula_object.devel && !ARGV.include?('--HEAD') - dependencies += formula_object.devel.deps + deps += formula_object.devel.deps end - dependencies.each {|f| CompilerSelector.new(f.to_formula).compiler } + deps.each {|f| CompilerSelector.new(f.to_formula).compiler } CompilerSelector.new(formula_object).compiler rescue CompilerSelectionError => e
false
Other
Homebrew
brew
309001fd9f510879693828c340654f44ccc82406.json
Fix tests on 1.8
Library/Homebrew/test/test_dependency_collector.rb
@@ -33,7 +33,7 @@ def test_add_returns_created_dep def test_dependency_tags assert_predicate Dependency.new('foo', [:build]), :build? assert_predicate Dependency.new('foo', [:build, :optional]), :optional? - assert_includes Dependency.new('foo', [:universal]).options, "--universal" + assert_includes Dependency.new('foo', ["universal"]).options, "--universal" assert_empty Dependency.new('foo').tags end
false
Other
Homebrew
brew
d18c016a274ca6239fe0e3b736af3d6dc291ff3e.json
Use cp because install warns on empty arrays
Library/Homebrew/formula.rb
@@ -261,7 +261,7 @@ def brew # so load any deps before this point! And exit asap afterwards yield self ensure - (HOMEBREW_LOGS+name).install Dir["config.log", "CMakeCache.txt"] + cp Dir["config.log", "CMakeCache.txt"], HOMEBREW_LOGS+name end end end
false
Other
Homebrew
brew
977ae5f27d6d754a2417821ad53248f06add770b.json
Collapse iteration to a map
Library/Homebrew/options.rb
@@ -36,16 +36,7 @@ class Options include Enumerable def self.create(array) - options = new - array.each do |e| - case e - when /^--(.+)$/ - options << Option.new($1) - else - options << Option.new(e) - end - end - options + new array.map { |e| Option.new(e[/^--(.+)$/, 1] || e) } end def initialize(*args)
false
Other
Homebrew
brew
b14851903c258b62968581f26ab9537f89b37456.json
Add a method for retrieving only flags from ARGV
Library/Homebrew/build.rb
@@ -186,7 +186,7 @@ def fixopt f trap("INT", old_trap) formula = ARGV.formulae.first - options = Options.create(ARGV.options_only) + options = Options.create(ARGV.flags_only) build = Build.new(formula, options) build.install rescue Exception => e
true
Other
Homebrew
brew
b14851903c258b62968581f26ab9537f89b37456.json
Add a method for retrieving only flags from ARGV
Library/Homebrew/extend/ARGV.rb
@@ -7,6 +7,10 @@ def options_only select { |arg| arg.start_with?("-") } end + def flags_only + select { |arg| arg.start_with?("--") } + end + def formulae require "formula" @formulae ||= downcased_unique_named.map { |name| Formulary.factory(name, spec) }
true
Other
Homebrew
brew
b14851903c258b62968581f26ab9537f89b37456.json
Add a method for retrieving only flags from ARGV
Library/Homebrew/software_spec.rb
@@ -36,7 +36,7 @@ def initialize @bottle_specification = BottleSpecification.new @patches = [] @options = Options.new - @build = BuildOptions.new(Options.create(ARGV.options_only), options) + @build = BuildOptions.new(Options.create(ARGV.flags_only), options) @compiler_failures = [] end
true
Other
Homebrew
brew
b14851903c258b62968581f26ab9537f89b37456.json
Add a method for retrieving only flags from ARGV
Library/Homebrew/test/test_ARGV.rb
@@ -30,6 +30,11 @@ def test_options_only assert_equal %w[--foo -vds], @argv.options_only end + def test_flags_only + @argv << "--foo" << "-vds" << "a" << "b" << "cdefg" + assert_equal %w[--foo], @argv.flags_only + end + def test_empty_argv assert_empty @argv.named assert_empty @argv.kegs
true
Other
Homebrew
brew
6885f588d024839f1f49df0859a682e0e9963e04.json
Move handling of leading dashes to Options.create
Library/Homebrew/options.rb
@@ -38,8 +38,6 @@ def split_name(name) [name, "-#{name}"] when /^-[a-zA-Z]$/ [name[1..1], name] - when /^--(.+)$/ - [$1, name] else [name, "--#{name}"] end @@ -55,6 +53,8 @@ def self.create(array) case e when /^-[^-]+$/ e[1..-1].split(//).each { |o| options << Option.new(o) } + when /^--(.+)$/ + options << Option.new($1) else options << Option.new(e) end
true
Other
Homebrew
brew
6885f588d024839f1f49df0859a682e0e9963e04.json
Move handling of leading dashes to Options.create
Library/Homebrew/test/test_options.rb
@@ -19,12 +19,6 @@ def test_equality refute_eql @option, bar end - def test_strips_leading_dashes - option = Option.new("--foo") - assert_equal "foo", option.name - assert_equal "--foo", option.flag - end - def test_description assert_empty @option.description assert_equal "foo", Option.new("foo", "foo").description
true
Other
Homebrew
brew
e18da89f3c4331d65ef32f75c3271242b41246dc.json
Implement ARGV.named in terms of ARGV.options_only
Library/Homebrew/extend/ARGV.rb
@@ -1,10 +1,10 @@ module HomebrewArgvExtension def named - @named ||= reject{|arg| arg[0..0] == '-'} + @named ||= self - options_only end def options_only - select {|arg| arg[0..0] == '-'} + select { |arg| arg.start_with?("-") } end def formulae
true
Other
Homebrew
brew
e18da89f3c4331d65ef32f75c3271242b41246dc.json
Implement ARGV.named in terms of ARGV.options_only
Library/Homebrew/test/test_ARGV.rb
@@ -21,8 +21,13 @@ def test_argv_kegs end def test_argv_named - @argv << 'mxcl' << '--debug' << '-v' - assert_equal 1, @argv.named.length + @argv << "foo" << "--debug" << "-v" + assert_equal %w[foo], @argv.named + end + + def test_options_only + @argv << "--foo" << "-vds" << "a" << "b" << "cdefg" + assert_equal %w[--foo -vds], @argv.options_only end def test_empty_argv
true
Other
Homebrew
brew
6b9a929e40933db5e21ba91913445212f1d2b1c1.json
Rewrite missing_options in a more obvious way
Library/Homebrew/dependency.rb
@@ -43,9 +43,8 @@ def satisfied?(inherited_options) end def missing_options(inherited_options) - missing = options | inherited_options - missing -= Tab.for_formula(to_formula).used_options - missing + required = options | inherited_options + required - Tab.for_formula(to_formula).used_options end def modify_build_environment
false
Other
Homebrew
brew
5664e04b08e3e7733c5be41c00643a9edc9cea67.json
Move OpenFST and OpenGRM-ngram to homebrew-science Closes Homebrew/homebrew#31905. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Library/Homebrew/tap_migrations.rb
@@ -45,6 +45,8 @@ "nlopt" => "homebrew/science", "octave" => "homebrew/science", "opencv" => "homebrew/science", + "openfst" => "homebrew/science", + "opengrm-ngram" => "homebrew/science", "pan" => "homebrew/boneyard", "pjsip" => "homebrew/boneyard", "pocl" => "homebrew/science",
false
Other
Homebrew
brew
f7f8ca45fca35e04b962e847cc51e8ce4385ceae.json
Remove to_str from Option We no longer need implicit conversion of options to strings.
Library/Homebrew/options.rb
@@ -11,7 +11,6 @@ def initialize(name, description="") def to_s flag end - alias_method :to_str, :to_s def <=>(other) return unless Option === other
true
Other
Homebrew
brew
f7f8ca45fca35e04b962e847cc51e8ce4385ceae.json
Remove to_str from Option We no longer need implicit conversion of options to strings.
Library/Homebrew/test/test_options.rb
@@ -10,10 +10,6 @@ def test_to_s assert_equal "--foo", @option.to_s end - def test_to_str - assert_equal "--foo", @option.to_str - end - def test_equality foo = Option.new("foo") bar = Option.new("bar")
true
Other
Homebrew
brew
11f880801c1ccf11a9fc2a1d0dc469dbba8b2a15.json
Avoid intermediate option objects
Library/Homebrew/formula_installer.rb
@@ -462,7 +462,7 @@ def sanitized_ARGV_options end def build_argv - Options.create(sanitized_ARGV_options) + options + sanitized_ARGV_options + options.as_flags end def build
false
Other
Homebrew
brew
58cb4444da8f20e4e51800af253dedeadefc0edf.json
etc.install: handle recursive directory installs. We need to install the helper module not just on `etc` but also on all subdirectories of it too. Also, handle the case where we install a subdirectory with etc.install. Closes Homebrew/homebrew#26145.
Library/Homebrew/extend/pathname.rb
@@ -48,6 +48,7 @@ def install_p src, new_basename = nil dst = dst.to_s dst = yield(src, dst) if block_given? + return unless dst mkpath
true
Other
Homebrew
brew
58cb4444da8f20e4e51800af253dedeadefc0edf.json
etc.install: handle recursive directory installs. We need to install the helper module not just on `etc` but also on all subdirectories of it too. Also, handle the case where we install a subdirectory with etc.install. Closes Homebrew/homebrew#26145.
Library/Homebrew/install_renamed.rb
@@ -2,6 +2,12 @@ module InstallRenamed def install_p src, new_basename = nil super do |src, dst| dst += "/#{File.basename(src)}" if File.directory? dst + + if File.directory? src + Pathname.new(dst).install Dir["#{src}/*"] + next + end + append_default_if_different(src, dst) end end @@ -12,6 +18,14 @@ def cp_path_sub pattern, replacement end end + def + path + super(path).extend(InstallRenamed) + end + + def / path + super(path).extend(InstallRenamed) + end + private def append_default_if_different src, dst
true
Other
Homebrew
brew
b0c1e5f7d6456ea3b350d13383f9fbc72f410c20.json
Fix redefinition of x11 reader method in superenv
Library/Homebrew/extend/ENV/super.rb
@@ -311,7 +311,7 @@ def noop(*args); end # These methods are no longer necessary under superenv, but are needed to # maintain an interface compatible with stdenv. - noops.concat %w{fast O4 Og libxml2 x11 set_cpu_flags macosxsdk remove_macosxsdk} + noops.concat %w{fast O4 Og libxml2 set_cpu_flags macosxsdk remove_macosxsdk} # These methods provide functionality that has not yet been ported to # superenv.
false
Other
Homebrew
brew
566442606a817ceaa3d3e305b53f5f2634e3e793.json
Remove an unnecessary default argument
Library/Homebrew/dependency.rb
@@ -42,7 +42,7 @@ def satisfied?(inherited_options) installed? && missing_options(inherited_options).empty? end - def missing_options(inherited_options=[]) + def missing_options(inherited_options) missing = options | inherited_options missing -= Tab.for_formula(to_formula).used_options missing
false
Other
Homebrew
brew
05bb612ce71c9d16346a7ac95a578c33ed055cb8.json
Use opt_prefix instead of constructing it manually
Library/Homebrew/build.rb
@@ -108,8 +108,7 @@ def install keg_only_deps = deps.map(&:to_formula).select(&:keg_only?) deps.map(&:to_formula).each do |dep| - opt = HOMEBREW_PREFIX.join("opt", dep.name) - fixopt(dep) unless opt.directory? + fixopt(dep) unless dep.opt_prefix.directory? end pre_superenv_hacks
false
Other
Homebrew
brew
3a96a1a594d688225675d0b9bd7f90fd4669b7a5.json
Use a set to track failed downloads
Library/Homebrew/cmd/fetch.rb
@@ -60,19 +60,15 @@ def fetch_patch p private def retry_fetch? f - @fetch_failed ||= {} - already_failed = @fetch_failed.fetch(f.name, false) - - if already_failed || !ARGV.include?("--retry") + @fetch_failed ||= Set.new + if ARGV.include?("--retry") && @fetch_failed.add?(f.name) + ohai "Retrying download" + f.clear_cache + true + else Homebrew.failed = true - return false + false end - - ohai "Retrying download" - - f.clear_cache - @fetch_failed[f.name] = true - true end def fetch_fetchable f
false
Other
Homebrew
brew
fd4f985cb6a915baf2dabb1d6b9b07b1d7d138a1.json
Rescue only DownloadError
Library/Homebrew/cmd/fetch.rb
@@ -79,13 +79,12 @@ def fetch_fetchable f f.clear_cache if ARGV.force? already_fetched = f.cached_download.exist? - download = nil begin download = f.fetch - rescue => e + rescue DownloadError retry if retry_fetch? f - raise e + raise end return unless download.file?
false
Other
Homebrew
brew
3d26b7584721c485d4c9df38fc7e2130c28ef75f.json
Pull common stdlib checking code into a method
Library/Homebrew/build.rb
@@ -182,25 +182,11 @@ def install def detect_stdlibs keg = Keg.new(f.prefix) - # This first test includes executables because we still - # want to record the stdlib for something that installs no - # dylibs. - stdlibs = keg.detect_cxx_stdlibs - # This currently only tracks a single C++ stdlib per dep, - # though it's possible for different libs/executables in - # a given formula to link to different ones. - stdlib_in_use = CxxStdlib.create(stdlibs.first, ENV.compiler) - begin - stdlib_in_use.check_dependencies(f, deps) - rescue IncompatibleCxxStdlibs => e - opoo e.message - end + CxxStdlib.check_compatibility(f, deps, keg, ENV.compiler) - # This second check is recorded for checking dependencies, - # so executable are irrelevant at this point. If a piece - # of software installs an executable that links against libstdc++ - # and dylibs against libc++, libc++-only dependencies can safely - # link against it. + # The stdlib recorded in the install receipt is used during dependency + # compatibility checks, so we only care about the stdlib that libraries + # link against. keg.detect_cxx_stdlibs(:skip_executables => true) end
true
Other
Homebrew
brew
3d26b7584721c485d4c9df38fc7e2130c28ef75f.json
Pull common stdlib checking code into a method
Library/Homebrew/cxxstdlib.rb
@@ -11,6 +11,18 @@ def self.create(type, compiler) klass.new(type, compiler) end + def self.check_compatibility(formula, deps, keg, compiler) + return if formula.skip_cxxstdlib_check? + + stdlib = create(keg.detect_cxx_stdlibs.first, compiler) + + begin + stdlib.check_dependencies(formula, deps) + rescue IncompatibleCxxStdlibs => e + opoo e.message + end + end + attr_reader :type, :compiler def initialize(type, compiler) @@ -32,17 +44,14 @@ def compatible_with?(other) end def check_dependencies(formula, deps) - unless formula.skip_cxxstdlib_check? - deps.each do |dep| - # Software is unlikely to link against anything from its - # buildtime deps, so it doesn't matter at all if they link - # against different C++ stdlibs - next if dep.build? - - dep_stdlib = Tab.for_formula(dep.to_formula).cxxstdlib - if !compatible_with? dep_stdlib - raise IncompatibleCxxStdlibs.new(formula, dep, dep_stdlib, self) - end + deps.each do |dep| + # Software is unlikely to link against libraries from build-time deps, so + # it doesn't matter if they link against different C++ stdlibs. + next if dep.build? + + dep_stdlib = Tab.for_formula(dep.to_formula).cxxstdlib + if !compatible_with? dep_stdlib + raise IncompatibleCxxStdlibs.new(formula, dep, dep_stdlib, self) end end end
true
Other
Homebrew
brew
3d26b7584721c485d4c9df38fc7e2130c28ef75f.json
Pull common stdlib checking code into a method
Library/Homebrew/formula_installer.rb
@@ -158,13 +158,10 @@ def install pour @poured_bottle = true - stdlibs = Keg.new(f.prefix).detect_cxx_stdlibs - stdlib_in_use = CxxStdlib.create(stdlibs.first, MacOS.default_compiler) - begin - stdlib_in_use.check_dependencies(f, f.recursive_dependencies) - rescue IncompatibleCxxStdlibs => e - opoo e.message - end + CxxStdlib.check_compatibility( + f, f.recursive_dependencies, + Keg.new(f.prefix), MacOS.default_compiler + ) tab = Tab.for_keg f.prefix tab.poured_from_bottle = true
true
Other
Homebrew
brew
0bf3ec593de9d20b873c947f420e8b19b84d50ad.json
Fix false positive audit warning
Library/Homebrew/cmd/audit.rb
@@ -483,7 +483,7 @@ def audit_line(line, lineno) problem "Use new-style option definitions" end - if line =~ /def test/ + if line =~ /def test$/ problem "Use new-style test definitions (test do)" end
false
Other
Homebrew
brew
92eb96aca08a22d69d0c7a4455444e9af95acf63.json
Use the build accessor rather than metaprogramming
Library/Homebrew/formula.rb
@@ -478,8 +478,7 @@ def verify_download_integrity fn end def test - tab = Tab.for_formula(self) - extend Module.new { define_method(:build) { tab } } + self.build = Tab.for_formula(self) ret = nil mktemp do @testpath = Pathname.pwd
false
Other
Homebrew
brew
281646b0895de6d1f8404730d1b94d4f90700161.json
Define the test_defined? method dynamically
Library/Homebrew/formula.rb
@@ -490,7 +490,7 @@ def test end def test_defined? - not self.class.instance_variable_get(:@test_defined).nil? + false end protected @@ -592,7 +592,7 @@ def self.method_added method when :brew raise "You cannot override Formula#brew in class #{name}" when :test - @test_defined = true + define_method(:test_defined?) { true } when :options instance = allocate @@ -757,7 +757,7 @@ def needs *standards def test &block return @test unless block_given? - @test_defined = true + define_method(:test_defined?) { true } @test = block end end
false
Other
Homebrew
brew
2d91613d06ae3f1a8fa84f087d9f6e3a6ff89e31.json
fetch: retry the download on a failure.
Library/Homebrew/cmd/fetch.rb
@@ -68,6 +68,8 @@ def retry_fetch? f return false end + ohai "Retrying download" + f.clear_cache @fetch_failed[f.name] = true true @@ -77,7 +79,14 @@ def fetch_fetchable f f.clear_cache if ARGV.force? already_fetched = f.cached_download.exist? - download = f.fetch + download = nil + + begin + download = f.fetch + rescue => e + retry if retry_fetch? f + raise e + end return unless download.file?
false
Other
Homebrew
brew
95aef5511091dc666beae7c5bdb79df926374554.json
Simplify cxxstdlib_check implementation The cxxstdlib_check method currently only supports one value, so we can just define the accompanying instance method when necessary. If we ever add more options we can back it with a data structure.
Library/Homebrew/compat/formula.rb
@@ -16,10 +16,6 @@ def std_cmake_parameters "-DCMAKE_INSTALL_PREFIX='#{prefix}' -DCMAKE_BUILD_TYPE=None -DCMAKE_FIND_FRAMEWORK=LAST -Wno-dev" end - def cxxstdlib - self.class.cxxstdlib - end - def cxxstdlib_check check_type self.class.cxxstdlib_check check_type end
true
Other
Homebrew
brew
95aef5511091dc666beae7c5bdb79df926374554.json
Simplify cxxstdlib_check implementation The cxxstdlib_check method currently only supports one value, so we can just define the accompanying instance method when necessary. If we ever add more options we can back it with a data structure.
Library/Homebrew/formula.rb
@@ -245,7 +245,7 @@ def skip_clean? path end def skip_cxxstdlib_check? - self.class.cxxstdlib.include?(:skip) + false end def require_universal_deps? @@ -712,16 +712,9 @@ def keg_only reason, explanation="" @keg_only_reason = KegOnlyReason.new(reason, explanation) end - # Flag for marking whether this formula needs C++ standard library - # compatibility check - def cxxstdlib - @cxxstdlib ||= Set.new - end - - # Explicitly request changing C++ standard library compatibility check - # settings. Use with caution! + # Pass :skip to this method to disable post-install stdlib checking def cxxstdlib_check check_type - cxxstdlib << check_type + define_method(:skip_cxxstdlib_check?) { true } if check_type == :skip end # For Apple compilers, this should be in the format:
true
Other
Homebrew
brew
e6498f4dfc37524be8d0827957ed75fc471ad345.json
Remove the universal accessor from BuildOptions BuildOptions is now immutable (finally).
Library/Homebrew/build_options.rb
@@ -1,6 +1,4 @@ class BuildOptions - attr_accessor :universal - def initialize(args, options) @args = args @options = options @@ -48,7 +46,7 @@ def stable? # True if the user requested a universal build. def universal? - universal || include?("universal") && option_defined?("universal") + include?("universal") && option_defined?("universal") end # True if the user requested to enable C++11 mode.
true
Other
Homebrew
brew
e6498f4dfc37524be8d0827957ed75fc471ad345.json
Remove the universal accessor from BuildOptions BuildOptions is now immutable (finally).
Library/Homebrew/compat/formula.rb
@@ -43,4 +43,8 @@ def self.class_s(name) def self.factory(name) Formulary.factory(name) end + + def self.require_universal_deps + define_method(:require_universal_deps?) { true } + end end
true
Other
Homebrew
brew
e6498f4dfc37524be8d0827957ed75fc471ad345.json
Remove the universal accessor from BuildOptions BuildOptions is now immutable (finally).
Library/Homebrew/formula.rb
@@ -248,6 +248,10 @@ def skip_cxxstdlib_check? self.class.cxxstdlib.include?(:skip) end + def require_universal_deps? + false + end + # yields self with current working directory set to the uncompressed tarball def brew validate_attributes :name, :version @@ -759,10 +763,6 @@ def needs *standards end end - def require_universal_deps - specs.each { |spec| spec.build.universal = true } - end - def test &block return @test unless block_given? @test_defined = true
true
Other
Homebrew
brew
e6498f4dfc37524be8d0827957ed75fc471ad345.json
Remove the universal accessor from BuildOptions BuildOptions is now immutable (finally).
Library/Homebrew/formula_installer.rb
@@ -310,7 +310,7 @@ def effective_build_options_for(dependent, inherited_options=[]) def inherited_options_for(dep) inherited_options = Options.new u = Option.new("universal") - if (options.include?(u) || f.build.universal?) && !dep.build? && dep.to_formula.option_defined?(u) + if (options.include?(u) || f.require_universal_deps?) && !dep.build? && dep.to_formula.option_defined?(u) inherited_options << u end inherited_options
true
Other
Homebrew
brew
181654ddafbc3989cd989d0b4edb5dc35a8d9bbc.json
Remove two more unnecessary default arguments
Library/Homebrew/keg_fix_install_names.rb
@@ -133,7 +133,7 @@ def each_install_name_for file, &block dylibs.each(&block) end - def dylib_id_for file, options={} + def dylib_id_for(file, options) # The new dylib ID should have the same basename as the old dylib ID, not # the basename of the file itself. basename = File.basename(file.dylib_id)
true
Other
Homebrew
brew
181654ddafbc3989cd989d0b4edb5dc35a8d9bbc.json
Remove two more unnecessary default arguments
Library/Homebrew/requirement.rb
@@ -126,7 +126,7 @@ def env(*settings, &block) end class Satisfier - def initialize(options={}, &block) + def initialize(options, &block) case options when Hash @options = { :build_env => true }
true
Other
Homebrew
brew
1dc384b4c4e94621b7ba1b62358e5730dfb8e8da.json
Fix mktmp to be generic as-per SUS/BSD. Closes Homebrew/homebrew#31586. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Library/Homebrew/cmd/doctor.rb
@@ -700,7 +700,7 @@ def check_for_multiple_volumes # Find the volumes for the TMP folder & HOMEBREW_CELLAR real_cellar = HOMEBREW_CELLAR.realpath - tmp = Pathname.new with_system_path { `mktemp -d #{HOMEBREW_TEMP}/homebrew-brew-doctor-XXXX` }.strip + tmp = Pathname.new with_system_path { `mktemp -d #{HOMEBREW_TEMP}/homebrew-brew-doctor-XXXXXX` }.strip real_temp = tmp.realpath.parent where_cellar = volumes.which real_cellar
true
Other
Homebrew
brew
1dc384b4c4e94621b7ba1b62358e5730dfb8e8da.json
Fix mktmp to be generic as-per SUS/BSD. Closes Homebrew/homebrew#31586. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Library/Homebrew/extend/fileutils.rb
@@ -14,7 +14,7 @@ def mktemp(prefix=name) # /tmp volume to the other volume. So we let the user override the tmp # prefix if they need to. - tempd = with_system_path { `mktemp -d #{HOMEBREW_TEMP}/#{prefix}-XXXX` }.chuzzle + tempd = with_system_path { `mktemp -d #{HOMEBREW_TEMP}/#{prefix}-XXXXXX` }.chuzzle raise "Failed to create sandbox" if tempd.nil? prevd = pwd cd tempd
true
Other
Homebrew
brew
c7444d34f783c7716d87ae7ea1074bec62f703bc.json
Use the as_flags method instead of map
Library/Homebrew/formula.rb
@@ -453,7 +453,7 @@ def to_hash hsh["installed"] << { "version" => keg.version.to_s, - "used_options" => tab.used_options.map(&:flag), + "used_options" => tab.used_options.as_flags, "built_as_bottle" => tab.built_bottle, "poured_from_bottle" => tab.poured_from_bottle }
true
Other
Homebrew
brew
c7444d34f783c7716d87ae7ea1074bec62f703bc.json
Use the as_flags method instead of map
Library/Homebrew/tab.rb
@@ -11,8 +11,8 @@ class Tab < OpenStruct FILENAME = 'INSTALL_RECEIPT.json' def self.create(formula, compiler, stdlib, build) - Tab.new :used_options => build.used_options.map(&:to_s), - :unused_options => build.unused_options.map(&:to_s), + Tab.new :used_options => build.used_options.as_flags, + :unused_options => build.unused_options.as_flags, :tabfile => formula.prefix.join(FILENAME), :built_as_bottle => !!ARGV.build_bottle?, :poured_from_bottle => false, @@ -122,8 +122,8 @@ def cxxstdlib def to_json Utils::JSON.dump({ - :used_options => used_options.map(&:to_s), - :unused_options => unused_options.map(&:to_s), + :used_options => used_options.as_flags, + :unused_options => unused_options.as_flags, :built_as_bottle => built_as_bottle, :poured_from_bottle => poured_from_bottle, :tapped_from => tapped_from,
true
Other
Homebrew
brew
c7444d34f783c7716d87ae7ea1074bec62f703bc.json
Use the as_flags method instead of map
Library/Homebrew/test/test_tab.rb
@@ -8,8 +8,8 @@ def setup @unused = Options.create(%w(--with-baz --without-qux)) @tab = Tab.new({ - :used_options => @used.map(&:to_s), - :unused_options => @unused.map(&:to_s), + :used_options => @used.as_flags, + :unused_options => @unused.as_flags, :built_as_bottle => false, :poured_from_bottle => true, :tapped_from => "Homebrew/homebrew",
true
Other
Homebrew
brew
4c4193e905ed87faf58d9f41f1724f5353943e93.json
Use the Enumerable implementation of include?
Library/Homebrew/dependencies.rb
@@ -10,7 +10,7 @@ def each(*args, &block) end def <<(o) - @deps << o unless @deps.include? o + @deps << o unless include?(o) self end
false
Other
Homebrew
brew
d443089270addfc9588c9efba399763523b88de4.json
Simplify tab test setup
Library/Homebrew/test/test_tab.rb
@@ -4,9 +4,8 @@ class TabTests < Homebrew::TestCase def setup - @used, @unused = Options.new, Options.new - @used << Option.new("with-foo") << Option.new("without-bar") - @unused << Option.new("with-baz") << Option.new("without-qux") + @used = Options.create(%w(--with-foo --without-bar)) + @unused = Options.create(%w(--with-baz --without-qux)) @tab = Tab.new({ :used_options => @used.map(&:to_s),
false
Other
Homebrew
brew
eed8af9b80979fcdd55dc44c963392dc84e63d4f.json
Drop unnecessary parens in tests
Library/Homebrew/test/test_build_environment.rb
@@ -7,7 +7,7 @@ def setup end def test_shovel_returns_self - assert_same @env, (@env << :foo) + assert_same @env, @env << :foo end def test_merge_returns_self
true
Other
Homebrew
brew
eed8af9b80979fcdd55dc44c963392dc84e63d4f.json
Drop unnecessary parens in tests
Library/Homebrew/test/test_compiler_queue.rb
@@ -9,7 +9,7 @@ def setup end def test_shovel_returns_self - assert_same @q, (@q << Object.new) + assert_same @q, @q << Object.new end def test_empty
true
Other
Homebrew
brew
eed8af9b80979fcdd55dc44c963392dc84e63d4f.json
Drop unnecessary parens in tests
Library/Homebrew/test/test_dependencies.rb
@@ -9,7 +9,7 @@ def setup end def test_shovel_returns_self - assert_same @deps, (@deps << Dependency.new("foo")) + assert_same @deps, @deps << Dependency.new("foo") end def test_no_duplicate_deps @@ -86,7 +86,7 @@ def setup end def test_shovel_returns_self - assert_same @reqs, (@reqs << Object.new) + assert_same @reqs, @reqs << Object.new end def test_merging_multiple_dependencies
true
Other
Homebrew
brew
eed8af9b80979fcdd55dc44c963392dc84e63d4f.json
Drop unnecessary parens in tests
Library/Homebrew/test/test_options.rb
@@ -70,15 +70,15 @@ def test_include end def test_union_returns_options - assert_instance_of Options, (@options + Options.new) + assert_instance_of Options, @options + Options.new end def test_difference_returns_options - assert_instance_of Options, (@options - Options.new) + assert_instance_of Options, @options - Options.new end def test_shovel_returns_self - assert_same @options, (@options << Option.new("foo")) + assert_same @options, @options << Option.new("foo") end def test_as_flags
true
Other
Homebrew
brew
094c184b12b29c5978b3c669352991650fcba313.json
Remove unused branches from Options.coerce
Library/Homebrew/options.rb
@@ -116,8 +116,6 @@ def inspect def self.coerce(arg) case arg - when self then arg - when Option then new << arg when Array opts = new arg.each do |a|
true
Other
Homebrew
brew
094c184b12b29c5978b3c669352991650fcba313.json
Remove unused branches from Options.coerce
Library/Homebrew/test/test_options.rb
@@ -132,15 +132,6 @@ def test_set_union assert_equal [foo, bar, baz].sort, (@options | options).to_a.sort end - def test_coerce_with_options - assert_same @options, Options.coerce(@options) - end - - def test_coerce_with_option - option = Option.new("foo") - assert_equal option, Options.coerce(option).to_a.first - end - def test_coerce_with_array array = %w{--foo --bar} option1 = Option.new("foo")
true
Other
Homebrew
brew
0a2be32d802073ef46596792a46f7139bb862a8c.json
Remove unused branches from Options.coerce
Library/Homebrew/options.rb
@@ -116,8 +116,6 @@ def inspect def self.coerce(arg) case arg - when self then arg - when Option then new << arg when Array opts = new arg.each do |a|
true
Other
Homebrew
brew
0a2be32d802073ef46596792a46f7139bb862a8c.json
Remove unused branches from Options.coerce
Library/Homebrew/test/test_options.rb
@@ -132,15 +132,6 @@ def test_set_union assert_equal [foo, bar, baz].sort, (@options | options).to_a.sort end - def test_coerce_with_options - assert_same @options, Options.coerce(@options) - end - - def test_coerce_with_option - option = Option.new("foo") - assert_equal option, Options.coerce(option).to_a.first - end - def test_coerce_with_array array = %w{--foo --bar} option1 = Option.new("foo")
true