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
a412b49c2ce23d0b917f5c08e0cb453a042c1b26.json
Fix dependency equality
Library/Homebrew/dependencies.rb
@@ -10,7 +10,7 @@ def each(*args, &block) end def <<(o) - @deps << o unless include?(o) + @deps << o self end
true
Other
Homebrew
brew
a412b49c2ce23d0b917f5c08e0cb453a042c1b26.json
Fix dependency equality
Library/Homebrew/dependency.rb
@@ -20,12 +20,12 @@ def to_s end def ==(other) - instance_of?(other.class) && name == other.name + instance_of?(other.class) && name == other.name && tags == other.tags end alias_method :eql?, :== def hash - name.hash + name.hash ^ tags.hash end def to_formula @@ -118,12 +118,11 @@ def keep_but_prune_recursive_deps throw(:action, :keep_but_prune_recursive_deps) end - def merge_repeats(deps) - grouped = deps.group_by(&:name) - - deps.uniq.map do |dep| - tags = grouped.fetch(dep.name).map(&:tags).flatten.uniq - dep.class.new(dep.name, tags, dep.env_proc) + def merge_repeats(all) + all.group_by(&:name).map do |name, deps| + dep = deps.first + tags = deps.map(&:tags).flatten.uniq + dep.class.new(name, tags, dep.env_proc) end end end
true
Other
Homebrew
brew
a412b49c2ce23d0b917f5c08e0cb453a042c1b26.json
Fix dependency equality
Library/Homebrew/test/test_dependencies.rb
@@ -12,13 +12,6 @@ def test_shovel_returns_self assert_same @deps, @deps << Dependency.new("foo") end - def test_no_duplicate_deps - @deps << Dependency.new("foo") - @deps << Dependency.new("foo", [:build]) - @deps << Dependency.new("foo", [:build]) - assert_equal 1, @deps.count - end - def test_preserves_order hash = { 0 => "foo", 1 => "bar", 2 => "baz" } @deps << Dependency.new(hash[0])
true
Other
Homebrew
brew
a412b49c2ce23d0b917f5c08e0cb453a042c1b26.json
Fix dependency equality
Library/Homebrew/test/test_dependency.rb
@@ -47,5 +47,8 @@ def test_equality assert_eql foo1, foo2 refute_equal foo1, bar refute_eql foo1, bar + foo3 = Dependency.new("foo", [:build]) + refute_equal foo1, foo3 + refute_eql foo1, foo3 end end
true
Other
Homebrew
brew
a412b49c2ce23d0b917f5c08e0cb453a042c1b26.json
Fix dependency equality
Library/Homebrew/test/test_dependency_collector.rb
@@ -37,13 +37,6 @@ def test_dependency_tags assert_empty Dependency.new('foo').tags end - def test_no_duplicate_dependencies - @d.add 'foo' - @d.add 'foo' => :build - assert_equal 1, @d.deps.count - assert_empty find_dependency("foo").tags - end - def test_requirement_creation @d.add :x11 assert_instance_of X11Dependency, find_requirement(X11Dependency)
true
Other
Homebrew
brew
a412b49c2ce23d0b917f5c08e0cb453a042c1b26.json
Fix dependency equality
Library/Homebrew/test/test_dependency_expansion.rb
@@ -100,16 +100,15 @@ def test_skip_skips_parent_but_yields_children end def test_keep_dep_but_prune_recursive_deps - f = stub(:name => "f", :deps => [ - build_dep(:foo, [:build], [@bar]), - build_dep(:baz, [:build]), - ]) + foo = build_dep(:foo, [:build], @bar) + baz = build_dep(:baz, [:build]) + f = stub(:name => "f", :deps => [foo, baz]) deps = Dependency.expand(f) do |dependent, dep| Dependency.keep_but_prune_recursive_deps if dep.build? end - assert_equal [@foo, @baz], deps + assert_equal [foo, baz], deps end def test_deps_with_collection_argument
true
Other
Homebrew
brew
1a1f9aa323ae03ac59ae5ba4c006ef459a586b68.json
Improve inspect output for dependency collections
Library/Homebrew/dependencies.rb
@@ -51,6 +51,10 @@ def ==(other) deps == other.deps end alias_method :eql?, :== + + def inspect + "#<#{self.class.name}: #{to_a.inspect}>" + end end class Requirements
false
Other
Homebrew
brew
395d798bc293aae877a92f9535c5621fea226876.json
brew-test-bot: check default_formula requirements. This handles the case where e.g. a default_formula cannot be installed on Yosemite which causes the build to fail.
Library/Homebrew/cmd/test-bot.rb
@@ -322,18 +322,25 @@ def skip formula_name puts "#{Tty.blue}==>#{Tty.white} SKIPPING: #{formula_name}#{Tty.reset}" end - def satisfied_requirements? formula, spec + def satisfied_requirements? formula, spec, dependency=nil requirements = formula.send(spec).requirements unsatisfied_requirements = requirements.reject do |requirement| - requirement.satisfied? || requirement.default_formula? + satisfied = false + satisfied = true if requirement.satisfied? + if !satisfied && requirement.default_formula? + default = Formula[requirement.class.default_formula] + satisfied = satisfied_requirements?(default, :stable, formula.name) + end + satisfied end if unsatisfied_requirements.empty? true else name = formula.name name += " (#{spec})" unless spec == :stable + name += " (#{dependency} dependency)" if dependency skip name puts unsatisfied_requirements.map(&:message) false
false
Other
Homebrew
brew
da3c9a1e167ec4f1d819bae0296e4567c3425078.json
brew-pull: make close message detection more precise.
Library/Homebrew/cmd/pull.rb
@@ -132,7 +132,7 @@ def pull end # If this is a pull request, append a close message. - unless message.include? 'Closes #' + unless message.include? "Closes ##{issue}." message += "\nCloses ##{issue}." safe_system 'git', 'commit', '--amend', '--signoff', '-q', '-m', message end
false
Other
Homebrew
brew
aa406df68cb8c5589039b3d82ed9e29c2ac2593a.json
Remove services from zsh completion Closes Homebrew/homebrew#34230. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Library/Contributions/brew_zsh_completion.zsh
@@ -22,10 +22,6 @@ _brew_outdated_formulae() { outdated_formulae=(`brew outdated`) } -_brew_running_services() { - running_services=(`brew services list | awk '{print $1}'`) -} - local -a _1st_arguments _1st_arguments=( 'audit:check formulae for Homebrew coding style' @@ -52,7 +48,6 @@ _1st_arguments=( 'remove:remove a formula' 'search:search for a formula (/regex/ or string)' 'server:start a local web app that lets you browse formulae (requires Sinatra)' - 'services:small wrapper around `launchctl` for supported formulae' 'switch:switch between different versions of a formula' 'tap:tap a new formula repository from GitHub, or list existing taps' 'unlink:unlink a formula' @@ -63,17 +58,8 @@ _1st_arguments=( 'uses:show formulae which depend on a formula' ) -local -a _service_arguments -_service_arguments=( - 'cleanup:get rid of stale services and unused plists' - 'list:list all services managed by `brew services`' - 'restart:gracefully restart selected service' - 'start:start selected service' - 'stop:stop selected service' -) - local expl -local -a formulae installed_formulae installed_taps outdated_formulae running_services +local -a formulae installed_formulae installed_taps outdated_formulae _arguments \ '(-v)-v[verbose]' \ @@ -112,16 +98,6 @@ case "$words[1]" in _arguments \ '(--macports)--macports[search the macports repository]' \ '(--fink)--fink[search the fink repository]' ;; - services) - if [[ -n "$words[2]" ]]; then - case "$words[2]" in - restart|start|stop) - _brew_running_services - _wanted running_services expl 'running services' compadd -a running_services ;; - esac - else - _describe -t commands "brew services subcommand" _service_arguments - fi ;; untap) _brew_installed_taps _wanted installed_taps expl 'installed taps' compadd -a installed_taps ;;
false
Other
Homebrew
brew
8e68a9724de109fe08293c9d35f422d78caa341d.json
Tell brew doctor to ignore libTrAPI.dylib Tell brew doctor to ignore libTrAPI.dylib TrAPI used by VPN software "Endpoint Security VPN" Closes Homebrew/homebrew#34129. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Library/Homebrew/cmd/doctor.rb
@@ -124,6 +124,7 @@ def check_for_stray_dylibs "libmacfuse_i64.2.dylib", # OSXFuse MacFuse compatibility layer "libosxfuse_i32.2.dylib", # OSXFuse "libosxfuse_i64.2.dylib", # OSXFuse + "libTrAPI.dylib", # TrAPI ] __check_stray_files "/usr/local/lib", "*.dylib", white_list, <<-EOS.undent
false
Other
Homebrew
brew
b89123d487673df623ebbba8aac61b29d2f9470f.json
os: shorten troubleshooting URL.
Library/Homebrew/os.rb
@@ -8,7 +8,7 @@ def self.linux? end if OS.mac? - ISSUES_URL = "https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Troubleshooting.md#troubleshooting" + ISSUES_URL = "http://git.io/brew-troubleshooting" PATH_OPEN = "/usr/bin/open" elsif OS.linux? ISSUES_URL = "https://github.com/Homebrew/linuxbrew/wiki/troubleshooting"
false
Other
Homebrew
brew
9dfc5e39e8f6898588df6c31823c0deb3b0c7f80.json
Fix Requirement equality
Library/Homebrew/requirement.rb
@@ -75,9 +75,10 @@ def env_proc self.class.env_proc end - def eql?(other) + def ==(other) instance_of?(other.class) && name == other.name && tags == other.tags end + alias_method :eql?, :== def hash name.hash ^ tags.hash
true
Other
Homebrew
brew
9dfc5e39e8f6898588df6c31823c0deb3b0c7f80.json
Fix Requirement equality
Library/Homebrew/test/test_requirement.rb
@@ -129,12 +129,14 @@ def test_modify_build_environment_without_env_proc def test_eql a, b = Requirement.new, Requirement.new + assert_equal a, b assert_eql a, b assert_equal a.hash, b.hash end def test_not_eql a, b = Requirement.new([:optional]), Requirement.new + refute_equal a, b refute_eql a, b refute_equal a.hash, b.hash end
true
Other
Homebrew
brew
e537fc41de8baad61c9296d8628a9feb6edb4385.json
Exclude documentation from `brew list --unbrewed`
Library/Homebrew/cmd/list.rb
@@ -31,6 +31,7 @@ def list lib/gio/* lib/node_modules/* lib/python[23].[0-9]/* + share/doc/homebrew/* share/info/dir share/man/man1/brew.1 share/man/whatis
false
Other
Homebrew
brew
ab0368cb3422648ed38d7d4dee183f3dd7dc66bb.json
test-bot: make variable names consistent with other code
Library/Homebrew/cmd/test-bot.rb
@@ -298,12 +298,12 @@ def single_commit? start_revision, end_revision end end - def skip formula - puts "#{Tty.blue}==>#{Tty.white} SKIPPING: #{formula}#{Tty.reset}" + def skip formula_name + puts "#{Tty.blue}==>#{Tty.white} SKIPPING: #{formula_name}#{Tty.reset}" end - def satisfied_requirements? formula_object, spec - requirements = formula_object.send(spec).requirements + def satisfied_requirements? formula, spec + requirements = formula.send(spec).requirements unsatisfied_requirements = requirements.reject do |requirement| requirement.satisfied? || requirement.default_formula? @@ -312,10 +312,10 @@ def satisfied_requirements? formula_object, spec if unsatisfied_requirements.empty? true else - formula = formula_object.name - formula += " (#{spec})" unless spec == :stable - skip formula - unsatisfied_requirements.each {|r| puts r.message} + name = formula.name + name += " (#{spec})" unless spec == :stable + skip name + puts unsatisfied_requirements.map(&:message) false end end @@ -328,36 +328,36 @@ def setup test "brew", "config" end - def formula formula - @category = __method__.to_s + ".#{formula}" + def formula formula_name + @category = "#{__method__}.#{formula_name}" - test "brew", "uses", formula - dependencies = `brew deps #{formula}`.split("\n") + test "brew", "uses", formula_name + dependencies = `brew deps #{formula_name}`.split("\n") dependencies -= `brew list`.split("\n") unchanged_dependencies = dependencies - @formulae changed_dependences = dependencies - unchanged_dependencies - formula_object = Formulary.factory(formula) - return unless satisfied_requirements?(formula_object, :stable) + formula = Formulary.factory(formula_name) + return unless satisfied_requirements?(formula, :stable) installed_gcc = false - deps = formula_object.stable.deps.to_a - reqs = formula_object.stable.requirements.to_a - if formula_object.devel && !ARGV.include?('--HEAD') - deps |= formula_object.devel.deps.to_a - reqs |= formula_object.devel.requirements.to_a + deps = formula.stable.deps.to_a + reqs = formula.stable.requirements.to_a + if formula.devel && !ARGV.include?('--HEAD') + deps |= formula.devel.deps.to_a + reqs |= formula.devel.requirements.to_a end begin deps.each { |d| CompilerSelector.select_for(d.to_formula) } - CompilerSelector.select_for(formula_object) + CompilerSelector.select_for(formula) rescue CompilerSelectionError => e unless installed_gcc test "brew", "install", "gcc" installed_gcc = true OS::Mac.clear_version_cache retry end - skip formula + skip formula_name puts e.message return end @@ -373,44 +373,44 @@ def formula formula formula_fetch_options = [] formula_fetch_options << "--build-bottle" unless ARGV.include? "--no-bottle" formula_fetch_options << "--force" if ARGV.include? "--cleanup" - formula_fetch_options << formula + formula_fetch_options << formula_name test "brew", "fetch", "--retry", *formula_fetch_options - test "brew", "uninstall", "--force", formula if formula_object.installed? + test "brew", "uninstall", "--force", formula_name if formula.installed? install_args = %w[--verbose] install_args << "--build-bottle" unless ARGV.include? "--no-bottle" install_args << "--HEAD" if ARGV.include? "--HEAD" - install_args << formula + install_args << formula_name # Don't care about e.g. bottle failures for dependencies. ENV["HOMEBREW_DEVELOPER"] = nil test "brew", "install", "--only-dependencies", *install_args unless dependencies.empty? ENV["HOMEBREW_DEVELOPER"] = "1" test "brew", "install", *install_args install_passed = steps.last.passed? - test "brew", "audit", formula + test "brew", "audit", formula_name if install_passed unless ARGV.include? '--no-bottle' - test "brew", "bottle", "--rb", formula, :puts_output_on_success => true + test "brew", "bottle", "--rb", formula_name, :puts_output_on_success => true bottle_step = steps.last if bottle_step.passed? and bottle_step.has_output? bottle_filename = bottle_step.output.gsub(/.*(\.\/\S+#{bottle_native_regex}).*/m, '\1') - test "brew", "uninstall", "--force", formula + test "brew", "uninstall", "--force", formula_name test "brew", "install", bottle_filename end end - test "brew", "test", "--verbose", formula if formula_object.test_defined? - test "brew", "uninstall", "--force", formula + test "brew", "test", "--verbose", formula_name if formula.test_defined? + test "brew", "uninstall", "--force", formula_name end - if formula_object.devel && !ARGV.include?('--HEAD') \ - && satisfied_requirements?(formula_object, :devel) + if formula.devel && !ARGV.include?('--HEAD') \ + && satisfied_requirements?(formula, :devel) test "brew", "fetch", "--retry", "--devel", *formula_fetch_options - test "brew", "install", "--devel", "--verbose", formula + test "brew", "install", "--devel", "--verbose", formula_name devel_install_passed = steps.last.passed? - test "brew", "audit", "--devel", formula + test "brew", "audit", "--devel", formula_name if devel_install_passed - test "brew", "test", "--devel", "--verbose", formula if formula_object.test_defined? - test "brew", "uninstall", "--devel", "--force", formula + test "brew", "test", "--devel", "--verbose", formula_name if formula.test_defined? + test "brew", "uninstall", "--devel", "--force", formula_name end end test "brew", "uninstall", "--force", *unchanged_dependencies unless unchanged_dependencies.empty?
false
Other
Homebrew
brew
0578f1ff5a5234a4e7ca59c49dc0b0bb414cb78a.json
Pull initialization code out of begin block
Library/Homebrew/extend/pathname.rb
@@ -106,27 +106,29 @@ def binread(*open_args) def atomic_write content require "tempfile" tf = Tempfile.new(basename.to_s, dirname) - tf.binmode - tf.write(content) - begin - old_stat = stat - rescue Errno::ENOENT - old_stat = default_stat - end + tf.binmode + tf.write(content) - uid = Process.uid - gid = Process.groups.delete(old_stat.gid) { Process.gid } + begin + old_stat = stat + rescue Errno::ENOENT + old_stat = default_stat + end - begin - tf.chown(uid, gid) - tf.chmod(old_stat.mode) - rescue Errno::EPERM - end + uid = Process.uid + gid = Process.groups.delete(old_stat.gid) { Process.gid } - File.rename(tf.path, self) - ensure - tf.close! + begin + tf.chown(uid, gid) + tf.chmod(old_stat.mode) + rescue Errno::EPERM + end + + File.rename(tf.path, self) + ensure + tf.close! + end end def default_stat
false
Other
Homebrew
brew
b34fa6cfd870e23c3876394509ed0a5be6c70b1e.json
Use libexec method in install test
Library/Homebrew/test/test_formula_install.rb
@@ -35,9 +35,8 @@ def test_a_basic_install assert_predicate f.bin, :directory? assert_equal 3, f.bin.children.length - libexec = f.prefix+'libexec' - assert_predicate libexec, :directory? - assert_equal 1, libexec.children.length + assert_predicate f.libexec, :directory? + assert_equal 1, f.libexec.children.length refute_predicate f.prefix+'main.c', :exist? assert_predicate f, :installed?
false
Other
Homebrew
brew
3b1a1962f7cd4bd44a5e4de0098129ee1dce6dc6.json
Remove outdated comment
Library/Homebrew/formula.rb
@@ -279,8 +279,6 @@ def brew stage do begin patch - # we allow formulae to do anything they want to the Ruby process - # so load any deps before this point! And exit asap afterwards yield self ensure cp Dir["config.log", "CMakeCache.txt"], HOMEBREW_LOGS+name
false
Other
Homebrew
brew
d78769743d66c2af3039c85cda69382945691abd.json
Fix broken link in Acceptable Formulae The link to the Homebrew dupes repo was broken because of a typo. Closes Homebrew/homebrew#33931. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
share/doc/homebrew/Acceptable-Formulae.md
@@ -36,7 +36,7 @@ There are exceptions: openssl | OS X's openssl is deprecated libxml2 | Historically, OS X's libxml2 has been buggy -We also maintain [a tap](https://github.com/Homebrew/homebrew-dueps) that +We also maintain [a tap](https://github.com/Homebrew/homebrew-dupes) that contains many duplicates not otherwise found in Homebrew. ### We don’t like tools that upgrade themselves
false
Other
Homebrew
brew
2d67c5ee8f7bfe1ac68bde638af852c67816cb7f.json
brew-pull: allow resolution with --resolve.
Library/Homebrew/cmd/pull.rb
@@ -34,8 +34,12 @@ def pull_url url begin safe_system 'git', 'am', *patch_args rescue ErrorDuringExecution - system 'git', 'am', '--abort' - odie 'Patch failed to apply: aborted.' + if ARGV.include? "--resolve" + odie "Patch failed to apply: try to resolve it." + else + system 'git', 'am', '--abort' + odie 'Patch failed to apply: aborted.' + end ensure patchpath.unlink end
false
Other
Homebrew
brew
daabf4f5dc3effbaa1efe7275615f6541b65906c.json
keg: add python_pth_files_installed? helper
Library/Homebrew/keg.rb
@@ -230,6 +230,10 @@ def python_site_packages_installed? path.join("lib", "python2.7", "site-packages").directory? end + def python_pth_files_installed? + Dir["#{path}/lib/python2.7/site-packages/*.pth"].any? + end + def app_installed? Dir["#{path}/{,libexec/}*.app"].any? end
false
Other
Homebrew
brew
b584689afa5683592371458f7d9383d0fea4e8e1.json
language/python: add helper methods for pth detection
Library/Homebrew/language/python.rb
@@ -8,6 +8,10 @@ def self.major_minor_version python Version.new(version.to_s) end + def self.homebrew_site_packages(version="2.7") + HOMEBREW_PREFIX/"lib/python#{version}/site-packages" + end + def self.each_python build, &block original_pythonpath = ENV["PYTHONPATH"] ["python", "python3"].each do |python| @@ -16,11 +20,33 @@ def self.each_python build, &block ENV["PYTHONPATH"] = if Formulary.factory(python).installed? nil else - "#{HOMEBREW_PREFIX}/lib/python#{version}/site-packages" + homebrew_site_packages(version) end block.call python, version if block end ENV["PYTHONPATH"] = original_pythonpath end + + def self.reads_brewed_pth_files? python + version = major_minor_version python + return unless homebrew_site_packages(version).directory? + probe_file = homebrew_site_packages(version)/"homebrew-pth-probe.pth" + probe_file.atomic_write("import site; site.homebrew_was_here = True") + result = quiet_system python, "-c", "import site; assert(site.homebrew_was_here)" + probe_file.unlink + result + end + + def self.user_site_packages python + Pathname.new(`#{python} -c "import site; print(site.getusersitepackages())"`.chomp) + end + + def self.in_sys_path? python, path + script = <<-EOS.undent + import os, sys + [os.path.realpath(p) for p in sys.path].index(os.path.realpath("#{path}")) + EOS + quiet_system python, "-c", script + end end end
false
Other
Homebrew
brew
175336202475325a6a1b13372f93d7d44dd55385.json
Call #name rather than relying on implicit #to_s
Library/Homebrew/cmd/pull.rb
@@ -110,7 +110,7 @@ def pull unless ARGV.include?('--bottle') changed_formulae.each do |f| next unless f.bottle - opoo "#{f} has a bottle: do you need to update it with --bottle?" + opoo "#{f.name} has a bottle: do you need to update it with --bottle?" end end
false
Other
Homebrew
brew
673f08f17e036b7fa200553ae9a6d0a9f73ca4ac.json
audit: compare file mode directly
Library/Homebrew/cmd/audit.rb
@@ -95,7 +95,7 @@ def initialize(formula) end def audit_file - unless formula.path.stat.mode.to_s(8) == "100644" + unless formula.path.stat.mode == 0100644 problem "Incorrect file permissions: chmod 644 #{formula.path}" end
false
Other
Homebrew
brew
e5e206f4f1c6735e8b9ce0c8378e76ba56141d64.json
Revert "Revert "xcode: use 6.1 on Mavericks."" This reverts commit 2b472a6e2634a7b7592abb7084b20a098f4a488b.
Library/Homebrew/os/mac/xcode.rb
@@ -13,7 +13,7 @@ def latest_version when "10.6" then "3.2.6" when "10.7" then "4.6.3" when "10.8" then "5.1.1" - when "10.9" then "6.0.1" + when "10.9" then "6.1" when "10.10" then "6.1" else # Default to newest known version of Xcode for unreleased OSX versions. @@ -161,7 +161,7 @@ def installed? def latest_version case MacOS.version when "10.10" then "600.0.54" - when "10.9" then "600.0.51" + when "10.9" then "600.0.54" when "10.8" then "503.0.40" else "425.0.28"
false
Other
Homebrew
brew
6545e6dad3081baac176e1519206b2b9de7ff233.json
Remove unreachable branch Requirements meeting this condition are skipped by the first branch on the caller side: https://github.com/Homebrew/homebrew/blob/6c54de812f00658404501719d315202a5551cc1b/Library/Homebrew/formula_installer.rb
Library/Homebrew/formula_installer.rb
@@ -237,7 +237,6 @@ def check_requirements(req_map) def install_requirement_default_formula?(req, dependent, build) return false unless req.default_formula? - return false if build.without?(req) && (req.recommended? || req.optional?) return true unless req.satisfied? install_bottle_for?(dependent, build) || build_bottle? end
false
Other
Homebrew
brew
27f2aa5f2c0a9ee5679fcbd5cd6f0d31a6b0bd29.json
Reduce explicit branches in dependency expansion
Library/Homebrew/formula_installer.rb
@@ -69,7 +69,8 @@ def pour_bottle? install_bottle_options={:warn=>false} true end - def install_bottle_for_dep?(dep, build) + def install_bottle_for?(dep, build) + return pour_bottle? if dep == f return false if build_from_source? return false unless dep.bottle && dep.pour_bottle? return false unless build.used_options.empty? @@ -253,9 +254,7 @@ def expand_requirements if (req.optional? || req.recommended?) && build.without?(req) Requirement.prune - elsif req.build? && dependent == self.f && pour_bottle? - Requirement.prune - elsif req.build? && dependent != self.f && install_bottle_for_dep?(dependent, build) + elsif req.build? && install_bottle_for?(dependent, build) Requirement.prune elsif install_requirement_default_formula?(req, build) dep = req.to_dependency @@ -285,9 +284,7 @@ def expand_dependencies(deps) if (dep.optional? || dep.recommended?) && build.without?(dep) Dependency.prune - elsif dep.build? && dependent == f && pour_bottle? - Dependency.prune - elsif dep.build? && dependent != f && install_bottle_for_dep?(dependent, build) + elsif dep.build? && install_bottle_for?(dependent, build) Dependency.prune elsif dep.satisfied?(options) Dependency.skip
false
Other
Homebrew
brew
d494c9db8e24740d87c0717ed35ca8731f7e209b.json
Use start_with? instead of regexp
Library/Homebrew/cmd/doctor.rb
@@ -661,7 +661,7 @@ def check_for_config_scripts paths.each do |p| next if whitelist.include? p.downcase - next if p =~ %r[^(#{real_cellar.to_s}|#{HOMEBREW_CELLAR.to_s})] + next if p.start_with?(real_cellar.to_s, HOMEBREW_CELLAR.to_s) configs = Dir["#{p}/*-config"] config_scripts << [p, configs.map { |c| File.basename(c) }] unless configs.empty?
false
Other
Homebrew
brew
92e68049d1e09757d498021426a650dfc6405cc3.json
formula_installer: set exit code to failed always. If we say something failed we should communicate that through the exit code for the bot and scripts.
Library/Homebrew/formula_installer.rb
@@ -524,6 +524,7 @@ def link(keg) onoe "Failed to create #{f.opt_prefix}" puts "Things that depend on #{f.name} will probably not build." puts e + Homebrew.failed = true end return end @@ -544,6 +545,7 @@ def link(keg) mode = OpenStruct.new(:dry_run => true, :overwrite => true) keg.link(mode) @show_summary_heading = true + Homebrew.failed = true rescue Keg::LinkError => e onoe "The `brew link` step did not complete successfully" puts "The formula built, but is not symlinked into #{HOMEBREW_PREFIX}" @@ -552,13 +554,15 @@ def link(keg) puts "You can try again using:" puts " brew link #{f.name}" @show_summary_heading = true + Homebrew.failed = true rescue Exception => e onoe "An unexpected error occurred during the `brew link` step" puts "The formula built, but is not symlinked into #{HOMEBREW_PREFIX}" puts e puts e.backtrace if debug? @show_summary_heading = true ignore_interrupts { keg.unlink } + Homebrew.failed = true raise end end @@ -570,6 +574,7 @@ def install_plist rescue Exception => e onoe "Failed to install plist file" ohai e, e.backtrace if debug? + Homebrew.failed = true end def fix_install_names(keg) @@ -584,6 +589,7 @@ def fix_install_names(keg) puts "The formula built, but you may encounter issues using it or linking other" puts "formula against it." ohai e, e.backtrace if debug? + Homebrew.failed = true @show_summary_heading = true end @@ -594,6 +600,7 @@ def clean opoo "The cleaning step did not complete successfully" puts "Still, the installation was successful, so we will link it into your prefix" ohai e, e.backtrace if debug? + Homebrew.failed = true @show_summary_heading = true end @@ -603,6 +610,7 @@ def post_install opoo "The post-install step did not complete successfully" puts "You can try again using `brew postinstall #{f.name}`" ohai e, e.backtrace if debug? + Homebrew.failed = true @show_summary_heading = true end
false
Other
Homebrew
brew
56aec9494cbe76849140da5b2c4c33c2b42dbbef.json
Fix filename case
Library/Homebrew/test/test_patching.rb
@@ -99,7 +99,7 @@ def test_patch_array def patches [PATCH_URL_A] end - end.brew { assert_patched 'libexec/noop' } + end.brew { assert_patched 'libexec/NOOP' } end end @@ -109,7 +109,7 @@ def test_patch_hash def patches { :p1 => PATCH_URL_A } end - end.brew { assert_patched 'libexec/noop' } + end.brew { assert_patched 'libexec/NOOP' } end end @@ -119,23 +119,23 @@ def test_patch_hash_array def patches { :p1 => [PATCH_URL_A] } end - end.brew { assert_patched 'libexec/noop' } + end.brew { assert_patched 'libexec/NOOP' } end end def test_patch_string shutup do formula do patch PATCH_A_CONTENTS - end.brew { assert_patched 'libexec/noop' } + end.brew { assert_patched 'libexec/NOOP' } end end def test_patch_string_with_strip shutup do formula do patch :p0, PATCH_B_CONTENTS - end.brew { assert_patched 'libexec/noop' } + end.brew { assert_patched 'libexec/NOOP' } end end @@ -145,7 +145,7 @@ def test_patch_DATA_constant def patches Formula::DATA end - end.brew { assert_patched "libexec/noop" } + end.brew { assert_patched "libexec/NOOP" } end end end
false
Other
Homebrew
brew
3e8c6c8e67b8296b013c535e6d46da6238345236.json
brew-test-bot: start generalization of uploaders.
Library/Homebrew/cmd/test-bot.rb
@@ -543,7 +543,7 @@ def test_bot ENV['HOMEBREW_LOGS'] = "#{Dir.pwd}/logs" end - if ARGV.include? '--ci-pr-upload' or ARGV.include? '--ci-testing-upload' + if ARGV.include? '--ci-upload' or ARGV.include? '--ci-pr-upload' or ARGV.include? '--ci-testing-upload' jenkins = ENV['JENKINS_HOME'] job = ENV['UPSTREAM_JOB_NAME'] id = ENV['UPSTREAM_BUILD_ID'] @@ -566,10 +566,7 @@ def test_bot safe_system "git", "checkout", "-f", "master" safe_system "git", "reset", "--hard", "origin/master" safe_system "brew", "update" - - if ARGV.include? '--ci-pr-upload' - safe_system "brew", "pull", "--clean", pr - end + safe_system "brew", "pull", "--clean", pr if pr ENV["GIT_AUTHOR_NAME"] = ENV["GIT_COMMITTER_NAME"] ENV["GIT_AUTHOR_EMAIL"] = ENV["GIT_COMMITTER_EMAIL"]
false
Other
Homebrew
brew
d8c34e83b751d8e0cd895985ea2a2cb3eba90d29.json
Add unsigned kext requirement. Creates a new requirement that dictates packages are unable to install due to requiring a signed kext to function. Closes Homebrew/homebrew#33404. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Library/Homebrew/requirements.rb
@@ -2,11 +2,12 @@ require 'requirements/fortran_dependency' require 'requirements/language_module_dependency' require 'requirements/minimum_macos_requirement' +require 'requirements/maximum_macos_requirement' require 'requirements/mpi_dependency' require 'requirements/osxfuse_dependency' require 'requirements/python_dependency' +require 'requirements/unsigned_kext_requirement' require 'requirements/x11_dependency' -require 'requirements/maximum_macos_requirement' class XcodeDependency < Requirement fatal true
true
Other
Homebrew
brew
d8c34e83b751d8e0cd895985ea2a2cb3eba90d29.json
Add unsigned kext requirement. Creates a new requirement that dictates packages are unable to install due to requiring a signed kext to function. Closes Homebrew/homebrew#33404. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Library/Homebrew/requirements/unsigned_kext_requirement.rb
@@ -0,0 +1,16 @@ +require 'requirement' + +class UnsignedKextRequirement < Requirement + fatal true + + satisfy { MacOS.version < :yosemite } + + def message + <<-EOS.undent + OS X Mavericks or older is required for this package. + OS X Yosemite introduced a strict unsigned kext ban which breaks this package. + You should remove this package from your system and attempt to find upstream + binaries to use instead. + EOS + end +end
true
Other
Homebrew
brew
93f7f2e9507763816ce1ccbf518c4cbeda31d85a.json
Add security contact
CONTRIBUTING.md
@@ -9,6 +9,10 @@ Second, read the [Troubleshooting Checklist](https://github.com/Homebrew/homebre **If you don't read these it will take us far longer to help you with your problem.** +Security +-------- +Please report security issues to security@brew.sh. + Contributing ------------ Please read:
true
Other
Homebrew
brew
93f7f2e9507763816ce1ccbf518c4cbeda31d85a.json
Add security contact
README.md
@@ -21,6 +21,10 @@ Second, read the [Troubleshooting Checklist](https://github.com/Homebrew/homebre **If you don't read these it will take us far longer to help you with your problem.** +Security +-------- +Please report security issues to security@brew.sh. + Who Are You? ------------ Homebrew's current maintainers are [Misty De Meo][mistydemeo], [Adam Vandenberg][adamv], [Jack Nagel][jacknagel], [Mike McQuaid][mikemcquaid], [Brett Koonce][asparagui] and [Tim Smith][tdsmith].
true
Other
Homebrew
brew
f29376c867571c2416ef698ad11421a212caeb68.json
Revert "xcode: use 6.1 on Mavericks." Pending resolution of Homebrew/homebrew#33431. This reverts commit bf434e2f7d18ba7d77ac15d54a43c555bc4019c8.
Library/Homebrew/os/mac/xcode.rb
@@ -13,7 +13,7 @@ def latest_version when "10.6" then "3.2.6" when "10.7" then "4.6.3" when "10.8" then "5.1.1" - when "10.9" then "6.1" + when "10.9" then "6.0.1" when "10.10" then "6.1" else # Default to newest known version of Xcode for unreleased OSX versions. @@ -161,7 +161,7 @@ def installed? def latest_version case MacOS.version when "10.10" then "600.0.54" - when "10.9" then "600.0.54" + when "10.9" then "600.0.51" when "10.8" then "503.0.40" else "425.0.28"
false
Other
Homebrew
brew
5c3c728c47599968e1d6a4167c046ea5f608df25.json
xcode: use 6.1 on Mavericks. Closes Homebrew/homebrew#33399. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Library/Homebrew/os/mac/xcode.rb
@@ -13,7 +13,7 @@ def latest_version when "10.6" then "3.2.6" when "10.7" then "4.6.3" when "10.8" then "5.1.1" - when "10.9" then "6.0.1" + when "10.9" then "6.1" when "10.10" then "6.1" else # Default to newest known version of Xcode for unreleased OSX versions. @@ -161,7 +161,7 @@ def installed? def latest_version case MacOS.version when "10.10" then "600.0.54" - when "10.9" then "600.0.51" + when "10.9" then "600.0.54" when "10.8" then "503.0.40" else "425.0.28"
false
Other
Homebrew
brew
b4e8e85d23d164bc29479b4877660fc1653ce270.json
remove ext from autocomplete
Library/Contributions/brew_bash_completion.sh
@@ -458,9 +458,6 @@ _brew () done if [[ $i -eq $COMP_CWORD ]]; then - local ext=$(\ls -p $(brew --repository)/Library/Contributions/cmd \ - 2>/dev/null | sed -e "s/\.rb//g" -e "s/brew-//g" \ - -e "s/.*\///g") __brewcomp " --cache --cellar --env --prefix --repository @@ -500,7 +497,6 @@ _brew () update upgrade uses - $ext " return fi
false
Other
Homebrew
brew
dfda2b5d6d254ba51a6f149645f22c2fcd090336.json
remove versions from autocomplete
Library/Contributions/brew_bash_completion.sh
@@ -500,7 +500,6 @@ _brew () update upgrade uses - versions $ext " return @@ -538,7 +537,6 @@ _brew () update) _brew_update ;; upgrade) _brew_upgrade ;; uses) _brew_uses ;; - versions) __brew_complete_formulae ;; *) ;; esac }
false
Other
Homebrew
brew
55e0f40d020062a03a56a50cc67c65c3dfea78c0.json
Handle broken symlinks in resolve_any_conflicts Fixes Homebrew/homebrew#33328.
Library/Homebrew/keg.rb
@@ -328,11 +328,20 @@ def resolve_any_conflicts dst, mode return unless dst.symlink? src = dst.resolved_path + # src itself may be a symlink, so check lstat to ensure we are dealing with # a directory, and not a symlink pointing at a directory (which needs to be # treated as a file). In other words, we only want to resolve one symlink. - # If it isn't a directory, make_relative_symlink will raise an exception. - if src.lstat.directory? + + begin + stat = src.lstat + rescue Errno::ENOENT + # dst is a broken symlink, so remove it. + dst.unlink unless mode.dry_run + return + end + + if stat.directory? keg = Keg.for(src) dst.unlink unless mode.dry_run keg.link_dir(src, mode) { :mkpath }
true
Other
Homebrew
brew
55e0f40d020062a03a56a50cc67c65c3dfea78c0.json
Handle broken symlinks in resolve_any_conflicts Fixes Homebrew/homebrew#33328.
Library/Homebrew/test/test_keg.rb
@@ -239,4 +239,20 @@ def test_links_to_symlinks_are_not_removed a.uninstall b.uninstall end + + def test_removes_broken_symlinks_that_conflict_with_directories + a = HOMEBREW_CELLAR.join("a", "1.0") + a.join("lib", "foo").mkpath + + keg = Keg.new(a) + + link = HOMEBREW_PREFIX.join("lib", "foo") + link.parent.mkpath + link.make_symlink(@nonexistent) + + keg.link + ensure + keg.unlink + keg.uninstall + end end
true
Other
Homebrew
brew
975f61d9818c7be1e711d28eaa75d191470fe834.json
Fix filesystem leak in keg tests
Library/Homebrew/test/test_keg.rb
@@ -226,11 +226,17 @@ def test_links_to_symlinks_are_not_removed a.join("lib", "example2").make_symlink "example" b.join("lib", "example2").mkpath - Keg.new(a).link + a = Keg.new(a) + b = Keg.new(b) + a.link lib = HOMEBREW_PREFIX.join("lib") assert_equal 2, lib.children.length - assert_raises(Keg::ConflictError) { Keg.new(b).link } + assert_raises(Keg::ConflictError) { b.link } assert_equal 2, lib.children.length + ensure + a.unlink + a.uninstall + b.uninstall end end
false
Other
Homebrew
brew
6214b9821786302749edf31ecca316d8ccbe0ee1.json
Drop questionable CLT advice If an outdated Xcode is installed, it really needs to be updated if possible. Otherwise things that depend on Xcode at build time will have that dependency satisfied, but will fail to compile. The CLT is enough if it is installed by itself, in which case Xcode dependencies will not be satisfied.
Library/Homebrew/cmd/doctor.rb
@@ -255,9 +255,6 @@ def check_xcode_up_to_date s += <<-EOS.undent Xcode 6.1 is required on Yosemite to compile anything (6.0.1 does not include the 10.10 SDK). You can install it from the App Store. - - For some software installing the CLT may be enough: - xcode-select --install EOS else s += "Xcode can be updated from the App Store."
false
Other
Homebrew
brew
94f3f345cb5034169eb51c0ffbc662f6ef06e947.json
add audit check for system OpenSSL linkage
Library/Homebrew/formula_cellar_checks.rb
@@ -134,6 +134,23 @@ def check_easy_install_pth lib EOS end + def check_openssl_links prefix + return unless prefix.directory? + keg = Keg.new(prefix) + system_openssl = keg.mach_o_files.select do |obj| + dlls = obj.dynamically_linked_libraries + dlls.any? { |dll| /\/usr\/lib\/lib(crypto|ssl).(\d\.)*dylib/.match dll } + end + return if system_openssl.empty? + + <<-EOS.undent + object files were linked against system openssl + These object files were linked against the deprecated system OpenSSL. + Adding `depends_on "openssl"` to the formula may help. + #{system_openssl * "\n "} + EOS + end + def audit_installed audit_check_output(check_manpages) audit_check_output(check_infopages) @@ -145,6 +162,7 @@ def audit_installed audit_check_output(check_generic_executables(f.sbin)) audit_check_output(check_shadowed_headers) audit_check_output(check_easy_install_pth(f.lib)) + audit_check_output(check_openssl_links(f.prefix)) end private
false
Other
Homebrew
brew
8c6efd8993215dfa8ae73041300d4d538dcb09b3.json
Drop pointless use of CannotInstallFormulaError These are not caught anywhere, just raise the string. Missed in 1b3b61ff08a4ee5979838f7dbc171e9b38e83f7c.
Library/Homebrew/cmd/install.rb
@@ -28,15 +28,15 @@ def install ARGV.formulae.each do |f| # Building head-only without --HEAD is an error if not ARGV.build_head? and f.stable.nil? - raise CannotInstallFormulaError, <<-EOS.undent + raise <<-EOS.undent #{f.name} is a head-only formula Install with `brew install --HEAD #{f.name}` EOS end # Building stable-only with --HEAD is an error if ARGV.build_head? and f.head.nil? - raise CannotInstallFormulaError, "No head is defined for #{f.name}" + raise "No head is defined for #{f.name}" end end
false
Other
Homebrew
brew
bb167ef902a431c90404610935c7716e3e0b9a95.json
yardopts: specify "extra" files. The current .yardopts is treating extra .md files as source code rather than registering them as "extra files". YARD needs a "-" to separate source from non-source files. Closes Homebrew/homebrew#33362. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
.yardopts
@@ -3,5 +3,6 @@ --exclude Library/Homebrew/test/vendor/ --exclude Library/Homebrew/vendor/ Library/Homebrew/**/*.rb +- Library/Homebrew/*.md *.md
false
Other
Homebrew
brew
f96c6e5c6c1c4ee86be783441ab682135636643c.json
doctor: clarify 10.10 Xcode situation.
Library/Homebrew/cmd/doctor.rb
@@ -246,11 +246,25 @@ def check_for_installed_developer_tools end def check_xcode_up_to_date - if MacOS::Xcode.installed? && MacOS::Xcode.outdated? then <<-EOS.undent + if MacOS::Xcode.installed? && MacOS::Xcode.outdated? + s = <<-EOS.undent Your Xcode (#{MacOS::Xcode.version}) is outdated Please update to Xcode #{MacOS::Xcode.latest_version}. - Xcode can be updated from the App Store. EOS + if MacOS.version == :yosemite && MacOS::Xcode.latest_version == "6.1" + s += <<-EOS.undent + Xcode 6.1 is required on Yosemite to compile anything (6.0.1 does not include + the 10.10 SDK). Apple have not yet uploaded it to the App Store. Instead it must + be downloaded from: + https://developer.apple.com/downloads/download.action?path=Developer_Tools/xcode_6.1/xcode_6.1.dmg + + For some software installing the CLT may be enough: + xcode-select --install + EOS + else + s += "Xcode can be updated from the App Store." + end + s end end
false
Other
Homebrew
brew
02e10beb7c79f29d5c8a17d89649af344034d541.json
Add deprecated_option to software_spec. Allows remapping one option name to another and updates build options and flags accordingly.
Library/Homebrew/options.rb
@@ -47,6 +47,11 @@ def old_flag def current_flag "--#{current}" end + + def ==(other) + instance_of?(other.class) && old == other.old && current == other.current + end + alias_method :eql?, :== end class Options
true
Other
Homebrew
brew
02e10beb7c79f29d5c8a17d89649af344034d541.json
Add deprecated_option to software_spec. Allows remapping one option name to another and updates build options and flags accordingly.
Library/Homebrew/software_spec.rb
@@ -20,6 +20,7 @@ class SoftwareSpec attr_reader :name, :owner attr_reader :build, :resources, :patches, :options + attr_reader :deprecated_flags, :deprecated_options attr_reader :dependency_collector attr_reader :bottle_specification attr_reader :compiler_failures @@ -36,7 +37,10 @@ def initialize @bottle_specification = BottleSpecification.new @patches = [] @options = Options.new - @build = BuildOptions.new(Options.create(ARGV.flags_only), options) + @flags = ARGV.flags_only + @deprecated_flags = [] + @deprecated_options = [] + @build = BuildOptions.new(Options.create(@flags), options) @compiler_failures = [] end @@ -99,6 +103,26 @@ def option(name, description="") options << opt end + def deprecated_option hash + raise ArgumentError, "deprecated_option hash must not be empty" if hash.empty? + hash.each do |old_options, new_options| + Array(old_options).each do |old_option| + Array(new_options).each do |new_option| + deprecated_option = DeprecatedOption.new(old_option, new_option) + deprecated_options << deprecated_option + + old_flag = deprecated_option.old_flag + new_flag = deprecated_option.current_flag + next unless @flags.include? old_flag + @flags -= [old_flag] + @flags |= [new_flag] + @deprecated_flags << deprecated_option + end + end + end + @build = BuildOptions.new(Options.create(@flags), options) + end + def depends_on spec dep = dependency_collector.add(spec) add_dep_option(dep) if dep
true
Other
Homebrew
brew
02e10beb7c79f29d5c8a17d89649af344034d541.json
Add deprecated_option to software_spec. Allows remapping one option name to another and updates build options and flags accordingly.
Library/Homebrew/test/test_options.rb
@@ -37,6 +37,23 @@ def test_old def test_current assert_equal "bar", @deprecated_option.current end + + def test_old + assert_equal "--foo", @deprecated_option.old_flag + end + + def test_current + assert_equal "--bar", @deprecated_option.current_flag + end + + def test_equality + foobar = DeprecatedOption.new("foo", "bar") + boofar = DeprecatedOption.new("boo", "far") + assert_equal foobar, @deprecated_option + refute_equal boofar, @deprecated_option + assert_eql @deprecated_option, foobar + refute_eql @deprecated_option, boofar + end end class OptionsTests < Homebrew::TestCase
true
Other
Homebrew
brew
02e10beb7c79f29d5c8a17d89649af344034d541.json
Add deprecated_option to software_spec. Allows remapping one option name to another and updates build options and flags accordingly.
Library/Homebrew/test/test_software_spec.rb
@@ -72,6 +72,30 @@ def test_option_description_defaults_to_empty_string assert_equal "", @spec.options.first.description end + def test_deprecated_option + @spec.deprecated_option('foo' => 'bar') + assert @spec.deprecated_options.any? + assert_equal "foo", @spec.deprecated_options.first.old + assert_equal "bar", @spec.deprecated_options.first.current + end + + def test_deprecated_options + @spec.deprecated_option(['foo1', 'foo2'] => 'bar1', 'foo3' => ['bar2', 'bar3']) + refute_empty @spec.deprecated_options + assert_equal "foo1", @spec.deprecated_options.first.old + assert_equal "bar1", @spec.deprecated_options.first.current + assert_equal "foo2", @spec.deprecated_options[1].old + assert_equal "bar1", @spec.deprecated_options[1].current + assert_equal "foo3", @spec.deprecated_options[2].old + assert_equal "bar2", @spec.deprecated_options[2].current + assert_equal "foo3", @spec.deprecated_options.last.old + assert_equal "bar3", @spec.deprecated_options.last.current + end + + def test_deprecated_option_raises_when_empty + assert_raises(ArgumentError) { @spec.deprecated_option({}) } + end + def test_depends_on @spec.depends_on('foo') assert_equal 'foo', @spec.deps.first.name
true
Other
Homebrew
brew
da0a65356d662575c0005b70371050b8015227b2.json
Add DeprecatedOption class. Used to capture options that are being renamed.
Library/Homebrew/options.rb
@@ -32,6 +32,23 @@ def inspect end end +class DeprecatedOption + attr_reader :old, :current + + def initialize(old, current) + @old = old + @current = current + end + + def old_flag + "--#{old}" + end + + def current_flag + "--#{current}" + end +end + class Options include Enumerable
true
Other
Homebrew
brew
da0a65356d662575c0005b70371050b8015227b2.json
Add DeprecatedOption class. Used to capture options that are being renamed.
Library/Homebrew/test/test_options.rb
@@ -25,6 +25,20 @@ def test_description end end +class DeprecatedOptionTests < Homebrew::TestCase + def setup + @deprecated_option = DeprecatedOption.new("foo", "bar") + end + + def test_old + assert_equal "foo", @deprecated_option.old + end + + def test_current + assert_equal "bar", @deprecated_option.current + end +end + class OptionsTests < Homebrew::TestCase def setup @options = Options.new
true
Other
Homebrew
brew
f7bb5190411006ef1f8a7f6e6a4587ecd7eaf70d.json
Add tdsmith as maintainer.
README.md
@@ -23,7 +23,7 @@ Second, read the [Troubleshooting Checklist](https://github.com/Homebrew/homebre Who Are You? ------------ -Homebrew's current maintainers are [Misty De Meo][mistydemeo], [Adam Vandenberg][adamv], [Jack Nagel][jacknagel], [Mike McQuaid][mikemcquaid] and [Brett Koonce][asparagui]. +Homebrew's current maintainers are [Misty De Meo][mistydemeo], [Adam Vandenberg][adamv], [Jack Nagel][jacknagel], [Mike McQuaid][mikemcquaid], [Brett Koonce][asparagui] and [Tim Smith][tdsmith]. Homebrew was originally created by [Max Howell][mxcl]. @@ -44,6 +44,7 @@ We accept tips through [Gittip][tip]. [jacknagel]:https://github.com/jacknagel [mikemcquaid]:https://github.com/mikemcquaid [asparagui]:https://github.com/asparagui +[tdsmith]:https://github.com/tdsmith [mxcl]:https://github.com/mxcl [formula]:https://github.com/Homebrew/homebrew/tree/master/Library/Formula/ [braumeister]:http://braumeister.org
false
Other
Homebrew
brew
93c71bafca01fe14e01843572106eb9dcb909609.json
Use YARD for API documentation. Massive TODO. We'll get there eventually...
.gitignore
@@ -1,5 +1,6 @@ /* !/.gitignore +!/.yardopts !/Library/ !/CODEOFCONDUCT.md !/CONTRIBUTING.md
true
Other
Homebrew
brew
93c71bafca01fe14e01843572106eb9dcb909609.json
Use YARD for API documentation. Massive TODO. We'll get there eventually...
.yardopts
@@ -0,0 +1,4 @@ +--title "Homebrew" +--main Library/Homebrew/API.md +Library/Homebrew/**/*.rb +*.md
true
Other
Homebrew
brew
93c71bafca01fe14e01843572106eb9dcb909609.json
Use YARD for API documentation. Massive TODO. We'll get there eventually...
Library/Homebrew/.rdoc_options
@@ -1,17 +0,0 @@ ---- !ruby/object:RDoc::Options -encoding: UTF-8 -static_path: [] -rdoc_include: -- . -charset: UTF-8 -exclude: -hyperlink_all: false -line_numbers: true -main_page: -markup: rdoc -page_dir: -show_hash: false -tab_width: 2 -title: Homebrew -visibility: :protected -webcvs:
true
Other
Homebrew
brew
93c71bafca01fe14e01843572106eb9dcb909609.json
Use YARD for API documentation. Massive TODO. We'll get there eventually...
Library/Homebrew/API.md
@@ -0,0 +1,4 @@ +# Homebrew Public API +We're (finally) working on a documented public API for Homebrew. It's currently a work in progress; a bunch of public stuff is documented and a bunch of private stuff is undocumented. Sorry about that! + +The main class you should look at is {Formula}. Assume everything else is private for now.
true
Other
Homebrew
brew
41cc28ca42e1bcaa9716d6c7930ec9c492ffa356.json
Pull conditional out of begin block
Library/Homebrew/formula_installer.rb
@@ -154,16 +154,17 @@ def install @@attempted << f - begin - if pour_bottle? :warn => true + if pour_bottle?(:warn => true) + begin pour + rescue => e + raise if ARGV.homebrew_developer? + @pour_failed = true + onoe e.message + opoo "Bottle installation failed: building from source." + else @poured_bottle = true end - rescue => e - raise e if ARGV.homebrew_developer? - @pour_failed = true - onoe e.message - opoo "Bottle installation failed: building from source." end build_bottle_preinstall if build_bottle?
false
Other
Homebrew
brew
ca2680d77f312ec8bd8c06467adb1d5077fbed81.json
Move some code to the pour method
Library/Homebrew/formula_installer.rb
@@ -158,15 +158,6 @@ def install if pour_bottle? :warn => true pour @poured_bottle = true - - 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 - tab.write end rescue => e raise e if ARGV.homebrew_developer? @@ -628,6 +619,15 @@ def pour path.cp_path_sub(f.bottle_prefix, HOMEBREW_PREFIX) end FileUtils.rm_rf f.bottle_prefix + + 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 + tab.write end def audit_check_output(output)
false
Other
Homebrew
brew
b6631b9a150250c2f381912d3bd360ae1d72974c.json
audit: call puts once instead of problems.size + 2 times
Library/Homebrew/cmd/audit.rb
@@ -22,11 +22,9 @@ def audit fa.audit unless fa.problems.empty? - puts "#{f.name}:" - fa.problems.each { |p| puts " * #{p}" } - puts formula_count += 1 problem_count += fa.problems.size + puts "#{f.name}:", fa.problems.map { |p| " * #{p}" }, "" end end @@ -153,10 +151,7 @@ def audit_deps next if dep.build? or dep.run? problem %{#{dep} dependency should be "depends_on '#{dep}' => :build"} when "git", "ruby", "mercurial" - problem <<-EOS.undent - Don't use #{dep} as a dependency. We allow non-Homebrew - #{dep} installations. - EOS + problem "Don't use #{dep} as a dependency. We allow non-Homebrew #{dep} installations." when 'gfortran' problem "Use `depends_on :fortran` instead of `depends_on 'gfortran'`" when 'open-mpi', 'mpich2'
false
Other
Homebrew
brew
358fd0ca19ea65e82577a1ff58f51793a9e9b56f.json
brew-test-bot: use Jenkins PR plugin provided URL.
Library/Homebrew/cmd/test-bot.rb
@@ -222,7 +222,7 @@ def single_commit? start_revision, end_revision # Use Jenkins environment variables if present. if no_args? and ENV['GIT_PREVIOUS_COMMIT'] and ENV['GIT_COMMIT'] \ - and not ENV['ghprbPullId'] + and not ENV['ghprbPullLink'] diff_start_sha1 = shorten_revision ENV['GIT_PREVIOUS_COMMIT'] diff_end_sha1 = shorten_revision ENV['GIT_COMMIT'] test "brew", "update" if current_branch == "master" @@ -233,18 +233,7 @@ def single_commit? start_revision, end_revision end # Handle Jenkins pull request builder plugin. - if ENV['ghprbPullId'] and ENV['GIT_URL'] - git_url = ENV['GIT_URL'] - git_match = git_url.match %r{.*github.com[:/](\w+/\w+).*} - if git_match - github_repo = git_match[1] - pull_id = ENV['ghprbPullId'] - @url = "https://github.com/#{github_repo}/pull/#{pull_id}" - @hash = nil - else - puts "Invalid 'ghprbPullId' environment variable value!" - end - end + @url = ENV['ghprbPullLink'] if ENV['ghprbPullLink'] if no_args? if diff_start_sha1 == diff_end_sha1 or \
false
Other
Homebrew
brew
7312b4a1a43c77c819b5d02db574572d6d6e4656.json
brew-test-bot: truncate output to 1MB.
Library/Homebrew/cmd/test-bot.rb
@@ -30,6 +30,7 @@ module Homebrew EMAIL_SUBJECT_FILE = "brew-test-bot.#{MacOS.cat}.email.txt" + BYTES_IN_1_MEGABYTE = 1024*1024 def homebrew_git_repo tap=nil if tap @@ -621,7 +622,12 @@ def test_bot if output.respond_to?(:force_encoding) && !output.valid_encoding? output.force_encoding(Encoding::UTF_8) end - output = REXML::CData.new output.delete("\000\a\b\e\f") + output = output.delete("\000\a\b\e\f") + if output.bytesize > BYTES_IN_1_MEGABYTE + output = "truncated output to 1MB:\n" \ + + output.slice(-BYTES_IN_1_MEGABYTE, BYTES_IN_1_MEGABYTE) + end + output = REXML::CData.new output if step.passed? system_out = testcase.add_element 'system-out' system_out.text = output
false
Other
Homebrew
brew
7266ecd4e3799006d0482708a3331bfac4e1e0d1.json
Hide install receipt key names
Library/Homebrew/cmd/reinstall.rb
@@ -20,8 +20,7 @@ def reinstall_formula f fi = FormulaInstaller.new(f) fi.options = options - fi.build_bottle = ARGV.build_bottle? - fi.build_bottle ||= tab.built_as_bottle && !tab.poured_from_bottle + fi.build_bottle = ARGV.build_bottle? || tab.build_bottle? fi.build_from_source = ARGV.build_from_source? fi.force_bottle = ARGV.force_bottle? fi.verbose = ARGV.verbose?
true
Other
Homebrew
brew
7266ecd4e3799006d0482708a3331bfac4e1e0d1.json
Hide install receipt key names
Library/Homebrew/cmd/upgrade.rb
@@ -53,8 +53,7 @@ def upgrade_formula f fi = FormulaInstaller.new(f) fi.options = tab.used_options - fi.build_bottle = ARGV.build_bottle? - fi.build_bottle ||= tab.built_as_bottle && !tab.poured_from_bottle + fi.build_bottle = ARGV.build_bottle? || tab.build_bottle? fi.build_from_source = ARGV.build_from_source? fi.verbose = ARGV.verbose? fi.verbose &&= :quieter if ARGV.quieter?
true
Other
Homebrew
brew
7266ecd4e3799006d0482708a3331bfac4e1e0d1.json
Hide install receipt key names
Library/Homebrew/tab.rb
@@ -121,6 +121,10 @@ def cxxstdlib CxxStdlib.create(lib, cc.to_sym) end + def build_bottle? + built_as_bottle && !poured_from_bottle + end + def to_json Utils::JSON.dump({ :used_options => used_options.as_flags,
true
Other
Homebrew
brew
634d67690bbb2f0d6520c2f87a1cf8c7e4ceb089.json
Remove repeated conditional The post-install audit methods are not run for keg-only installs, so we don't need to repeat the conditional here.
Library/Homebrew/formula_installer.rb
@@ -647,13 +647,13 @@ def print_check_output(output) end def audit_bin - print_check_output(check_PATH(f.bin)) unless f.keg_only? + print_check_output(check_PATH(f.bin)) print_check_output(check_non_executables(f.bin)) print_check_output(check_generic_executables(f.bin)) end def audit_sbin - print_check_output(check_PATH(f.sbin)) unless f.keg_only? + print_check_output(check_PATH(f.sbin)) print_check_output(check_non_executables(f.sbin)) print_check_output(check_generic_executables(f.sbin)) end
false
Other
Homebrew
brew
b46ebf8a29d9ac150895f426cbcf9a78359709ec.json
Simplify post-install audit output
Library/Homebrew/cmd/audit.rb
@@ -550,10 +550,8 @@ def quote_dep(dep) Symbol === dep ? dep.inspect : "'#{dep}'" end - def audit_check_output warning_and_description - return unless warning_and_description - warning, description = *warning_and_description - problem "#{warning}\n#{description}" + def audit_check_output(output) + problem(output) if output end def audit_installed
true
Other
Homebrew
brew
b46ebf8a29d9ac150895f426cbcf9a78359709ec.json
Simplify post-install audit output
Library/Homebrew/formula_cellar_checks.rb
@@ -10,49 +10,48 @@ def check_PATH bin prefix_bin = prefix_bin.realpath return if ORIGINAL_PATHS.include? prefix_bin - ["#{prefix_bin} is not in your PATH", - "You can amend this by altering your ~/.bashrc file"] + <<-EOS.undent + #{prefix_bin} is not in your PATH + You can amend this by altering your ~/.bashrc file + EOS end def check_manpages # Check for man pages that aren't in share/man return unless (f.prefix+'man').directory? - ['A top-level "man" directory was found.', - <<-EOS.undent - Homebrew requires that man pages live under share. - This can often be fixed by passing "--mandir=\#{man}" to configure. - EOS - ] + <<-EOS.undent + A top-level "man" directory was found + Homebrew requires that man pages live under share. + This can often be fixed by passing "--mandir=\#{man}" to configure. + EOS end def check_infopages # Check for info pages that aren't in share/info return unless (f.prefix+'info').directory? - ['A top-level "info" directory was found.', - <<-EOS.undent - Homebrew suggests that info pages live under share. - This can often be fixed by passing "--infodir=\#{info}" to configure. - EOS - ] + <<-EOS.undent + A top-level "info" directory was found + Homebrew suggests that info pages live under share. + This can often be fixed by passing "--infodir=\#{info}" to configure. + EOS end def check_jars return unless f.lib.directory? jars = f.lib.children.select { |g| g.extname == ".jar" } return if jars.empty? - ["JARs were installed to \"#{f.lib}\".", - <<-EOS.undent - Installing JARs to "lib" can cause conflicts between packages. - For Java software, it is typically better for the formula to - install to "libexec" and then symlink or wrap binaries into "bin". - See "activemq", "jruby", etc. for examples. - The offending files are: - #{jars * "\n "} - EOS - ] + <<-EOS.undent + JARs were installed to "#{f.lib}" + Installing JARs to "lib" can cause conflicts between packages. + For Java software, it is typically better for the formula to + install to "libexec" and then symlink or wrap binaries into "bin". + See "activemq", "jruby", etc. for examples. + The offending files are: + #{jars * "\n "} + EOS end def check_non_libraries @@ -66,13 +65,12 @@ def check_non_libraries end return if non_libraries.empty? - ["Non-libraries were installed to \"#{f.lib}\".", - <<-EOS.undent - Installing non-libraries to "lib" is discouraged. - The offending files are: - #{non_libraries * "\n "} - EOS - ] + <<-EOS.undent + Non-libraries were installed to "#{f.lib}" + Installing non-libraries to "lib" is discouraged. + The offending files are: + #{non_libraries * "\n "} + EOS end def check_non_executables bin @@ -81,12 +79,11 @@ def check_non_executables bin non_exes = bin.children.select { |g| g.directory? or not g.executable? } return if non_exes.empty? - ["Non-executables were installed to \"#{bin}\".", - <<-EOS.undent - The offending files are: - #{non_exes * "\n "} - EOS - ] + <<-EOS.undent + Non-executables were installed to "#{bin}" + The offending files are: + #{non_exes * "\n "} + EOS end def check_generic_executables bin @@ -95,16 +92,15 @@ def check_generic_executables bin generics = bin.children.select { |g| generic_names.include? g.basename.to_s } return if generics.empty? - ["Generic binaries were installed to \"#{bin}\".", - <<-EOS.undent - Binaries with generic names are likely to conflict with other software, - and suggest that this software should be installed to "libexec" and - then symlinked as needed. + <<-EOS.undent + Generic binaries were installed to "#{bin}" + Binaries with generic names are likely to conflict with other software, + and suggest that this software should be installed to "libexec" and then + symlinked as needed. - The offending files are: - #{generics * "\n "} - EOS - ] + The offending files are: + #{generics * "\n "} + EOS end def check_shadowed_headers @@ -116,21 +112,25 @@ def check_shadowed_headers return if files.empty? - ["Header files that shadow system header files were installed to \"#{f.include}\".", - "The offending files are: \n #{files * "\n "}"] + <<-EOS.undent + Header files that shadow system header files were installed to "#{f.include}" + The offending files are: + #{files * "\n "} + EOS end def check_easy_install_pth lib pth_found = Dir["#{lib}/python{2.7,3.4}/site-packages/easy-install.pth"].map { |f| File.dirname(f) } return if pth_found.empty? - ["easy-install.pth files were found in #{pth_found.join(", ")}.", - <<-EOS.undent - These .pth files are likely to cause link conflicts. Please - invoke setup.py with options --single-version-externally-managed - --record=install.txt. - EOS - ] + <<-EOS.undent + easy-install.pth files were found + These .pth files are likely to cause link conflicts. Please invoke + setup.py with options + --single-version-externally-managed --record=install.txt + The offending files are + #{pth_found * "\n "} + EOS end private
true
Other
Homebrew
brew
b46ebf8a29d9ac150895f426cbcf9a78359709ec.json
Simplify post-install audit output
Library/Homebrew/formula_installer.rb
@@ -639,12 +639,11 @@ def pour ## checks - def print_check_output warning_and_description - return unless warning_and_description - warning, description = *warning_and_description - opoo warning - puts description - @show_summary_heading = true + def print_check_output(output) + if output + opoo output + @show_summary_heading = true + end end def audit_bin
true
Other
Homebrew
brew
09d53f4fc567dfafb6d9c71742f4633762f55d7c.json
Remove audit whitelist This is currently unnecessary.
Library/Homebrew/cmd/audit.rb
@@ -484,9 +484,7 @@ def audit_line(line, lineno) end if line =~ /ARGV\.(?!(debug\?|verbose\?|value[\(\s]))/ - # Python formulae need ARGV for Requirements - problem "Use build instead of ARGV to check options", - :whitelist => %w{pygobject3 qscintilla2} + problem "Use build instead of ARGV to check options" end if line =~ /def options/ @@ -585,8 +583,7 @@ def audit private - def problem p, options={} - return if options[:whitelist].to_a.include? f.name + def problem p @problems << p end end
false
Other
Homebrew
brew
3d96dad25cdca41ced3c80d8a3b0a29a0d16d98c.json
Pull cache creation out of begin block
Library/Homebrew/resource.rb
@@ -78,12 +78,14 @@ def files(*files) end def fetch - # Ensure the cache exists HOMEBREW_CACHE.mkpath - downloader.fetch - rescue ErrorDuringExecution, CurlDownloadStrategyError => e - raise DownloadError.new(self, e) - else + + begin + downloader.fetch + rescue ErrorDuringExecution, CurlDownloadStrategyError => e + raise DownloadError.new(self, e) + end + cached_download end
false
Other
Homebrew
brew
b3ed5a367df7e551f5e3b30cb140486fa56ff3c7.json
Remove redundant comments
Library/Homebrew/formula.rb
@@ -473,12 +473,10 @@ def to_hash end - # For brew-fetch and others. def fetch active_spec.fetch end - # For FormulaInstaller. def verify_download_integrity fn active_spec.verify_download_integrity(fn) end
true
Other
Homebrew
brew
b3ed5a367df7e551f5e3b30cb140486fa56ff3c7.json
Remove redundant comments
Library/Homebrew/resource.rb
@@ -77,7 +77,6 @@ def files(*files) Partial.new(self, files) end - # For brew-fetch and others. def fetch # Ensure the cache exists HOMEBREW_CACHE.mkpath
true
Other
Homebrew
brew
a6df8785d8e51a1b4a916bfb1e555b253aa9cbfd.json
Handle read(n) returning nil Fixes Homebrew/homebrew#33090.
Library/Homebrew/mach.rb
@@ -60,7 +60,7 @@ def _mach_data offsets = [] mach_data = [] - header = read(8).unpack("N2") + header = (read(8) || "").unpack("N2") case header[0] when 0xcafebabe # universal header[1].times do |i|
false
Other
Homebrew
brew
8cc5aabfcf2a5ae8413ec7222b971c18daa69697.json
Allow debugging patch failures Closes Homebrew/homebrew#33056.
Library/Homebrew/debrew.rb
@@ -17,7 +17,7 @@ def raise(*) end module Formula - def install + def brew Debrew.debrew { super } end
false
Other
Homebrew
brew
7b550b9486b53f8987e18a2e27b7e8c137391a94.json
Use alias_method instead of an extra ivar
Library/Homebrew/requirement.rb
@@ -11,13 +11,13 @@ class Requirement include Dependable - attr_reader :tags, :name, :option_name + attr_reader :tags, :name + alias_method :option_name, :name def initialize(tags=[]) @tags = tags @tags << :build if self.class.build @name ||= infer_name - @option_name = @name end # The message to show when the requirement is not met.
false
Other
Homebrew
brew
21c329e0eb25100df64dc4bdab41ba41d64309f2.json
Simplify dispatch in git wrapper
Library/ENV/scm/git
@@ -7,15 +7,9 @@ D = File.expand_path(File.dirname(__FILE__)).freeze def exec *args # prevent fork-bombs - arg0 = if args.size == 1 - args.first.split(' ') - else - args - end.first - return if arg0 =~ /^#{F}/i - return if File.expand_path(arg0) == File.expand_path(__FILE__) - - Kernel.exec(*args) + arg0 = args.first + return if arg0 =~ /^#{F}/i || File.expand_path(arg0) == File.expand_path(__FILE__) + super end case F.downcase
false
Other
Homebrew
brew
54d0043771c0f577554f19a81fc4e251531f5ff4.json
Walk entire keg to find object files to relocate Closes Homebrew/homebrew#32772.
Library/Homebrew/keg_fix_install_names.rb
@@ -154,15 +154,9 @@ def find_dylib name def mach_o_files mach_o_files = [] - dirs = %w{bin sbin lib Frameworks} - dirs.map! { |dir| path.join(dir) } - dirs.reject! { |dir| not dir.directory? } - - dirs.each do |dir| - dir.find do |pn| - next if pn.symlink? or pn.directory? - mach_o_files << pn if pn.dylib? or pn.mach_o_bundle? or pn.mach_o_executable? - end + path.find do |pn| + next if pn.symlink? or pn.directory? + mach_o_files << pn if pn.dylib? or pn.mach_o_bundle? or pn.mach_o_executable? end mach_o_files
false
Other
Homebrew
brew
9f9f5bf31c19b33e2c4d780b59037ba6ff0afbeb.json
Add test for inreplace sub!/gsub!
Library/Homebrew/test/test_inreplace.rb
@@ -76,4 +76,15 @@ def test_change_make_var_with_tabs s.remove_make_var! "LDFLAGS" assert_equal "CFLAGS=-O3\n", s end + + def test_sub_gsub + s = "foo" + s.extend(StringInreplaceExtension) + + s.sub!("f", "b") + assert_equal "boo", s + + s.gsub!("o", "e") + assert_equal "bee", s + end end
false
Other
Homebrew
brew
cb69f339b88bf58d7e40e87859e7efd13823eab7.json
Intercept calls to sub! in inreplace blocks
Library/Homebrew/extend/string.rb
@@ -56,13 +56,21 @@ def chuzzle; end # used by the inreplace function (in utils.rb) module StringInreplaceExtension + def sub! before, after + result = super + unless result + opoo "inreplace: replacement of '#{before}' with '#{after}' failed" + end + result + end + # Warn if nothing was replaced def gsub! before, after, audit_result=true - sub = super(before, after) - if audit_result and sub.nil? + result = super(before, after) + if audit_result && result.nil? opoo "inreplace: replacement of '#{before}' with '#{after}' failed" end - return sub + result end # Looks for Makefile style variable defintions and replaces the
false
Other
Homebrew
brew
701691c261778c8f3b531b2b827f046b97ac0bf0.json
Add missing test for inreplace with tabs
Library/Homebrew/test/test_inreplace.rb
@@ -63,4 +63,17 @@ def test_get_make_var s.extend(StringInreplaceExtension) assert_equal "-Wall -O2", s.get_make_var("CFLAGS") end + + def test_change_make_var_with_tabs + s = "CFLAGS\t=\t-Wall -O2\nLDFLAGS\t=\t-lcrypto -lssl" + s.extend(StringInreplaceExtension) + + assert_equal "-Wall -O2", s.get_make_var("CFLAGS") + + s.change_make_var! "CFLAGS", "-O3" + assert_equal "CFLAGS=-O3\nLDFLAGS\t=\t-lcrypto -lssl", s + + s.remove_make_var! "LDFLAGS" + assert_equal "CFLAGS=-O3\n", s + end end
false
Other
Homebrew
brew
fb1250a012f6f7896d601c70ef6f8db90a76263d.json
Rescue any SystemCallError from atomic_write
Library/Homebrew/keg_fix_install_names.rb
@@ -47,7 +47,7 @@ def relocate_install_names old_prefix, new_prefix, old_cellar, new_cellar, optio begin first.atomic_write(s) - rescue Errno::EACCES + rescue SystemCallError first.ensure_writable do first.open("wb") { |f| f.write(s) } end
false
Other
Homebrew
brew
3b8a6c072426922946e74619f8eef511d6c35c34.json
brew-tap-readme: make an internal command.
Library/Contributions/cmd/brew-tap-readme.rb
@@ -1,31 +0,0 @@ -name = ARGV.first - -raise "A name is required" if name.nil? - -template = <<-EOS -Homebrew-#{name} -=========#{'=' * name.size} - -How do I install these formulae? --------------------------------- -Just `brew tap homebrew/#{name}` and then `brew install <formula>`. - -If the formula conflicts with one from Homebrew/homebrew or another tap, you can `brew install homebrew/#{name}/<formula>`. - -You can also install via URL: - -``` -brew install https://raw.githubusercontent.com/Homebrew/homebrew-#{name}/master/<formula>.rb -``` - -Docs ----- -`brew help`, `man brew`, or the Homebrew [wiki][]. - -[wiki]:http://wiki.github.com/Homebrew/homebrew -EOS - -puts template if ARGV.verbose? -path = Pathname.new('./README.md') -raise "#{path} already exists" if path.exist? -path.write template
true
Other
Homebrew
brew
3b8a6c072426922946e74619f8eef511d6c35c34.json
brew-tap-readme: make an internal command.
Library/Homebrew/cmd/tap-readme.rb
@@ -0,0 +1,35 @@ +module Homebrew + def tap_readme + name = ARGV.first + + raise "A name is required" if name.nil? + + template = <<-EOS + Homebrew-#{name} + =========#{'=' * name.size} + + How do I install these formulae? + -------------------------------- + Just `brew tap homebrew/#{name}` and then `brew install <formula>`. + + If the formula conflicts with one from Homebrew/homebrew or another tap, you can `brew install homebrew/#{name}/<formula>`. + + You can also install via URL: + + ``` + brew install https://raw.githubusercontent.com/Homebrew/homebrew-#{name}/master/<formula>.rb + ``` + + Docs + ---- + `brew help`, `man brew`, or the Homebrew [wiki][]. + + [wiki]:http://wiki.github.com/Homebrew/homebrew + EOS + + puts template if ARGV.verbose? + path = Pathname.new('./README.md') + raise "#{path} already exists" if path.exist? + path.write template + end +end
true
Other
Homebrew
brew
8b6978b54dc335bd0780c431cd5efadd8924c7bd.json
Move manpage to Homebrew (from Contributions). As this is something we support and update.
Library/Contributions/cmd/brew-man
@@ -3,7 +3,7 @@ set -e shopt -s nullglob -SOURCE_PATH="$HOMEBREW_REPOSITORY/Library/Contributions/manpages" +SOURCE_PATH="$HOMEBREW_REPOSITORY/Library/Homebrew/manpages" TARGET_PATH="$HOMEBREW_REPOSITORY/share/man/man1" LINKED_PATH="$HOMEBREW_PREFIX/share/man/man1"
true
Other
Homebrew
brew
8b6978b54dc335bd0780c431cd5efadd8924c7bd.json
Move manpage to Homebrew (from Contributions). As this is something we support and update.
Library/Homebrew/manpages/brew.1.md
@@ -609,4 +609,3 @@ Max Howell, a splendid chap. ## BUGS See Issues on GitHub: <http://github.com/Homebrew/homebrew/issues> -
true
Other
Homebrew
brew
af8a9ff502107fd02f6911bf7c1ab72889add666.json
brew-aspell-dictionaries: make a developer command
Library/Contributions/cmd/brew-aspell-dictionaries.rb
@@ -1,36 +0,0 @@ -require 'open-uri' -require 'resource' -require 'formula' - -dict_url = "http://ftpmirror.gnu.org/aspell/dict" -dict_mirror = "http://ftp.gnu.org/gnu/aspell/dict" -languages = {} - -open("#{dict_url}/0index.html") do |content| - content.each_line do |line| - break if %r{^</table} === line - next unless /^<tr><td><a/ === line - - fields = line.split('"') - lang, path = fields[1], fields[3] - lang.gsub!("-", "_") - languages[lang] = path - end -end - -languages.inject([]) do |resources, (lang, path)| - r = Resource.new(lang) - r.owner = Formulary.factory("aspell") - r.url "#{dict_url}/#{path}" - r.mirror "#{dict_mirror}/#{path}" - resources << r -end.each(&:fetch).each do |r| - puts <<-EOS - resource "#{r.name}" do - url "#{r.url}" - mirror "#{r.mirrors.first}" - sha1 "#{r.cached_download.sha1}" - end - - EOS -end
true
Other
Homebrew
brew
af8a9ff502107fd02f6911bf7c1ab72889add666.json
brew-aspell-dictionaries: make a developer command
Library/Homebrew/cmd/aspell-dictionaries.rb
@@ -0,0 +1,40 @@ +require 'open-uri' +require 'resource' +require 'formula' + +module Homebrew + def aspell_dictionaries + dict_url = "http://ftpmirror.gnu.org/aspell/dict" + dict_mirror = "http://ftp.gnu.org/gnu/aspell/dict" + languages = {} + + open("#{dict_url}/0index.html") do |content| + content.each_line do |line| + break if %r{^</table} === line + next unless /^<tr><td><a/ === line + + fields = line.split('"') + lang, path = fields[1], fields[3] + lang.gsub!("-", "_") + languages[lang] = path + end + end + + languages.inject([]) do |resources, (lang, path)| + r = Resource.new(lang) + r.owner = Formulary.factory("aspell") + r.url "#{dict_url}/#{path}" + r.mirror "#{dict_mirror}/#{path}" + resources << r + end.each(&:fetch).each do |r| + puts <<-EOS + resource "#{r.name}" do + url "#{r.url}" + mirror "#{r.mirrors.first}" + sha1 "#{r.cached_download.sha1}" + end + + EOS + end + end +end
true
Other
Homebrew
brew
ce6d76ed1c02d06f1eec41e21289b79b94bbdcc0.json
brew-switch: make an internal command.
Library/Contributions/cmd/brew-switch.rb
@@ -1,45 +0,0 @@ -require 'formula' -require 'keg' - -if ARGV.named.length != 2 - onoe "Usage: brew switch <formula> <version>" - exit 1 -end - -name = ARGV.shift -version = ARGV.shift - -# Does this formula have any versions? -f = Formula.factory(name.downcase) -cellar = f.prefix.parent -unless cellar.directory? - onoe "#{name} not found in the Cellar." - exit 2 -end - -# Does the target version exist? -unless (cellar+version).directory? - onoe "#{name} does not have a version \"#{version}\" in the Cellar." - - versions = cellar.subdirs.map { |d| Keg.new(d).version } - puts "Versions available: #{versions.join(', ')}" - - exit 3 -end - -# Unlink all existing versions -cellar.subdirs.each do |v| - keg = Keg.new(v) - puts "Cleaning #{keg}" - keg.unlink -end - -# Link new version, if not keg-only -if f.keg_only? - keg = Keg.new(cellar+version) - keg.optlink - puts "Opt link created for #{keg}" -else - keg = Keg.new(cellar+version) - puts "#{keg.link} links created for #{keg}" -end
true
Other
Homebrew
brew
ce6d76ed1c02d06f1eec41e21289b79b94bbdcc0.json
brew-switch: make an internal command.
Library/Homebrew/cmd/switch.rb
@@ -0,0 +1,49 @@ +require 'formula' +require 'keg' + +module Homebrew + def switch + if ARGV.named.length != 2 + onoe "Usage: brew switch <formula> <version>" + exit 1 + end + + name = ARGV.shift + version = ARGV.shift + + # Does this formula have any versions? + f = Formula.factory(name.downcase) + cellar = f.prefix.parent + unless cellar.directory? + onoe "#{name} not found in the Cellar." + exit 2 + end + + # Does the target version exist? + unless (cellar+version).directory? + onoe "#{name} does not have a version \"#{version}\" in the Cellar." + + versions = cellar.subdirs.map { |d| Keg.new(d).version } + puts "Versions available: #{versions.join(', ')}" + + exit 3 + end + + # Unlink all existing versions + cellar.subdirs.each do |v| + keg = Keg.new(v) + puts "Cleaning #{keg}" + keg.unlink + end + + # Link new version, if not keg-only + if f.keg_only? + keg = Keg.new(cellar+version) + keg.optlink + puts "Opt link created for #{keg}" + else + keg = Keg.new(cellar+version) + puts "#{keg.link} links created for #{keg}" + end + end +end
true
Other
Homebrew
brew
3a432bcc2a20ff2c61ae074ff70ca9faaee4b19b.json
brew-pull: make an internal command.
Library/Contributions/cmd/brew-pull.rb
@@ -1,144 +0,0 @@ -# Gets a patch from a GitHub commit or pull request and applies it to Homebrew. -# Optionally, installs it too. - -require 'utils' -require 'formula' - -def tap arg - match = arg.match(%r[homebrew-(\w+)/]) - match[1].downcase if match -end - -if ARGV.empty? - onoe 'This command requires at least one argument containing a URL or pull request number' -end - -if ARGV[0] == '--rebase' - onoe 'You meant `git pull --rebase`.' -end - -ARGV.named.each do |arg| - if arg.to_i > 0 - url = 'https://github.com/Homebrew/homebrew/pull/' + arg - issue = arg - else - url_match = arg.match HOMEBREW_PULL_OR_COMMIT_URL_REGEX - unless url_match - ohai 'Ignoring URL:', "Not a GitHub pull request or commit: #{arg}" - next - end - - url = url_match[0] - issue = url_match[3] - end - - if tap_name = tap(url) - user = url_match[1].downcase - tap_dir = HOMEBREW_REPOSITORY/"Library/Taps/#{user}/homebrew-#{tap_name}" - safe_system "brew", "tap", "#{user}/#{tap_name}" unless tap_dir.exist? - Dir.chdir tap_dir - else - Dir.chdir HOMEBREW_REPOSITORY - end - - if ARGV.include? '--bottle' - if issue - url = "https://github.com/BrewTestBot/homebrew/compare/homebrew:master...pr-#{issue}" - else - raise "No pull request detected!" - end - end - - # GitHub provides commits'/pull-requests' raw patches using this URL. - url += '.patch' - - # The cache directory seems like a good place to put patches. - HOMEBREW_CACHE.mkpath - patchpath = HOMEBREW_CACHE + File.basename(url) - curl url, '-o', patchpath - - # Store current revision - revision = `git rev-parse --short HEAD`.strip - - ohai 'Applying patch' - patch_args = [] - # Normally we don't want whitespace errors, but squashing them can break - # patches so an option is provided to skip this step. - if ARGV.include? '--ignore-whitespace' or ARGV.include? '--clean' - patch_args << '--whitespace=nowarn' - else - patch_args << '--whitespace=fix' - end - - # Fall back to three-way merge if patch does not apply cleanly - patch_args << "-3" - patch_args << patchpath - - begin - safe_system 'git', 'am', *patch_args - rescue ErrorDuringExecution - system 'git', 'am', '--abort' - odie 'Patch failed to apply: aborted.' - ensure - patchpath.unlink - end - - changed_formulae = [] - - if tap_dir - formula_dir = %w[Formula HomebrewFormula].find { |d| tap_dir.join(d).directory? } || "" - else - formula_dir = "Library/Formula" - end - - Utils.popen_read( - "git", "diff-tree", "-r", "--name-only", - "--diff-filter=AM", revision, "HEAD", "--", formula_dir - ).each_line do |line| - name = File.basename(line.chomp, ".rb") - - begin - changed_formulae << Formula[name] - # Make sure we catch syntax errors. - rescue Exception => e - next - end - end - - unless ARGV.include?('--bottle') - changed_formulae.each do |f| - next unless f.bottle - opoo "#{f} has a bottle: do you need to update it with --bottle?" - end - end - - if issue && !ARGV.include?('--clean') - ohai "Patch closes issue ##{issue}" - message = `git log HEAD^.. --format=%B` - - if ARGV.include? '--bump' - onoe 'Can only bump one changed formula' unless changed_formulae.length == 1 - f = changed_formulae.first - subject = "#{f.name} #{f.version}" - ohai "New bump commit subject: #{subject}" - message = "#{subject}\n\n#{message}" - end - - # If this is a pull request, append a close message. - unless message.include? 'Closes #' - message += "\nCloses ##{issue}." - safe_system 'git', 'commit', '--amend', '--signoff', '-q', '-m', message - end - end - - ohai 'Patch changed:' - safe_system "git", "diff-tree", "-r", "--stat", revision, "HEAD" - - if ARGV.include? '--install' - changed_formulae.each do |f| - ohai "Installing #{f.name}" - install = f.installed? ? 'upgrade' : 'install' - safe_system 'brew', install, '--debug', f.name - end - end -end
true
Other
Homebrew
brew
3a432bcc2a20ff2c61ae074ff70ca9faaee4b19b.json
brew-pull: make an internal command.
Library/Homebrew/cmd/pull.rb
@@ -0,0 +1,148 @@ +# Gets a patch from a GitHub commit or pull request and applies it to Homebrew. +# Optionally, installs it too. + +require 'utils' +require 'formula' + +module Homebrew + def tap arg + match = arg.match(%r[homebrew-(\w+)/]) + match[1].downcase if match + end + + def pull + if ARGV.empty? + onoe 'This command requires at least one argument containing a URL or pull request number' + end + + if ARGV[0] == '--rebase' + onoe 'You meant `git pull --rebase`.' + end + + ARGV.named.each do |arg| + if arg.to_i > 0 + url = 'https://github.com/Homebrew/homebrew/pull/' + arg + issue = arg + else + url_match = arg.match HOMEBREW_PULL_OR_COMMIT_URL_REGEX + unless url_match + ohai 'Ignoring URL:', "Not a GitHub pull request or commit: #{arg}" + next + end + + url = url_match[0] + issue = url_match[3] + end + + if tap_name = tap(url) + user = url_match[1].downcase + tap_dir = HOMEBREW_REPOSITORY/"Library/Taps/#{user}/homebrew-#{tap_name}" + safe_system "brew", "tap", "#{user}/#{tap_name}" unless tap_dir.exist? + Dir.chdir tap_dir + else + Dir.chdir HOMEBREW_REPOSITORY + end + + if ARGV.include? '--bottle' + if issue + url = "https://github.com/BrewTestBot/homebrew/compare/homebrew:master...pr-#{issue}" + else + raise "No pull request detected!" + end + end + + # GitHub provides commits'/pull-requests' raw patches using this URL. + url += '.patch' + + # The cache directory seems like a good place to put patches. + HOMEBREW_CACHE.mkpath + patchpath = HOMEBREW_CACHE + File.basename(url) + curl url, '-o', patchpath + + # Store current revision + revision = `git rev-parse --short HEAD`.strip + + ohai 'Applying patch' + patch_args = [] + # Normally we don't want whitespace errors, but squashing them can break + # patches so an option is provided to skip this step. + if ARGV.include? '--ignore-whitespace' or ARGV.include? '--clean' + patch_args << '--whitespace=nowarn' + else + patch_args << '--whitespace=fix' + end + + # Fall back to three-way merge if patch does not apply cleanly + patch_args << "-3" + patch_args << patchpath + + begin + safe_system 'git', 'am', *patch_args + rescue ErrorDuringExecution + system 'git', 'am', '--abort' + odie 'Patch failed to apply: aborted.' + ensure + patchpath.unlink + end + + changed_formulae = [] + + if tap_dir + formula_dir = %w[Formula HomebrewFormula].find { |d| tap_dir.join(d).directory? } || "" + else + formula_dir = "Library/Formula" + end + + Utils.popen_read( + "git", "diff-tree", "-r", "--name-only", + "--diff-filter=AM", revision, "HEAD", "--", formula_dir + ).each_line do |line| + name = File.basename(line.chomp, ".rb") + + begin + changed_formulae << Formula[name] + # Make sure we catch syntax errors. + rescue Exception => e + next + end + end + + unless ARGV.include?('--bottle') + changed_formulae.each do |f| + next unless f.bottle + opoo "#{f} has a bottle: do you need to update it with --bottle?" + end + end + + if issue && !ARGV.include?('--clean') + ohai "Patch closes issue ##{issue}" + message = `git log HEAD^.. --format=%B` + + if ARGV.include? '--bump' + onoe 'Can only bump one changed formula' unless changed_formulae.length == 1 + f = changed_formulae.first + subject = "#{f.name} #{f.version}" + ohai "New bump commit subject: #{subject}" + message = "#{subject}\n\n#{message}" + end + + # If this is a pull request, append a close message. + unless message.include? 'Closes #' + message += "\nCloses ##{issue}." + safe_system 'git', 'commit', '--amend', '--signoff', '-q', '-m', message + end + end + + ohai 'Patch changed:' + safe_system "git", "diff-tree", "-r", "--stat", revision, "HEAD" + + if ARGV.include? '--install' + changed_formulae.each do |f| + ohai "Installing #{f.name}" + install = f.installed? ? 'upgrade' : 'install' + safe_system 'brew', install, '--debug', f.name + end + end + end + end +end
true
Other
Homebrew
brew
706e8abe290c0c04185d62e29e2551dd8999b982.json
brew-gist-logs: make an internal command.
Library/Contributions/cmd/brew-gist-logs.rb
@@ -1,107 +0,0 @@ -require 'formula' -require 'cmd/config' -require 'net/http' -require 'net/https' -require 'stringio' - -def gist_logs f - if ARGV.include? '--new-issue' - unless HOMEBREW_GITHUB_API_TOKEN - puts 'You need to create an API token: https://github.com/settings/applications' - puts 'and then set HOMEBREW_GITHUB_API_TOKEN to use --new-issue option.' - exit 1 - end - end - - files = load_logs(f.name) - - s = StringIO.new - Homebrew.dump_verbose_config(s) - files["config.out"] = { :content => s.string } - files["doctor.out"] = { :content => `brew doctor 2>&1` } - - url = create_gist(files) - - if ARGV.include? '--new-issue' - url = new_issue(f.tap, "#{f.name} failed to build on #{MACOS_FULL_VERSION}", url) - end - - ensure puts url if url -end - -def load_logs name - logs = {} - dir = HOMEBREW_LOGS/name - dir.children.sort.each do |file| - 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 -end - -def create_gist files - post("/gists", "public" => true, "files" => files)["html_url"] -end - -def new_issue repo, title, body - post("/repos/#{repo}/issues", "title" => title, "body" => body)["html_url"] -end - -def http - @http ||= begin - uri = URI.parse('https://api.github.com') - p = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) : nil - if p.class == URI::HTTP or p.class == URI::HTTPS - @http = Net::HTTP.new(uri.host, uri.port, p.host, p.port, p.user, p.password) - else - @http = Net::HTTP.new(uri.host, uri.port) - end - @http.use_ssl = true - @http - end -end - -def make_request(path, data) - headers = { - "User-Agent" => HOMEBREW_USER_AGENT, - "Accept" => "application/vnd.github.v3+json", - "Content-Type" => "application/json", - } - - if 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 - -def post(path, data) - request = make_request(path, data) - - case response = http.request(request) - when Net::HTTPCreated - Utils::JSON.load get_body(response) - else - raise "HTTP #{response.code} #{response.message} (expected 201)" - end -end - -def get_body(response) - if !response.body.respond_to?(:force_encoding) - response.body - elsif response["Content-Type"].downcase == "application/json; charset=utf-8" - response.body.dup.force_encoding(Encoding::UTF_8) - else - response.body.encode(Encoding::UTF_8, :undef => :replace) - end -end - -if ARGV.formulae.length != 1 - puts "usage: brew gist-logs [--new-issue] <formula>" - exit 1 -end - -gist_logs(ARGV.formulae[0])
true
Other
Homebrew
brew
706e8abe290c0c04185d62e29e2551dd8999b982.json
brew-gist-logs: make an internal command.
Library/Homebrew/cmd/gist-logs.rb
@@ -0,0 +1,112 @@ +require 'formula' +require 'cmd/config' +require 'net/http' +require 'net/https' +require 'stringio' + +module Homebrew + def gistify_logs f + if ARGV.include? '--new-issue' + unless HOMEBREW_GITHUB_API_TOKEN + puts 'You need to create an API token: https://github.com/settings/applications' + puts 'and then set HOMEBREW_GITHUB_API_TOKEN to use --new-issue option.' + exit 1 + end + end + + files = load_logs(f.name) + + s = StringIO.new + Homebrew.dump_verbose_config(s) + files["config.out"] = { :content => s.string } + files["doctor.out"] = { :content => `brew doctor 2>&1` } + + url = create_gist(files) + + if ARGV.include? '--new-issue' + url = new_issue(f.tap, "#{f.name} failed to build on #{MACOS_FULL_VERSION}", url) + end + + ensure puts url if url + end + + def load_logs name + logs = {} + dir = HOMEBREW_LOGS/name + dir.children.sort.each do |file| + 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 + end + + def create_gist files + post("/gists", "public" => true, "files" => files)["html_url"] + end + + def new_issue repo, title, body + post("/repos/#{repo}/issues", "title" => title, "body" => body)["html_url"] + end + + def http + @http ||= begin + uri = URI.parse('https://api.github.com') + p = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) : nil + if p.class == URI::HTTP or p.class == URI::HTTPS + @http = Net::HTTP.new(uri.host, uri.port, p.host, p.port, p.user, p.password) + else + @http = Net::HTTP.new(uri.host, uri.port) + end + @http.use_ssl = true + @http + end + end + + def make_request(path, data) + headers = { + "User-Agent" => HOMEBREW_USER_AGENT, + "Accept" => "application/vnd.github.v3+json", + "Content-Type" => "application/json", + } + + if 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 + + def post(path, data) + request = make_request(path, data) + + case response = http.request(request) + when Net::HTTPCreated + Utils::JSON.load get_body(response) + else + raise "HTTP #{response.code} #{response.message} (expected 201)" + end + end + + def get_body(response) + if !response.body.respond_to?(:force_encoding) + response.body + elsif response["Content-Type"].downcase == "application/json; charset=utf-8" + response.body.dup.force_encoding(Encoding::UTF_8) + else + response.body.encode(Encoding::UTF_8, :undef => :replace) + end + end + + def gist_logs + if ARGV.formulae.length != 1 + puts "usage: brew gist-logs [--new-issue] <formula>" + Homebrew.failed = true + return + end + + gistify_logs(ARGV.formulae[0]) + end +end
true
Other
Homebrew
brew
b7c9025d931a4e7894f8c3febf109031e775d528.json
brew-test-bot: make an internal command.
Library/Contributions/cmd/brew-test-bot.rb
@@ -1,663 +0,0 @@ -# Comprehensively test a formula or pull request. -# -# Usage: brew test-bot [options...] <pull-request|formula> -# -# Options: -# --keep-logs: Write and keep log files under ./brewbot/ -# --cleanup: Clean the Homebrew directory. Very dangerous. Use with care. -# --clean-cache: Remove all cached downloads. Use with care. -# --skip-setup: Don't check the local system is setup correctly. -# --junit: Generate a JUnit XML test results file. -# --email: Generate an email subject file. -# --no-bottle: Run brew install without --build-bottle -# --HEAD: Run brew install with --HEAD -# --local: Ask Homebrew to write verbose logs under ./logs/ -# --tap=<tap>: Use the git repository of the given tap -# --dry-run: Just print commands, don't run them. -# -# --ci-master: Shortcut for Homebrew master branch CI options. -# --ci-pr: Shortcut for Homebrew pull request CI options. -# --ci-testing: Shortcut for Homebrew testing CI options. -# --ci-pr-upload: Homebrew CI pull request bottle upload. -# --ci-testing-upload: Homebrew CI testing bottle upload. - -require 'formula' -require 'utils' -require 'date' -require 'rexml/document' -require 'rexml/xmldecl' -require 'rexml/cdata' - -EMAIL_SUBJECT_FILE = "brew-test-bot.#{MacOS.cat}.email.txt" - -def homebrew_git_repo tap=nil - if tap - HOMEBREW_LIBRARY/"Taps/#{tap}" - else - HOMEBREW_REPOSITORY - end -end - -class Step - attr_reader :command, :name, :status, :output, :time - - def initialize test, command, options={} - @test = test - @category = test.category - @command = command - @puts_output_on_success = options[:puts_output_on_success] - @name = command[1].delete("-") - @status = :running - @repository = options[:repository] || HOMEBREW_REPOSITORY - @time = 0 - end - - def log_file_path - file = "#{@category}.#{@name}.txt" - root = @test.log_root - root ? root + file : file - end - - def status_colour - case @status - when :passed then "green" - when :running then "orange" - when :failed then "red" - end - end - - def status_upcase - @status.to_s.upcase - end - - def command_short - (@command - %w[brew --force --retry --verbose --build-bottle --rb]).join(" ") - end - - def passed? - @status == :passed - end - - def failed? - @status == :failed - end - - def puts_command - cmd = @command.join(" ") - print "#{Tty.blue}==>#{Tty.white} #{cmd}#{Tty.reset}" - tabs = (80 - "PASSED".length + 1 - cmd.length) / 8 - tabs.times{ print "\t" } - $stdout.flush - end - - def puts_result - puts " #{Tty.send status_colour}#{status_upcase}#{Tty.reset}" - end - - def has_output? - @output && !@output.empty? - end - - def run - puts_command - if ARGV.include? "--dry-run" - puts - @status = :passed - return - end - - start_time = Time.now - - log = log_file_path - - pid = fork do - File.open(log, "wb") do |f| - STDOUT.reopen(f) - STDERR.reopen(f) - end - Dir.chdir(@repository) if @command.first == "git" - exec(*@command) - end - Process.wait(pid) - - @time = Time.now - start_time - - @status = $?.success? ? :passed : :failed - puts_result - - if File.exist?(log) - @output = File.read(log) - if has_output? and (failed? or @puts_output_on_success) - puts @output - end - FileUtils.rm(log) unless ARGV.include? "--keep-logs" - end - end -end - -class Test - attr_reader :log_root, :category, :name, :steps - - def initialize argument, tap=nil - @hash = nil - @url = nil - @formulae = [] - @steps = [] - @tap = tap - @repository = homebrew_git_repo @tap - @repository_requires_tapping = !@repository.directory? - - url_match = argument.match HOMEBREW_PULL_OR_COMMIT_URL_REGEX - - # Tap repository if required, this is done before everything else - # because Formula parsing and/or git commit hash lookup depends on it. - test "brew", "tap", @tap if @tap && @repository_requires_tapping - - begin - formula = Formulary.factory(argument) - rescue FormulaUnavailableError - end - - git "rev-parse", "--verify", "-q", argument - if $?.success? - @hash = argument - elsif url_match - @url = url_match[0] - elsif formula - @formulae = [argument] - else - odie "#{argument} is not a pull request URL, commit URL or formula name." - end - - @category = __method__ - @brewbot_root = Pathname.pwd + "brewbot" - FileUtils.mkdir_p @brewbot_root - end - - def no_args? - @hash == 'HEAD' - end - - def git(*args) - rd, wr = IO.pipe - - pid = fork do - rd.close - STDERR.reopen("/dev/null") - STDOUT.reopen(wr) - wr.close - Dir.chdir @repository - exec("git", *args) - end - wr.close - Process.wait(pid) - - rd.read - ensure - rd.close - end - - def download - def shorten_revision revision - git("rev-parse", "--short", revision).strip - end - - def current_sha1 - shorten_revision 'HEAD' - end - - def current_branch - git("symbolic-ref", "HEAD").gsub("refs/heads/", "").strip - end - - def single_commit? start_revision, end_revision - git("rev-list", "--count", "#{start_revision}..#{end_revision}").to_i == 1 - end - - @category = __method__ - @start_branch = current_branch - - # Use Jenkins environment variables if present. - if no_args? and ENV['GIT_PREVIOUS_COMMIT'] and ENV['GIT_COMMIT'] \ - and not ENV['ghprbPullId'] - diff_start_sha1 = shorten_revision ENV['GIT_PREVIOUS_COMMIT'] - diff_end_sha1 = shorten_revision ENV['GIT_COMMIT'] - test "brew", "update" if current_branch == "master" - elsif @hash or @url - diff_start_sha1 = current_sha1 - test "brew", "update" if current_branch == "master" - diff_end_sha1 = current_sha1 - end - - # Handle Jenkins pull request builder plugin. - if ENV['ghprbPullId'] and ENV['GIT_URL'] - git_url = ENV['GIT_URL'] - git_match = git_url.match %r{.*github.com[:/](\w+/\w+).*} - if git_match - github_repo = git_match[1] - pull_id = ENV['ghprbPullId'] - @url = "https://github.com/#{github_repo}/pull/#{pull_id}" - @hash = nil - else - puts "Invalid 'ghprbPullId' environment variable value!" - end - end - - if no_args? - if diff_start_sha1 == diff_end_sha1 or \ - single_commit?(diff_start_sha1, diff_end_sha1) - @name = diff_end_sha1 - else - @name = "#{diff_start_sha1}-#{diff_end_sha1}" - end - elsif @hash - test "git", "checkout", @hash - diff_start_sha1 = "#{@hash}^" - diff_end_sha1 = @hash - @name = @hash - elsif @url - test "git", "checkout", current_sha1 - test "brew", "pull", "--clean", @url - diff_end_sha1 = current_sha1 - @short_url = @url.gsub('https://github.com/', '') - if @short_url.include? '/commit/' - # 7 characters should be enough for a commit (not 40). - @short_url.gsub!(/(commit\/\w{7}).*/, '\1') - @name = @short_url - else - @name = "#{@short_url}-#{diff_end_sha1}" - end - else - diff_start_sha1 = diff_end_sha1 = current_sha1 - @name = "#{@formulae.first}-#{diff_end_sha1}" - end - - @log_root = @brewbot_root + @name - FileUtils.mkdir_p @log_root - - return unless diff_start_sha1 != diff_end_sha1 - return if @url and not steps.last.passed? - - if @tap - formula_path = %w[Formula HomebrewFormula].find { |dir| (@repository/dir).directory? } || "" - else - formula_path = "Library/Formula" - end - - git( - "diff-tree", "-r", "--name-only", "--diff-filter=AM", - diff_start_sha1, diff_end_sha1, "--", formula_path - ).each_line do |line| - @formulae << File.basename(line.chomp, ".rb") - end - end - - def skip formula - puts "#{Tty.blue}==>#{Tty.white} SKIPPING: #{formula}#{Tty.reset}" - end - - def satisfied_requirements? formula_object, spec - requirements = formula_object.send(spec).requirements - - unsatisfied_requirements = requirements.reject do |requirement| - requirement.satisfied? || requirement.default_formula? - end - - if unsatisfied_requirements.empty? - true - else - formula = formula_object.name - formula += " (#{spec})" unless spec == :stable - skip formula - unsatisfied_requirements.each {|r| puts r.message} - false - end - end - - def setup - @category = __method__ - return if ARGV.include? "--skip-setup" - test "brew", "doctor" - test "brew", "--env" - test "brew", "config" - end - - def formula formula - @category = __method__.to_s + ".#{formula}" - - test "brew", "uses", formula - dependencies = `brew deps #{formula}`.split("\n") - dependencies -= `brew list`.split("\n") - unchanged_dependencies = dependencies - @formulae - changed_dependences = dependencies - unchanged_dependencies - formula_object = Formulary.factory(formula) - return unless satisfied_requirements?(formula_object, :stable) - - installed_gcc = false - deps = formula_object.stable.deps.to_a - reqs = formula_object.stable.requirements.to_a - if formula_object.devel && !ARGV.include?('--HEAD') - deps |= formula_object.devel.deps.to_a - reqs |= formula_object.devel.requirements.to_a - end - - begin - deps.each { |d| CompilerSelector.select_for(d.to_formula) } - CompilerSelector.select_for(formula_object) - rescue CompilerSelectionError => e - unless installed_gcc - test "brew", "install", "gcc" - installed_gcc = true - OS::Mac.clear_version_cache - retry - end - skip formula - puts e.message - return - end - - if (deps | reqs).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-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" - formula_fetch_options << formula - test "brew", "fetch", "--retry", *formula_fetch_options - test "brew", "uninstall", "--force", formula if formula_object.installed? - install_args = %w[--verbose] - install_args << "--build-bottle" unless ARGV.include? "--no-bottle" - install_args << "--HEAD" if ARGV.include? "--HEAD" - install_args << formula - # Don't care about e.g. bottle failures for dependencies. - ENV["HOMEBREW_DEVELOPER"] = nil - test "brew", "install", "--only-dependencies", *install_args unless dependencies.empty? - ENV["HOMEBREW_DEVELOPER"] = "1" - test "brew", "install", *install_args - install_passed = steps.last.passed? - test "brew", "audit", formula - if install_passed - unless ARGV.include? '--no-bottle' - test "brew", "bottle", "--rb", formula, :puts_output_on_success => true - bottle_step = steps.last - if bottle_step.passed? and bottle_step.has_output? - bottle_filename = - bottle_step.output.gsub(/.*(\.\/\S+#{bottle_native_regex}).*/m, '\1') - test "brew", "uninstall", "--force", formula - test "brew", "install", bottle_filename - end - end - test "brew", "test", "--verbose", formula if formula_object.test_defined? - test "brew", "uninstall", "--force", formula - end - - if formula_object.devel && !ARGV.include?('--HEAD') \ - && satisfied_requirements?(formula_object, :devel) - test "brew", "fetch", "--retry", "--devel", *formula_fetch_options - test "brew", "install", "--devel", "--verbose", formula - devel_install_passed = steps.last.passed? - test "brew", "audit", "--devel", formula - if devel_install_passed - test "brew", "test", "--devel", "--verbose", formula if formula_object.test_defined? - test "brew", "uninstall", "--devel", "--force", formula - end - end - test "brew", "uninstall", "--force", *unchanged_dependencies unless unchanged_dependencies.empty? - end - - def homebrew - @category = __method__ - test "brew", "tests" - test "brew", "readall" - end - - def cleanup_before - @category = __method__ - return unless ARGV.include? '--cleanup' - git "stash" - git "am", "--abort" - git "rebase", "--abort" - git "reset", "--hard" - git "checkout", "-f", "master" - git "clean", "--force", "-dx" - end - - def cleanup_after - @category = __method__ - - checkout_args = [] - if ARGV.include? '--cleanup' - test "git", "clean", "--force", "-dx" - checkout_args << "-f" - end - - checkout_args << @start_branch - - if ARGV.include? '--cleanup' or @url or @hash - test "git", "checkout", *checkout_args - end - - if ARGV.include? '--cleanup' - test "git", "reset", "--hard" - git "stash", "pop" - test "brew", "cleanup" - end - - test "brew", "untap", @tap if @tap && @repository_requires_tapping - - FileUtils.rm_rf @brewbot_root unless ARGV.include? "--keep-logs" - end - - def test(*args) - options = Hash === args.last ? args.pop : {} - options[:repository] = @repository - step = Step.new self, args, options - step.run - steps << step - step - end - - def check_results - status = :passed - steps.each do |step| - case step.status - when :passed then next - when :running then raise - when :failed then status = :failed - end - end - 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 - setup - homebrew - formulae.each do |f| - formula(f) - end - cleanup_after - check_results - end -end - -tap = ARGV.value('tap') - -if Pathname.pwd == HOMEBREW_PREFIX and ARGV.include? "--cleanup" - odie 'cannot use --cleanup from HOMEBREW_PREFIX as it will delete all output.' -end - -if ARGV.include? "--email" - File.open EMAIL_SUBJECT_FILE, 'w' do |file| - # The file should be written at the end but in case we don't get to that - # point ensure that we have something valid. - file.write "#{MacOS.version}: internal error." - end -end - -ENV['HOMEBREW_DEVELOPER'] = '1' -ENV['HOMEBREW_NO_EMOJI'] = '1' -if ARGV.include? '--ci-master' or ARGV.include? '--ci-pr' \ - or ARGV.include? '--ci-testing' - ARGV << '--cleanup' << '--junit' << '--local' -end -if ARGV.include? '--ci-master' - ARGV << '--no-bottle' << '--email' -end - -if ARGV.include? '--local' - ENV['HOMEBREW_LOGS'] = "#{Dir.pwd}/logs" -end - -if ARGV.include? '--ci-pr-upload' or ARGV.include? '--ci-testing-upload' - jenkins = ENV['JENKINS_HOME'] - job = ENV['UPSTREAM_JOB_NAME'] - id = ENV['UPSTREAM_BUILD_ID'] - raise "Missing Jenkins variables!" unless jenkins and job and id - - ARGV << '--verbose' - cp_args = Dir["#{jenkins}/jobs/#{job}/configurations/axis-version/*/builds/#{id}/archive/*.bottle*.*"] + ["."] - exit unless system "cp", *cp_args - - ENV["GIT_COMMITTER_NAME"] = "BrewTestBot" - ENV["GIT_COMMITTER_EMAIL"] = "brew-test-bot@googlegroups.com" - ENV["GIT_WORK_TREE"] = homebrew_git_repo tap - ENV["GIT_DIR"] = "#{ENV["GIT_WORK_TREE"]}/.git" - - pr = ENV['UPSTREAM_PULL_REQUEST'] - number = ENV['UPSTREAM_BUILD_NUMBER'] - - system "git am --abort 2>/dev/null" - system "git rebase --abort 2>/dev/null" - safe_system "git", "checkout", "-f", "master" - safe_system "git", "reset", "--hard", "origin/master" - safe_system "brew", "update" - - if ARGV.include? '--ci-pr-upload' - safe_system "brew", "pull", "--clean", pr - end - - ENV["GIT_AUTHOR_NAME"] = ENV["GIT_COMMITTER_NAME"] - ENV["GIT_AUTHOR_EMAIL"] = ENV["GIT_COMMITTER_EMAIL"] - safe_system "brew", "bottle", "--merge", "--write", *Dir["*.bottle.rb"] - - remote = "git@github.com:BrewTestBot/homebrew.git" - tag = pr ? "pr-#{pr}" : "testing-#{number}" - safe_system "git", "push", "--force", remote, "master:master", ":refs/tags/#{tag}" - - path = "/home/frs/project/m/ma/machomebrew/Bottles/" - url = "BrewTestBot,machomebrew@frs.sourceforge.net:#{path}" - - rsync_args = %w[--partial --progress --human-readable --compress] - rsync_args += Dir["*.bottle*.tar.gz"] + [url] - - safe_system "rsync", *rsync_args - safe_system "git", "tag", "--force", tag - safe_system "git", "push", "--force", remote, "refs/tags/#{tag}" - exit -end - -tests = [] -any_errors = false -if ARGV.named.empty? - # With no arguments just build the most recent commit. - test = Test.new('HEAD', tap) - any_errors = test.run - tests << test -else - ARGV.named.each do |argument| - test = Test.new(argument, tap) - any_errors = test.run or any_errors - tests << test - end -end - -if ARGV.include? "--junit" - xml_document = REXML::Document.new - xml_document << REXML::XMLDecl.new - testsuites = xml_document.add_element 'testsuites' - tests.each do |test| - testsuite = testsuites.add_element 'testsuite' - testsuite.attributes['name'] = "brew-test-bot.#{MacOS.cat}" - testsuite.attributes['tests'] = test.steps.count - test.steps.each do |step| - testcase = testsuite.add_element 'testcase' - testcase.attributes['name'] = step.command_short - testcase.attributes['status'] = step.status - testcase.attributes['time'] = step.time - failure = testcase.add_element 'failure' if step.failed? - if step.has_output? - # Remove invalid XML CData characters from step output. - output = step.output - if output.respond_to?(:force_encoding) && !output.valid_encoding? - output.force_encoding(Encoding::UTF_8) - end - output = REXML::CData.new output.delete("\000\a\b\e\f") - if step.passed? - system_out = testcase.add_element 'system-out' - system_out.text = output - else - failure.attributes["message"] = "#{step.status}: #{step.command.join(" ")}" - failure.text = output - end - end - end - end - - open("brew-test-bot.xml", "w") do |xml_file| - pretty_print_indent = 2 - xml_document.write(xml_file, pretty_print_indent) - end -end - -if ARGV.include? "--email" - failed_steps = [] - tests.each do |test| - test.steps.each do |step| - next unless step.failed? - failed_steps << step.command_short - end - end - - if failed_steps.empty? - email_subject = '' - else - email_subject = "#{MacOS.version}: #{failed_steps.join ', '}." - end - - File.open EMAIL_SUBJECT_FILE, 'w' do |file| - file.write email_subject - end -end - - -safe_system "rm -rf #{HOMEBREW_CACHE}/*" if ARGV.include? "--clean-cache" - -exit any_errors ? 0 : 1
true
Other
Homebrew
brew
b7c9025d931a4e7894f8c3febf109031e775d528.json
brew-test-bot: make an internal command.
Library/Homebrew/cmd/test-bot.rb
@@ -0,0 +1,666 @@ +# Comprehensively test a formula or pull request. +# +# Usage: brew test-bot [options...] <pull-request|formula> +# +# Options: +# --keep-logs: Write and keep log files under ./brewbot/ +# --cleanup: Clean the Homebrew directory. Very dangerous. Use with care. +# --clean-cache: Remove all cached downloads. Use with care. +# --skip-setup: Don't check the local system is setup correctly. +# --junit: Generate a JUnit XML test results file. +# --email: Generate an email subject file. +# --no-bottle: Run brew install without --build-bottle +# --HEAD: Run brew install with --HEAD +# --local: Ask Homebrew to write verbose logs under ./logs/ +# --tap=<tap>: Use the git repository of the given tap +# --dry-run: Just print commands, don't run them. +# +# --ci-master: Shortcut for Homebrew master branch CI options. +# --ci-pr: Shortcut for Homebrew pull request CI options. +# --ci-testing: Shortcut for Homebrew testing CI options. +# --ci-pr-upload: Homebrew CI pull request bottle upload. +# --ci-testing-upload: Homebrew CI testing bottle upload. + +require 'formula' +require 'utils' +require 'date' +require 'rexml/document' +require 'rexml/xmldecl' +require 'rexml/cdata' + +module Homebrew + EMAIL_SUBJECT_FILE = "brew-test-bot.#{MacOS.cat}.email.txt" + + def homebrew_git_repo tap=nil + if tap + HOMEBREW_LIBRARY/"Taps/#{tap}" + else + HOMEBREW_REPOSITORY + end + end + + class Step + attr_reader :command, :name, :status, :output, :time + + def initialize test, command, options={} + @test = test + @category = test.category + @command = command + @puts_output_on_success = options[:puts_output_on_success] + @name = command[1].delete("-") + @status = :running + @repository = options[:repository] || HOMEBREW_REPOSITORY + @time = 0 + end + + def log_file_path + file = "#{@category}.#{@name}.txt" + root = @test.log_root + root ? root + file : file + end + + def status_colour + case @status + when :passed then "green" + when :running then "orange" + when :failed then "red" + end + end + + def status_upcase + @status.to_s.upcase + end + + def command_short + (@command - %w[brew --force --retry --verbose --build-bottle --rb]).join(" ") + end + + def passed? + @status == :passed + end + + def failed? + @status == :failed + end + + def puts_command + cmd = @command.join(" ") + print "#{Tty.blue}==>#{Tty.white} #{cmd}#{Tty.reset}" + tabs = (80 - "PASSED".length + 1 - cmd.length) / 8 + tabs.times{ print "\t" } + $stdout.flush + end + + def puts_result + puts " #{Tty.send status_colour}#{status_upcase}#{Tty.reset}" + end + + def has_output? + @output && !@output.empty? + end + + def run + puts_command + if ARGV.include? "--dry-run" + puts + @status = :passed + return + end + + start_time = Time.now + + log = log_file_path + + pid = fork do + File.open(log, "wb") do |f| + STDOUT.reopen(f) + STDERR.reopen(f) + end + Dir.chdir(@repository) if @command.first == "git" + exec(*@command) + end + Process.wait(pid) + + @time = Time.now - start_time + + @status = $?.success? ? :passed : :failed + puts_result + + if File.exist?(log) + @output = File.read(log) + if has_output? and (failed? or @puts_output_on_success) + puts @output + end + FileUtils.rm(log) unless ARGV.include? "--keep-logs" + end + end + end + + class Test + attr_reader :log_root, :category, :name, :steps + + def initialize argument, tap=nil + @hash = nil + @url = nil + @formulae = [] + @steps = [] + @tap = tap + @repository = Homebrew.homebrew_git_repo @tap + @repository_requires_tapping = !@repository.directory? + + url_match = argument.match HOMEBREW_PULL_OR_COMMIT_URL_REGEX + + # Tap repository if required, this is done before everything else + # because Formula parsing and/or git commit hash lookup depends on it. + test "brew", "tap", @tap if @tap && @repository_requires_tapping + + begin + formula = Formulary.factory(argument) + rescue FormulaUnavailableError + end + + git "rev-parse", "--verify", "-q", argument + if $?.success? + @hash = argument + elsif url_match + @url = url_match[0] + elsif formula + @formulae = [argument] + else + odie "#{argument} is not a pull request URL, commit URL or formula name." + end + + @category = __method__ + @brewbot_root = Pathname.pwd + "brewbot" + FileUtils.mkdir_p @brewbot_root + end + + def no_args? + @hash == 'HEAD' + end + + def git(*args) + rd, wr = IO.pipe + + pid = fork do + rd.close + STDERR.reopen("/dev/null") + STDOUT.reopen(wr) + wr.close + Dir.chdir @repository + exec("git", *args) + end + wr.close + Process.wait(pid) + + rd.read + ensure + rd.close + end + + def download + def shorten_revision revision + git("rev-parse", "--short", revision).strip + end + + def current_sha1 + shorten_revision 'HEAD' + end + + def current_branch + git("symbolic-ref", "HEAD").gsub("refs/heads/", "").strip + end + + def single_commit? start_revision, end_revision + git("rev-list", "--count", "#{start_revision}..#{end_revision}").to_i == 1 + end + + @category = __method__ + @start_branch = current_branch + + # Use Jenkins environment variables if present. + if no_args? and ENV['GIT_PREVIOUS_COMMIT'] and ENV['GIT_COMMIT'] \ + and not ENV['ghprbPullId'] + diff_start_sha1 = shorten_revision ENV['GIT_PREVIOUS_COMMIT'] + diff_end_sha1 = shorten_revision ENV['GIT_COMMIT'] + test "brew", "update" if current_branch == "master" + elsif @hash or @url + diff_start_sha1 = current_sha1 + test "brew", "update" if current_branch == "master" + diff_end_sha1 = current_sha1 + end + + # Handle Jenkins pull request builder plugin. + if ENV['ghprbPullId'] and ENV['GIT_URL'] + git_url = ENV['GIT_URL'] + git_match = git_url.match %r{.*github.com[:/](\w+/\w+).*} + if git_match + github_repo = git_match[1] + pull_id = ENV['ghprbPullId'] + @url = "https://github.com/#{github_repo}/pull/#{pull_id}" + @hash = nil + else + puts "Invalid 'ghprbPullId' environment variable value!" + end + end + + if no_args? + if diff_start_sha1 == diff_end_sha1 or \ + single_commit?(diff_start_sha1, diff_end_sha1) + @name = diff_end_sha1 + else + @name = "#{diff_start_sha1}-#{diff_end_sha1}" + end + elsif @hash + test "git", "checkout", @hash + diff_start_sha1 = "#{@hash}^" + diff_end_sha1 = @hash + @name = @hash + elsif @url + test "git", "checkout", current_sha1 + test "brew", "pull", "--clean", @url + diff_end_sha1 = current_sha1 + @short_url = @url.gsub('https://github.com/', '') + if @short_url.include? '/commit/' + # 7 characters should be enough for a commit (not 40). + @short_url.gsub!(/(commit\/\w{7}).*/, '\1') + @name = @short_url + else + @name = "#{@short_url}-#{diff_end_sha1}" + end + else + diff_start_sha1 = diff_end_sha1 = current_sha1 + @name = "#{@formulae.first}-#{diff_end_sha1}" + end + + @log_root = @brewbot_root + @name + FileUtils.mkdir_p @log_root + + return unless diff_start_sha1 != diff_end_sha1 + return if @url and not steps.last.passed? + + if @tap + formula_path = %w[Formula HomebrewFormula].find { |dir| (@repository/dir).directory? } || "" + else + formula_path = "Library/Formula" + end + + git( + "diff-tree", "-r", "--name-only", "--diff-filter=AM", + diff_start_sha1, diff_end_sha1, "--", formula_path + ).each_line do |line| + @formulae << File.basename(line.chomp, ".rb") + end + end + + def skip formula + puts "#{Tty.blue}==>#{Tty.white} SKIPPING: #{formula}#{Tty.reset}" + end + + def satisfied_requirements? formula_object, spec + requirements = formula_object.send(spec).requirements + + unsatisfied_requirements = requirements.reject do |requirement| + requirement.satisfied? || requirement.default_formula? + end + + if unsatisfied_requirements.empty? + true + else + formula = formula_object.name + formula += " (#{spec})" unless spec == :stable + skip formula + unsatisfied_requirements.each {|r| puts r.message} + false + end + end + + def setup + @category = __method__ + return if ARGV.include? "--skip-setup" + test "brew", "doctor" + test "brew", "--env" + test "brew", "config" + end + + def formula formula + @category = __method__.to_s + ".#{formula}" + + test "brew", "uses", formula + dependencies = `brew deps #{formula}`.split("\n") + dependencies -= `brew list`.split("\n") + unchanged_dependencies = dependencies - @formulae + changed_dependences = dependencies - unchanged_dependencies + formula_object = Formulary.factory(formula) + return unless satisfied_requirements?(formula_object, :stable) + + installed_gcc = false + deps = formula_object.stable.deps.to_a + reqs = formula_object.stable.requirements.to_a + if formula_object.devel && !ARGV.include?('--HEAD') + deps |= formula_object.devel.deps.to_a + reqs |= formula_object.devel.requirements.to_a + end + + begin + deps.each { |d| CompilerSelector.select_for(d.to_formula) } + CompilerSelector.select_for(formula_object) + rescue CompilerSelectionError => e + unless installed_gcc + test "brew", "install", "gcc" + installed_gcc = true + OS::Mac.clear_version_cache + retry + end + skip formula + puts e.message + return + end + + if (deps | reqs).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-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" + formula_fetch_options << formula + test "brew", "fetch", "--retry", *formula_fetch_options + test "brew", "uninstall", "--force", formula if formula_object.installed? + install_args = %w[--verbose] + install_args << "--build-bottle" unless ARGV.include? "--no-bottle" + install_args << "--HEAD" if ARGV.include? "--HEAD" + install_args << formula + # Don't care about e.g. bottle failures for dependencies. + ENV["HOMEBREW_DEVELOPER"] = nil + test "brew", "install", "--only-dependencies", *install_args unless dependencies.empty? + ENV["HOMEBREW_DEVELOPER"] = "1" + test "brew", "install", *install_args + install_passed = steps.last.passed? + test "brew", "audit", formula + if install_passed + unless ARGV.include? '--no-bottle' + test "brew", "bottle", "--rb", formula, :puts_output_on_success => true + bottle_step = steps.last + if bottle_step.passed? and bottle_step.has_output? + bottle_filename = + bottle_step.output.gsub(/.*(\.\/\S+#{bottle_native_regex}).*/m, '\1') + test "brew", "uninstall", "--force", formula + test "brew", "install", bottle_filename + end + end + test "brew", "test", "--verbose", formula if formula_object.test_defined? + test "brew", "uninstall", "--force", formula + end + + if formula_object.devel && !ARGV.include?('--HEAD') \ + && satisfied_requirements?(formula_object, :devel) + test "brew", "fetch", "--retry", "--devel", *formula_fetch_options + test "brew", "install", "--devel", "--verbose", formula + devel_install_passed = steps.last.passed? + test "brew", "audit", "--devel", formula + if devel_install_passed + test "brew", "test", "--devel", "--verbose", formula if formula_object.test_defined? + test "brew", "uninstall", "--devel", "--force", formula + end + end + test "brew", "uninstall", "--force", *unchanged_dependencies unless unchanged_dependencies.empty? + end + + def homebrew + @category = __method__ + test "brew", "tests" + test "brew", "readall" + end + + def cleanup_before + @category = __method__ + return unless ARGV.include? '--cleanup' + git "stash" + git "am", "--abort" + git "rebase", "--abort" + git "reset", "--hard" + git "checkout", "-f", "master" + git "clean", "--force", "-dx" + end + + def cleanup_after + @category = __method__ + + checkout_args = [] + if ARGV.include? '--cleanup' + test "git", "clean", "--force", "-dx" + checkout_args << "-f" + end + + checkout_args << @start_branch + + if ARGV.include? '--cleanup' or @url or @hash + test "git", "checkout", *checkout_args + end + + if ARGV.include? '--cleanup' + test "git", "reset", "--hard" + git "stash", "pop" + test "brew", "cleanup" + end + + test "brew", "untap", @tap if @tap && @repository_requires_tapping + + FileUtils.rm_rf @brewbot_root unless ARGV.include? "--keep-logs" + end + + def test(*args) + options = Hash === args.last ? args.pop : {} + options[:repository] = @repository + step = Step.new self, args, options + step.run + steps << step + step + end + + def check_results + status = :passed + steps.each do |step| + case step.status + when :passed then next + when :running then raise + when :failed then status = :failed + end + end + 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 + setup + homebrew + formulae.each do |f| + formula(f) + end + cleanup_after + check_results + end + end + + def test_bot + tap = ARGV.value('tap') + + if Pathname.pwd == HOMEBREW_PREFIX and ARGV.include? "--cleanup" + odie 'cannot use --cleanup from HOMEBREW_PREFIX as it will delete all output.' + end + + if ARGV.include? "--email" + File.open EMAIL_SUBJECT_FILE, 'w' do |file| + # The file should be written at the end but in case we don't get to that + # point ensure that we have something valid. + file.write "#{MacOS.version}: internal error." + end + end + + ENV['HOMEBREW_DEVELOPER'] = '1' + ENV['HOMEBREW_NO_EMOJI'] = '1' + if ARGV.include? '--ci-master' or ARGV.include? '--ci-pr' \ + or ARGV.include? '--ci-testing' + ARGV << '--cleanup' << '--junit' << '--local' + end + if ARGV.include? '--ci-master' + ARGV << '--no-bottle' << '--email' + end + + if ARGV.include? '--local' + ENV['HOMEBREW_LOGS'] = "#{Dir.pwd}/logs" + end + + if ARGV.include? '--ci-pr-upload' or ARGV.include? '--ci-testing-upload' + jenkins = ENV['JENKINS_HOME'] + job = ENV['UPSTREAM_JOB_NAME'] + id = ENV['UPSTREAM_BUILD_ID'] + raise "Missing Jenkins variables!" unless jenkins and job and id + + ARGV << '--verbose' + cp_args = Dir["#{jenkins}/jobs/#{job}/configurations/axis-version/*/builds/#{id}/archive/*.bottle*.*"] + ["."] + return unless system "cp", *cp_args + + ENV["GIT_COMMITTER_NAME"] = "BrewTestBot" + ENV["GIT_COMMITTER_EMAIL"] = "brew-test-bot@googlegroups.com" + ENV["GIT_WORK_TREE"] = Homebrew.homebrew_git_repo tap + ENV["GIT_DIR"] = "#{ENV["GIT_WORK_TREE"]}/.git" + + pr = ENV['UPSTREAM_PULL_REQUEST'] + number = ENV['UPSTREAM_BUILD_NUMBER'] + + system "git am --abort 2>/dev/null" + system "git rebase --abort 2>/dev/null" + safe_system "git", "checkout", "-f", "master" + safe_system "git", "reset", "--hard", "origin/master" + safe_system "brew", "update" + + if ARGV.include? '--ci-pr-upload' + safe_system "brew", "pull", "--clean", pr + end + + ENV["GIT_AUTHOR_NAME"] = ENV["GIT_COMMITTER_NAME"] + ENV["GIT_AUTHOR_EMAIL"] = ENV["GIT_COMMITTER_EMAIL"] + safe_system "brew", "bottle", "--merge", "--write", *Dir["*.bottle.rb"] + + remote = "git@github.com:BrewTestBot/homebrew.git" + tag = pr ? "pr-#{pr}" : "testing-#{number}" + safe_system "git", "push", "--force", remote, "master:master", ":refs/tags/#{tag}" + + path = "/home/frs/project/m/ma/machomebrew/Bottles/" + url = "BrewTestBot,machomebrew@frs.sourceforge.net:#{path}" + + rsync_args = %w[--partial --progress --human-readable --compress] + rsync_args += Dir["*.bottle*.tar.gz"] + [url] + + safe_system "rsync", *rsync_args + safe_system "git", "tag", "--force", tag + safe_system "git", "push", "--force", remote, "refs/tags/#{tag}" + return + end + + tests = [] + any_errors = false + if ARGV.named.empty? + # With no arguments just build the most recent commit. + test = Test.new('HEAD', tap) + any_errors = test.run + tests << test + else + ARGV.named.each do |argument| + test = Test.new(argument, tap) + any_errors = test.run or any_errors + tests << test + end + end + + if ARGV.include? "--junit" + xml_document = REXML::Document.new + xml_document << REXML::XMLDecl.new + testsuites = xml_document.add_element 'testsuites' + tests.each do |test| + testsuite = testsuites.add_element 'testsuite' + testsuite.attributes['name'] = "brew-test-bot.#{MacOS.cat}" + testsuite.attributes['tests'] = test.steps.count + test.steps.each do |step| + testcase = testsuite.add_element 'testcase' + testcase.attributes['name'] = step.command_short + testcase.attributes['status'] = step.status + testcase.attributes['time'] = step.time + failure = testcase.add_element 'failure' if step.failed? + if step.has_output? + # Remove invalid XML CData characters from step output. + output = step.output + if output.respond_to?(:force_encoding) && !output.valid_encoding? + output.force_encoding(Encoding::UTF_8) + end + output = REXML::CData.new output.delete("\000\a\b\e\f") + if step.passed? + system_out = testcase.add_element 'system-out' + system_out.text = output + else + failure.attributes["message"] = "#{step.status}: #{step.command.join(" ")}" + failure.text = output + end + end + end + end + + open("brew-test-bot.xml", "w") do |xml_file| + pretty_print_indent = 2 + xml_document.write(xml_file, pretty_print_indent) + end + end + + if ARGV.include? "--email" + failed_steps = [] + tests.each do |test| + test.steps.each do |step| + next unless step.failed? + failed_steps << step.command_short + end + end + + if failed_steps.empty? + email_subject = '' + else + email_subject = "#{MacOS.version}: #{failed_steps.join ', '}." + end + + File.open EMAIL_SUBJECT_FILE, 'w' do |file| + file.write email_subject + end + end + + safe_system "rm -rf #{HOMEBREW_CACHE}/*" if ARGV.include? "--clean-cache" + + Homebrew.failed = any_errors + end +end
true
Other
Homebrew
brew
bd8559c791e7bc37c17a0f270e9b0f98e89d7a8a.json
brew: add contributed tap commands to PATH. This means that taps root and `cmd` directories are added to the PATH. This should enable migration of some of our contributed commands into taps (e.g. `homebrew-boneyard`) and make it easy for third parties to be able to maintain these. It might also make stuff easier for existing tools like e.g. `brew-cask` and `boxen`. Closes Homebrew/homebrew#32471.
Library/brew.rb
@@ -109,6 +109,9 @@ def require? path # Add contributed commands to PATH before checking. ENV['PATH'] += "#{File::PATH_SEPARATOR}#{HOMEBREW_CONTRIB}/cmd" + Dir["#{HOMEBREW_LIBRARY}/Taps/*/*/cmd"].each do |tap_cmd_dir| + ENV["PATH"] += "#{File::PATH_SEPARATOR}#{tap_cmd_dir}" + end internal_cmd = require? HOMEBREW_LIBRARY_PATH.join("cmd", cmd) if cmd
false
Other
Homebrew
brew
892d7dc130a6cf88600b71a388f32b9f27874e5c.json
Simplify unbrewed file whitelists Only the keys of the hashes are used, so we can just use arrays and comments instead.
Library/Homebrew/cmd/doctor.rb
@@ -108,9 +108,8 @@ def __check_stray_files(dir, pattern, white_list, message) Dir[pattern].select { |f| File.file?(f) && !File.symlink?(f) } } - keys = white_list.keys bad = files.reject { |file| - keys.any? { |pat| File.fnmatch?(pat, file) } + white_list.any? { |pat| File.fnmatch?(pat, file) } } bad.map! { |file| File.join(dir, file) } @@ -121,12 +120,12 @@ def __check_stray_files(dir, pattern, white_list, message) def check_for_stray_dylibs # Dylibs which are generally OK should be added to this list, # with a short description of the software they come with. - white_list = { - "libfuse.2.dylib" => "MacFuse", - "libfuse_ino64.2.dylib" => "MacFuse", - "libosxfuse_i32.2.dylib" => "OSXFuse", - "libosxfuse_i64.2.dylib" => "OSXFuse", - } + white_list = [ + "libfuse.2.dylib", # MacFuse + "libfuse_ino64.2.dylib", # MacFuse + "libosxfuse_i32.2.dylib", # OSXFuse + "libosxfuse_i64.2.dylib", # OSXFuse + ] __check_stray_files "/usr/local/lib", "*.dylib", white_list, <<-EOS.undent Unbrewed dylibs were found in /usr/local/lib. @@ -140,10 +139,10 @@ def check_for_stray_dylibs def check_for_stray_static_libs # Static libs which are generally OK should be added to this list, # with a short description of the software they come with. - white_list = { - "libsecurity_agent_client.a" => "OS X 10.8.2 Supplemental Update", - "libsecurity_agent_server.a" => "OS X 10.8.2 Supplemental Update" - } + white_list = [ + "libsecurity_agent_client.a", # OS X 10.8.2 Supplemental Update + "libsecurity_agent_server.a", # OS X 10.8.2 Supplemental Update + ] __check_stray_files "/usr/local/lib", "*.a", white_list, <<-EOS.undent Unbrewed static libraries were found in /usr/local/lib. @@ -157,9 +156,9 @@ def check_for_stray_static_libs def check_for_stray_pcs # Package-config files which are generally OK should be added to this list, # with a short description of the software they come with. - white_list = { - "osxfuse.pc" => "OSXFuse", - } + white_list = [ + "osxfuse.pc", # OSXFuse + ] __check_stray_files "/usr/local/lib/pkgconfig", "*.pc", white_list, <<-EOS.undent Unbrewed .pc files were found in /usr/local/lib/pkgconfig. @@ -171,12 +170,12 @@ def check_for_stray_pcs end def check_for_stray_las - white_list = { - "libfuse.la" => "MacFuse", - "libfuse_ino64.la" => "MacFuse", - "libosxfuse_i32.la" => "OSXFuse", - "libosxfuse_i64.la" => "OSXFuse", - } + white_list = [ + "libfuse.la", # MacFuse + "libfuse_ino64.la", # MacFuse + "libosxfuse_i32.la", # OSXFuse + "libosxfuse_i64.la", # OSXFuse + ] __check_stray_files "/usr/local/lib", "*.la", white_list, <<-EOS.undent Unbrewed .la files were found in /usr/local/lib. @@ -188,9 +187,9 @@ def check_for_stray_las end def check_for_stray_headers - white_list = { - "osxfuse/*" => "OSXFuse", - } + white_list = [ + "osxfuse/*", # OSXFuse + ] __check_stray_files "/usr/local/include", "**/*.h", white_list, <<-EOS.undent Unbrewed header files were found in /usr/local/include.
false