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
4f95f7ff84eb6a65b4b6d08af90d1e40e2ccb4fe.json
tests: add cmd/irb integration test (#501)
Library/Homebrew/test/test_integration_cmds.rb
@@ -690,4 +690,20 @@ def test_unlink cmd("install", "testball") assert_match "Would remove", cmd("unlink", "--dry-run", "testball") end + + def test_irb + assert_match "'v8'.f # => instance of the v8 formula", + cmd("irb", "--examples") + + setup_test_formula "testball" + + irb_test = HOMEBREW_TEMP/"irb-test.rb" + irb_test.write <<-EOS.undent + "testball".f + :testball.f + exit + EOS + + assert_match "Interactive Homebrew Shell", cmd("irb", irb_test) + end end
false
Other
Homebrew
brew
5768e32ad20208e8c5c1029ef2c9b47abd2caa2d.json
test-bot: fix coverage on Travis CI Make sure to call `brew tests` only once with `--coverage` to avoid expensive multiple runs and to prevent later runs from overwriting previously sent results to Coveralls. (The previous setup overwrote the results from a regular run with results from the `--generic` run.) The `--no-compat` variant without any other options specified seemed to be the most appropriate for a coverage report. Closes #546. Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
Library/Homebrew/dev-cmd/test-bot.rb
@@ -659,14 +659,15 @@ def homebrew if @tap.nil? tests_args = [] + tests_args_coverage = [] if RUBY_TWO tests_args << "--official-cmd-taps" - tests_args << "--coverage" if ENV["TRAVIS"] + tests_args_coverage << "--coverage" if ENV["TRAVIS"] end test "brew", "tests", *tests_args test "brew", "tests", "--generic", "--only=integration_cmds", *tests_args - test "brew", "tests", "--no-compat" + test "brew", "tests", "--no-compat", *tests_args_coverage test "brew", "readall", "--syntax" # test update from origin/master to current commit. test "brew", "update-test"
false
Other
Homebrew
brew
d7ee54129310de2b8b4989e6a47607fd1fb7db6c.json
reinstall: handle new options Since we are loading options as Formula#build from tab, we will have to explicitly read options from ARGV as well. Fixes #3066. Closes #537. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/cmd/reinstall.rb
@@ -11,7 +11,8 @@ def reinstall end def reinstall_formula(f) - options = f.build.used_options + options = BuildOptions.new(Options.create(ARGV.flags_only), f.options).used_options + options |= f.build.used_options notice = "Reinstalling #{f.full_name}" notice += " with #{options * ", "}" unless options.empty?
false
Other
Homebrew
brew
820b6347b8731faed631e4cef8e4e90a52d33501.json
remove unnecessary `Tab.for_formula` We already loaded tab in ARGV.resolved_formulae or Formulary.from_rack
Library/Homebrew/cmd/leaves.rb
@@ -12,11 +12,10 @@ def leaves installed.each do |f| deps = [] - tab = Tab.for_formula(f) f.deps.each do |dep| if dep.optional? || dep.recommended? - deps << dep.to_formula.full_name if tab.with?(dep) + deps << dep.to_formula.full_name if f.build.with?(dep) else deps << dep.to_formula.full_name end
true
Other
Homebrew
brew
820b6347b8731faed631e4cef8e4e90a52d33501.json
remove unnecessary `Tab.for_formula` We already loaded tab in ARGV.resolved_formulae or Formulary.from_rack
Library/Homebrew/cmd/reinstall.rb
@@ -11,8 +11,7 @@ def reinstall end def reinstall_formula(f) - tab = Tab.for_formula(f) - options = tab.used_options | f.build.used_options + options = f.build.used_options notice = "Reinstalling #{f.full_name}" notice += " with #{options * ", "}" unless options.empty? @@ -25,7 +24,7 @@ def reinstall_formula(f) fi = FormulaInstaller.new(f) fi.options = options - fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && tab.build_bottle?) + fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && f.build.build_bottle?) fi.build_from_source = ARGV.build_from_source? || ARGV.build_all_from_source? fi.force_bottle = ARGV.force_bottle? fi.interactive = ARGV.interactive?
true
Other
Homebrew
brew
820b6347b8731faed631e4cef8e4e90a52d33501.json
remove unnecessary `Tab.for_formula` We already loaded tab in ARGV.resolved_formulae or Formulary.from_rack
Library/Homebrew/cmd/upgrade.rb
@@ -66,11 +66,10 @@ def upgrade_pinned? def upgrade_formula(f) outdated_keg = Keg.new(f.linked_keg.resolved_path) if f.linked_keg.directory? - tab = Tab.for_formula(f) fi = FormulaInstaller.new(f) - fi.options = tab.used_options - fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && tab.build_bottle?) + fi.options = f.build.used_options + fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && f.build.build_bottle?) fi.build_from_source = ARGV.build_from_source? || ARGV.build_all_from_source? fi.verbose = ARGV.verbose? fi.quieter = ARGV.quieter?
true
Other
Homebrew
brew
91a47a9ed6d85c1bf8f507cdfef4462a07f61831.json
LinkageChecker: simplify logic (#538) BuiltOptions#without? already handles the option_names for dependencies. Also check disabled recommended deps.
Library/Homebrew/os/mac/linkage_checker.rb
@@ -53,7 +53,8 @@ def check_dylibs def check_undeclared_deps filter_out = proc do |dep| next true if dep.build? - dep.optional? && !dep.option_names.any? { |n| formula.build.with?(n) } + next false unless dep.optional? || dep.recommended? + formula.build.without?(dep) end declared_deps = formula.deps.reject { |dep| filter_out.call(dep) }.map(&:name) declared_requirement_deps = formula.requirements.reject { |req| filter_out.call(req) }.map(&:default_formula).compact
false
Other
Homebrew
brew
a59d346fcff9245db811f8d30f1871d0dc0e549e.json
xcode: track prerelease releases
Library/Homebrew/os/mac/xcode.rb
@@ -27,6 +27,11 @@ def latest_version end end + def prerelease? + # TODO: bump to version >= "8.1" after Xcode 8.0 is stable. + version > "7.3.1" + end + def outdated? version < latest_version end
false
Other
Homebrew
brew
2633f888d40314dee794dfba614c6e42f97f8c8a.json
extend/ARGV: avoid assignment in argument list Aside from being bad style, this also assigns to an unused variable.
Library/Homebrew/extend/ARGV.rb
@@ -29,14 +29,14 @@ def resolved_formulae f = Formulary.factory(name, spec) if f.any_version_installed? tab = Tab.for_formula(f) - resolved_spec = spec(default=nil) || tab.spec + resolved_spec = spec(nil) || tab.spec f.set_active_spec(resolved_spec) if f.send(resolved_spec) f.build = tab end f else rack = Formulary.to_rack(name) - Formulary.from_rack(rack, spec(default=nil)) + Formulary.from_rack(rack, spec(nil)) end end end
false
Other
Homebrew
brew
b51283424321cb996d0a587e9a62a070d21f3342.json
audit: prevent crash from nil exitstatus (#532) If rubocop invocation from brew audit exits with nil exitstatus, brew audit fails with 'undefined method `>' for nil:NilClass'.
Library/Homebrew/cmd/style.rb
@@ -63,8 +63,10 @@ def check_style_impl(files, output_type, options = {}) !$?.success? when :json json = Utils.popen_read_text("rubocop", "--format", "json", *args) - # exit status of 1 just means violations were found; others are errors - raise "Error while running rubocop" if $?.exitstatus > 1 + # exit status of 1 just means violations were found; other numbers mean execution errors + # exitstatus can also be nil if RuboCop process crashes, e.g. due to + # native extension problems + raise "Error while running RuboCop" if $?.exitstatus.nil? || $?.exitstatus > 1 RubocopResults.new(Utils::JSON.load(json)) else raise "Invalid output_type for check_style_impl: #{output_type}"
false
Other
Homebrew
brew
242508fca4d2b167cef3c355722f3471594d7b4b.json
software_spec: use version dups for resources (#534) Also prevent the commit of formula's HeadVersion from passing to the resource. This is a fix of #531
Library/Homebrew/software_spec.rb
@@ -53,7 +53,7 @@ def owner=(owner) @resource.owner = self resources.each_value do |r| r.owner = self - r.version ||= version + r.version ||= (version.head? ? Version.create("HEAD") : version.dup) end patches.each { |p| p.owner = self } end
false
Other
Homebrew
brew
3fb5d70a729472a7d7f2a5d0d7b84248921fb583.json
Unify Version.create usage Substitue each Version.new and HeadVersion.new with Version.create to unify Version and HeadVersion instantiation among core code. Note that this does not relate to Mac::OS::Version class.
Library/Homebrew/cmd/audit.rb
@@ -606,7 +606,7 @@ def audit_specs case stable && stable.url when %r{download\.gnome\.org/sources}, %r{ftp\.gnome\.org/pub/GNOME/sources}i version = Version.parse(stable.url) - if version >= Version.new("1.0") + if version >= Version.create("1.0") minor_version = version.to_s.split(".", 3)[1].to_i if minor_version.odd? problem "#{stable.version} is a development release"
true
Other
Homebrew
brew
3fb5d70a729472a7d7f2a5d0d7b84248921fb583.json
Unify Version.create usage Substitue each Version.new and HeadVersion.new with Version.create to unify Version and HeadVersion instantiation among core code. Note that this does not relate to Mac::OS::Version class.
Library/Homebrew/cmd/create.rb
@@ -116,7 +116,7 @@ def url=(url) end update_path if @version - @version = Version.new(@version) + @version = Version.create(@version) else @version = Pathname.new(url).version end
true
Other
Homebrew
brew
3fb5d70a729472a7d7f2a5d0d7b84248921fb583.json
Unify Version.create usage Substitue each Version.new and HeadVersion.new with Version.create to unify Version and HeadVersion instantiation among core code. Note that this does not relate to Mac::OS::Version class.
Library/Homebrew/cmd/pull.rb
@@ -441,7 +441,7 @@ def any_bottle_tag def version(spec_type) version_str = info["versions"][spec_type.to_s] - version_str && Version.new(version_str) + version_str && Version.create(version_str) end def pkg_version(spec_type = :stable)
true
Other
Homebrew
brew
3fb5d70a729472a7d7f2a5d0d7b84248921fb583.json
Unify Version.create usage Substitue each Version.new and HeadVersion.new with Version.create to unify Version and HeadVersion instantiation among core code. Note that this does not relate to Mac::OS::Version class.
Library/Homebrew/diagnostic.rb
@@ -761,7 +761,7 @@ def check_filesystem_case_sensitive def check_git_version # https://help.github.com/articles/https-cloning-errors return unless Utils.git_available? - return unless Version.new(Utils.git_version) < Version.new("1.7.10") + return unless Version.create(Utils.git_version) < Version.create("1.7.10") git = Formula["git"] git_upgrade_cmd = git.any_version_installed? ? "upgrade" : "install"
true
Other
Homebrew
brew
3fb5d70a729472a7d7f2a5d0d7b84248921fb583.json
Unify Version.create usage Substitue each Version.new and HeadVersion.new with Version.create to unify Version and HeadVersion instantiation among core code. Note that this does not relate to Mac::OS::Version class.
Library/Homebrew/extend/ENV/shared.rb
@@ -325,6 +325,6 @@ def check_for_compiler_universal_support def gcc_with_cxx11_support?(cc) version = cc[/^gcc-(\d+(?:\.\d+)?)$/, 1] - version && Version.new(version) >= Version.new("4.8") + version && Version.create(version) >= Version.create("4.8") end end
true
Other
Homebrew
brew
3fb5d70a729472a7d7f2a5d0d7b84248921fb583.json
Unify Version.create usage Substitue each Version.new and HeadVersion.new with Version.create to unify Version and HeadVersion instantiation among core code. Note that this does not relate to Mac::OS::Version class.
Library/Homebrew/extend/os/mac/diagnostic.rb
@@ -287,8 +287,8 @@ def check_for_latest_xquartz return unless MacOS::XQuartz.version return if MacOS::XQuartz.provided_by_apple? - installed_version = Version.new(MacOS::XQuartz.version) - latest_version = Version.new(MacOS::XQuartz.latest_version) + installed_version = Version.create(MacOS::XQuartz.version) + latest_version = Version.create(MacOS::XQuartz.latest_version) return if installed_version >= latest_version <<-EOS.undent
true
Other
Homebrew
brew
3fb5d70a729472a7d7f2a5d0d7b84248921fb583.json
Unify Version.create usage Substitue each Version.new and HeadVersion.new with Version.create to unify Version and HeadVersion instantiation among core code. Note that this does not relate to Mac::OS::Version class.
Library/Homebrew/formula.rb
@@ -1326,7 +1326,7 @@ def to_hash } end - hsh["installed"] = hsh["installed"].sort_by { |i| Version.new(i["version"]) } + hsh["installed"] = hsh["installed"].sort_by { |i| Version.create(i["version"]) } hsh end
true
Other
Homebrew
brew
3fb5d70a729472a7d7f2a5d0d7b84248921fb583.json
Unify Version.create usage Substitue each Version.new and HeadVersion.new with Version.create to unify Version and HeadVersion instantiation among core code. Note that this does not relate to Mac::OS::Version class.
Library/Homebrew/language/python.rb
@@ -5,7 +5,7 @@ module Python def self.major_minor_version(python) version = /\d\.\d/.match `#{python} --version 2>&1` return unless version - Version.new(version.to_s) + Version.create(version.to_s) end def self.homebrew_site_packages(version = "2.7")
true
Other
Homebrew
brew
3fb5d70a729472a7d7f2a5d0d7b84248921fb583.json
Unify Version.create usage Substitue each Version.new and HeadVersion.new with Version.create to unify Version and HeadVersion instantiation among core code. Note that this does not relate to Mac::OS::Version class.
Library/Homebrew/requirements/emacs_requirement.rb
@@ -11,7 +11,7 @@ def initialize(tags) next false unless which "emacs" next true unless @version emacs_version = Utils.popen_read("emacs", "--batch", "--eval", "(princ emacs-version)") - Version.new(emacs_version) >= Version.new(@version) + Version.create(emacs_version) >= Version.create(@version) end env do
true
Other
Homebrew
brew
3fb5d70a729472a7d7f2a5d0d7b84248921fb583.json
Unify Version.create usage Substitue each Version.new and HeadVersion.new with Version.create to unify Version and HeadVersion instantiation among core code. Note that this does not relate to Mac::OS::Version class.
Library/Homebrew/requirements/perl_requirement.rb
@@ -12,7 +12,7 @@ def initialize(tags) which_all("perl").detect do |perl| perl_version = Utils.popen_read(perl, "--version")[/\(v(\d+\.\d+)(?:\.\d+)?\)/, 1] next unless perl_version - Version.new(perl_version.to_s) >= Version.new(@version) + Version.create(perl_version.to_s) >= Version.create(@version) end end
true
Other
Homebrew
brew
3fb5d70a729472a7d7f2a5d0d7b84248921fb583.json
Unify Version.create usage Substitue each Version.new and HeadVersion.new with Version.create to unify Version and HeadVersion instantiation among core code. Note that this does not relate to Mac::OS::Version class.
Library/Homebrew/requirements/python_requirement.rb
@@ -11,16 +11,16 @@ class PythonRequirement < Requirement version = python_short_version next unless version # Always use Python 2.7 for consistency on older versions of OSX. - version == Version.new("2.7") + version == Version.create("2.7") end env do short_version = python_short_version - if !system_python? && short_version == Version.new("2.7") + if !system_python? && short_version == Version.create("2.7") ENV.prepend_path "PATH", which_python.dirname # Homebrew Python should take precedence over older Pythons in the PATH - elsif short_version != Version.new("2.7") + elsif short_version != Version.create("2.7") ENV.prepend_path "PATH", Formula["python"].opt_bin end
true
Other
Homebrew
brew
3fb5d70a729472a7d7f2a5d0d7b84248921fb583.json
Unify Version.create usage Substitue each Version.new and HeadVersion.new with Version.create to unify Version and HeadVersion instantiation among core code. Note that this does not relate to Mac::OS::Version class.
Library/Homebrew/requirements/ruby_requirement.rb
@@ -12,7 +12,7 @@ def initialize(tags) which_all("ruby").detect do |ruby| version = /\d\.\d/.match Utils.popen_read(ruby, "--version") next unless version - Version.new(version.to_s) >= Version.new(@version) + Version.create(version.to_s) >= Version.create(@version) end end
true
Other
Homebrew
brew
3fb5d70a729472a7d7f2a5d0d7b84248921fb583.json
Unify Version.create usage Substitue each Version.new and HeadVersion.new with Version.create to unify Version and HeadVersion instantiation among core code. Note that this does not relate to Mac::OS::Version class.
Library/Homebrew/requirements/x11_requirement.rb
@@ -13,17 +13,17 @@ class X11Requirement < Requirement def initialize(name = "x11", tags = []) @name = name if /(\d\.)+\d/ === tags.first - @min_version = Version.new(tags.shift) + @min_version = Version.create(tags.shift) @min_version_string = " #{@min_version}" else - @min_version = Version.new("0.0.0") + @min_version = Version.create("0.0.0") @min_version_string = "" end super(tags) end satisfy :build_env => false do - MacOS::XQuartz.installed? && min_version <= Version.new(MacOS::XQuartz.version) + MacOS::XQuartz.installed? && min_version <= Version.create(MacOS::XQuartz.version) end def message
true
Other
Homebrew
brew
3fb5d70a729472a7d7f2a5d0d7b84248921fb583.json
Unify Version.create usage Substitue each Version.new and HeadVersion.new with Version.create to unify Version and HeadVersion instantiation among core code. Note that this does not relate to Mac::OS::Version class.
Library/Homebrew/software_spec.rb
@@ -204,7 +204,7 @@ def add_dep_option(dep) class HeadSoftwareSpec < SoftwareSpec def initialize super - @resource.version = HeadVersion.new("HEAD") + @resource.version = Version.create("HEAD") end def verify_download_integrity(_fn)
true
Other
Homebrew
brew
3fb5d70a729472a7d7f2a5d0d7b84248921fb583.json
Unify Version.create usage Substitue each Version.new and HeadVersion.new with Version.create to unify Version and HeadVersion instantiation among core code. Note that this does not relate to Mac::OS::Version class.
Library/Homebrew/test/test_pkg_version.rb
@@ -7,12 +7,12 @@ def v(version) end def test_parse - assert_equal PkgVersion.new(Version.new("1.0"), 1), PkgVersion.parse("1.0_1") - assert_equal PkgVersion.new(Version.new("1.0"), 1), PkgVersion.parse("1.0_1") - assert_equal PkgVersion.new(Version.new("1.0"), 0), PkgVersion.parse("1.0") - assert_equal PkgVersion.new(Version.new("1.0"), 0), PkgVersion.parse("1.0_0") - assert_equal PkgVersion.new(Version.new("2.1.4"), 0), PkgVersion.parse("2.1.4_0") - assert_equal PkgVersion.new(Version.new("1.0.1e"), 1), PkgVersion.parse("1.0.1e_1") + assert_equal PkgVersion.new(Version.create("1.0"), 1), PkgVersion.parse("1.0_1") + assert_equal PkgVersion.new(Version.create("1.0"), 1), PkgVersion.parse("1.0_1") + assert_equal PkgVersion.new(Version.create("1.0"), 0), PkgVersion.parse("1.0") + assert_equal PkgVersion.new(Version.create("1.0"), 0), PkgVersion.parse("1.0_0") + assert_equal PkgVersion.new(Version.create("2.1.4"), 0), PkgVersion.parse("2.1.4_0") + assert_equal PkgVersion.new(Version.create("1.0.1e"), 1), PkgVersion.parse("1.0.1e_1") end def test_comparison @@ -24,26 +24,26 @@ def test_comparison assert_operator v("HEAD"), :>, v("1.0") assert_operator v("1.0"), :<, v("HEAD") - v = PkgVersion.new(Version.new("1.0"), 0) + v = PkgVersion.new(Version.create("1.0"), 0) assert_nil v <=> Object.new assert_raises(ArgumentError) { v > Object.new } - assert_raises(ArgumentError) { v > Version.new("1.0") } + assert_raises(ArgumentError) { v > Version.create("1.0") } end def test_to_s - assert_equal "1.0", PkgVersion.new(Version.new("1.0"), 0).to_s - assert_equal "1.0_1", PkgVersion.new(Version.new("1.0"), 1).to_s - assert_equal "1.0", PkgVersion.new(Version.new("1.0"), 0).to_s - assert_equal "1.0", PkgVersion.new(Version.new("1.0"), 0).to_s + assert_equal "1.0", PkgVersion.new(Version.create("1.0"), 0).to_s + assert_equal "1.0_1", PkgVersion.new(Version.create("1.0"), 1).to_s + assert_equal "1.0", PkgVersion.new(Version.create("1.0"), 0).to_s + assert_equal "1.0", PkgVersion.new(Version.create("1.0"), 0).to_s assert_equal "HEAD_1", PkgVersion.new(Version.create("HEAD"), 1).to_s assert_equal "HEAD-ffffff_1", PkgVersion.new(Version.create("HEAD-ffffff"), 1).to_s end def test_hash - p1 = PkgVersion.new(Version.new("1.0"), 1) - p2 = PkgVersion.new(Version.new("1.0"), 1) - p3 = PkgVersion.new(Version.new("1.1"), 1) - p4 = PkgVersion.new(Version.new("1.0"), 0) + p1 = PkgVersion.new(Version.create("1.0"), 1) + p2 = PkgVersion.new(Version.create("1.0"), 1) + p3 = PkgVersion.new(Version.create("1.1"), 1) + p4 = PkgVersion.new(Version.create("1.0"), 0) assert_equal p1.hash, p2.hash refute_equal p1.hash, p3.hash refute_equal p1.hash, p4.hash
true
Other
Homebrew
brew
3fb5d70a729472a7d7f2a5d0d7b84248921fb583.json
Unify Version.create usage Substitue each Version.new and HeadVersion.new with Version.create to unify Version and HeadVersion instantiation among core code. Note that this does not relate to Mac::OS::Version class.
Library/Homebrew/test/test_version_subclasses.rb
@@ -34,10 +34,10 @@ def test_compare_with_string end def test_compare_with_version - assert_operator @v, :>, Version.new("10.6") - assert_operator @v, :==, Version.new("10.7") - assert_operator @v, :===, Version.new("10.7") - assert_operator @v, :<, Version.new("10.8") + assert_operator @v, :>, Version.create("10.6") + assert_operator @v, :==, Version.create("10.7") + assert_operator @v, :===, Version.create("10.7") + assert_operator @v, :<, Version.create("10.8") end def test_from_symbol
true
Other
Homebrew
brew
3fb5d70a729472a7d7f2a5d0d7b84248921fb583.json
Unify Version.create usage Substitue each Version.new and HeadVersion.new with Version.create to unify Version and HeadVersion instantiation among core code. Note that this does not relate to Mac::OS::Version class.
Library/Homebrew/test/test_versions.rb
@@ -4,17 +4,17 @@ class VersionTests < Homebrew::TestCase def test_accepts_objects_responding_to_to_str value = stub(:to_str => "0.1") - assert_equal "0.1", Version.new(value).to_s + assert_equal "0.1", Version.create(value).to_s end def test_raises_for_non_string_objects - assert_raises(TypeError) { Version.new(1.1) } - assert_raises(TypeError) { Version.new(1) } - assert_raises(TypeError) { Version.new(:symbol) } + assert_raises(TypeError) { Version.create(1.1) } + assert_raises(TypeError) { Version.create(1) } + assert_raises(TypeError) { Version.create(:symbol) } end def test_detected_from_url? - refute Version.new("1.0").detected_from_url? + refute Version.create("1.0").detected_from_url? assert Version::FromURL.new("1.0").detected_from_url? end end @@ -462,20 +462,20 @@ def test_create_head end def test_commit_assigned - v = HeadVersion.new("HEAD-abcdef") + v = Version.create("HEAD-abcdef") assert_equal "abcdef", v.commit assert_equal "HEAD-abcdef", v.to_str end def test_no_commit - v = HeadVersion.new("HEAD") + v = Version.create("HEAD") assert_nil v.commit assert_equal "HEAD", v.to_str end def test_update_commit - v1 = HeadVersion.new("HEAD-abcdef") - v2 = HeadVersion.new("HEAD") + v1 = Version.create("HEAD-abcdef") + v2 = Version.create("HEAD") v1.update_commit("ffffff") assert_equal "ffffff", v1.commit
true
Other
Homebrew
brew
3fb5d70a729472a7d7f2a5d0d7b84248921fb583.json
Unify Version.create usage Substitue each Version.new and HeadVersion.new with Version.create to unify Version and HeadVersion instantiation among core code. Note that this does not relate to Mac::OS::Version class.
Library/Homebrew/test/testing_env.rb
@@ -27,7 +27,7 @@ def version(v) end def assert_version_equal(expected, actual) - assert_equal Version.new(expected), actual + assert_equal Version.create(expected), actual end def assert_version_detected(expected, url, specs={})
true
Other
Homebrew
brew
454003c4c1ea43f4fd84db96017636fc4c50b318.json
test_formula: test new HEAD methods * Test `Formula#update_head_version` * Test `Formula#latest_head_prefix`
Library/Homebrew/test/test_formula.rb
@@ -158,6 +158,29 @@ def test_installed_prefix_devel assert_equal prefix, f.installed_prefix end + def test_latest_head_prefix + f = Testball.new + + stamps_with_revisions = [[111111, 1], [222222, 1], [222222, 2], [222222, 0]] + + stamps_with_revisions.each do |stamp, revision| + version = "HEAD-#{stamp}" + version += "_#{revision}" if revision > 0 + prefix = f.rack.join(version) + prefix.mkpath + + tab = Tab.empty + tab.tabfile = prefix.join("INSTALL_RECEIPT.json") + tab.source_modified_time = stamp + tab.write + end + + prefix = HOMEBREW_CELLAR/"#{f.name}/HEAD-222222_2" + assert_equal prefix, f.latest_head_prefix + ensure + f.rack.rmtree + end + def test_equality x = Testball.new y = Testball.new @@ -282,6 +305,38 @@ def test_head_uses_revisions assert_equal PkgVersion.parse("HEAD_1"), f.pkg_version end + def test_update_head_version + initial_env = ENV.to_hash + + f = formula do + head "foo", :using => :git + end + + cached_location = f.head.downloader.cached_location + cached_location.mkpath + + %w[AUTHOR COMMITTER].each do |role| + ENV["GIT_#{role}_NAME"] = "brew tests" + ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" + ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" + end + + cached_location.cd do + FileUtils.touch "LICENSE" + shutup do + system "git", "init" + system "git", "add", "--all" + system "git", "commit", "-m", "Initial commit" + end + end + + f.update_head_version + assert_equal Version.create("HEAD-5658946"), f.head.version + ensure + ENV.replace(initial_env) + cached_location.rmtree + end + def test_legacy_options f = formula do url "foo-1.0"
false
Other
Homebrew
brew
458f9a008cc5316de9ec18ebae3b0f3990583540.json
Apply tests to new HEAD format
Library/Homebrew/test/test_formula.rb
@@ -272,14 +272,14 @@ def test_version_with_revision assert_equal PkgVersion.parse("1.0_1"), f.pkg_version end - def test_head_ignores_revisions + def test_head_uses_revisions f = formula("test", Pathname.new(__FILE__).expand_path, :head) do url "foo-1.0.bar" revision 1 head "foo" end - assert_equal PkgVersion.parse("HEAD"), f.pkg_version + assert_equal PkgVersion.parse("HEAD_1"), f.pkg_version end def test_legacy_options
true
Other
Homebrew
brew
458f9a008cc5316de9ec18ebae3b0f3990583540.json
Apply tests to new HEAD format
Library/Homebrew/test/test_pkg_version.rb
@@ -35,7 +35,8 @@ def test_to_s assert_equal "1.0_1", PkgVersion.new(Version.new("1.0"), 1).to_s assert_equal "1.0", PkgVersion.new(Version.new("1.0"), 0).to_s assert_equal "1.0", PkgVersion.new(Version.new("1.0"), 0).to_s - assert_equal "HEAD", PkgVersion.new(Version.new("HEAD"), 1).to_s + assert_equal "HEAD_1", PkgVersion.new(Version.create("HEAD"), 1).to_s + assert_equal "HEAD-ffffff_1", PkgVersion.new(Version.create("HEAD-ffffff"), 1).to_s end def test_hash
true
Other
Homebrew
brew
00cdd5f481d409b1874b95c7f149c717ffb0259f.json
Add HeadVersion tests
Library/Homebrew/test/test_versions.rb
@@ -55,7 +55,11 @@ def test_comparing_regular_versions def test_HEAD assert_operator version("HEAD"), :>, version("1.2.3") + assert_operator version("HEAD-abcdef"), :>, version("1.2.3") assert_operator version("1.2.3"), :<, version("HEAD") + assert_operator version("1.2.3"), :<, version("HEAD-fedcba") + assert_operator version("HEAD-abcdef"), :==, version("HEAD-fedcba") + assert_operator version("HEAD"), :==, version("HEAD-fedcba") end def test_comparing_alpha_versions @@ -156,6 +160,12 @@ def test_no_version assert_version_nil "foo" end + def test_create + v = Version.create("1.20") + refute_predicate v, :head? + assert_equal "1.20", v.to_str + end + def test_version_all_dots assert_version_detected "1.14", "http://example.com/foo.bar.la.1.14.zip" end @@ -441,3 +451,38 @@ def test_from_url "http://github.com/foo/bar.git", {:tag => "v1.2.3"} end end + +class HeadVersionTests < Homebrew::TestCase + def test_create_head + v1 = Version.create("HEAD-abcdef") + v2 = Version.create("HEAD") + + assert_predicate v1, :head? + assert_predicate v2, :head? + end + + def test_commit_assigned + v = HeadVersion.new("HEAD-abcdef") + assert_equal "abcdef", v.commit + assert_equal "HEAD-abcdef", v.to_str + end + + def test_no_commit + v = HeadVersion.new("HEAD") + assert_nil v.commit + assert_equal "HEAD", v.to_str + end + + def test_update_commit + v1 = HeadVersion.new("HEAD-abcdef") + v2 = HeadVersion.new("HEAD") + + v1.update_commit("ffffff") + assert_equal "ffffff", v1.commit + assert_equal "HEAD-ffffff", v1.to_str + + v2.update_commit("ffffff") + assert_equal "ffffff", v2.commit + assert_equal "HEAD-ffffff", v2.to_str + end +end
true
Other
Homebrew
brew
00cdd5f481d409b1874b95c7f149c717ffb0259f.json
Add HeadVersion tests
Library/Homebrew/test/testing_env.rb
@@ -23,7 +23,7 @@ module Homebrew module VersionAssertions def version(v) - Version.new(v) + Version.create(v) end def assert_version_equal(expected, actual)
true
Other
Homebrew
brew
2e916110e4c561b3e4175da099fc795e85ddb822.json
Use HeadVersion for install/reinstall
Library/Homebrew/download_strategy.rb
@@ -135,6 +135,8 @@ def fetch clone_repo end + version.update_commit(last_commit) if head? + if @ref_type == :tag && @revision && current_revision unless current_revision == @revision raise <<-EOS.undent
true
Other
Homebrew
brew
2e916110e4c561b3e4175da099fc795e85ddb822.json
Use HeadVersion for install/reinstall
Library/Homebrew/formula.rb
@@ -287,6 +287,14 @@ def version active_spec.version end + def update_head_version + return unless head? + return unless head.downloader.is_a?(VCSDownloadStrategy) + return unless head.downloader.cached_location.exist? + + head.version.update_commit(head.downloader.last_commit) + end + # The {PkgVersion} for this formula with {version} and {#revision} information. def pkg_version PkgVersion.new(version, revision) @@ -405,11 +413,23 @@ def linked_keg Pathname.new("#{HOMEBREW_LIBRARY}/LinkedKegs/#{name}") end + def latest_head_prefix + head_versions = installed_prefixes.map do |pn| + pn_pkgversion = PkgVersion.parse(pn.basename.to_s) + pn_pkgversion if pn_pkgversion.head? + end.compact + + latest_head_version = head_versions.max_by do |pn_pkgversion| + [Tab.for_keg(prefix(pn_pkgversion)).source_modified_time, pn_pkgversion.revision] + end + prefix(latest_head_version) if latest_head_version + end + # The latest prefix for this formula. Checks for {#head}, then {#devel} # and then {#stable}'s {#prefix} # @private def installed_prefix - if head && (head_prefix = prefix(PkgVersion.new(head.version, revision))).directory? + if head && (head_prefix = latest_head_prefix) && head_prefix.directory? head_prefix elsif devel && (devel_prefix = prefix(PkgVersion.new(devel.version, revision))).directory? devel_prefix
true
Other
Homebrew
brew
2e916110e4c561b3e4175da099fc795e85ddb822.json
Use HeadVersion for install/reinstall
Library/Homebrew/formula_installer.rb
@@ -586,13 +586,16 @@ def build end end + formula.update_head_version + if !formula.prefix.directory? || Keg.new(formula.prefix).empty_installation? raise "Empty installation" end rescue Exception ignore_interrupts do # any exceptions must leave us with nothing installed + formula.update_head_version formula.prefix.rmtree if formula.prefix.directory? formula.rack.rmdir_if_possible end
true
Other
Homebrew
brew
2e916110e4c561b3e4175da099fc795e85ddb822.json
Use HeadVersion for install/reinstall
Library/Homebrew/pkg_version.rb
@@ -5,6 +5,8 @@ class PkgVersion RX = /\A(.+?)(?:_(\d+))?\z/ + attr_reader :version, :revision + def self.parse(path) _, version, revision = *path.match(RX) version = Version.create(version) @@ -38,8 +40,4 @@ def <=>(other) def hash version.hash ^ revision.hash end - - protected - - attr_reader :version, :revision end
true
Other
Homebrew
brew
2e916110e4c561b3e4175da099fc795e85ddb822.json
Use HeadVersion for install/reinstall
Library/Homebrew/software_spec.rb
@@ -29,6 +29,7 @@ class SoftwareSpec def_delegators :@resource, :cached_download, :clear_cache def_delegators :@resource, :checksum, :mirrors, :specs, :using def_delegators :@resource, :version, :mirror, *Checksum::TYPES + def_delegators :@resource, :downloader def initialize @resource = Resource.new @@ -203,7 +204,7 @@ def add_dep_option(dep) class HeadSoftwareSpec < SoftwareSpec def initialize super - @resource.version = Version.new("HEAD") + @resource.version = HeadVersion.new("HEAD") end def verify_download_integrity(_fn)
true
Other
Homebrew
brew
8a968a0b60dbc78f9f48be76762c9f050fa6416d.json
resource: detect HEAD versions
Library/Homebrew/resource.rb
@@ -159,7 +159,7 @@ def detect_version(val) case val when nil then Version.detect(url, specs) - when String then Version.new(val) + when String then Version.create(val) when Version then val else raise TypeError, "version '#{val.inspect}' should be a string"
false
Other
Homebrew
brew
2b078be186dec5d56ef11e1fcca4927506756704.json
test-bot: remove Jenkins Git debugging.
Library/Homebrew/dev-cmd/test-bot.rb
@@ -262,7 +262,6 @@ def safe_formula_canonical_name(formula_name) end def git(*args) - puts "#{@repository}: git #{args.join " "}" if ENV["JENKINS_HOME"] @repository.cd { Utils.popen_read("git", *args) } end
false
Other
Homebrew
brew
b62a2c7e7f9fc7f45931b61d7a534a6d6b02f391.json
add more test Closes #514. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/test/test_formulary.rb
@@ -90,12 +90,17 @@ def test_factory_from_alias alias_dir.rmtree end - def test_factory_from_rack + def test_factory_from_rack_and_from_keg formula = Formulary.factory(@path) installer = FormulaInstaller.new(formula) shutup { installer.install } keg = Keg.new(formula.prefix) - assert_kind_of Formula, Formulary.from_rack(formula.rack) + f = Formulary.from_rack(formula.rack) + assert_kind_of Formula, f + assert_kind_of Tab, f.build + f = Formulary.from_keg(keg) + assert_kind_of Formula, f + assert_kind_of Tab, f.build ensure keg.unlink keg.uninstall
true
Other
Homebrew
brew
b62a2c7e7f9fc7f45931b61d7a534a6d6b02f391.json
add more test Closes #514. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/test/test_tab.rb
@@ -29,6 +29,9 @@ def test_defaults assert_empty tab.used_options refute_predicate tab, :built_as_bottle refute_predicate tab, :poured_from_bottle + assert_predicate tab, :stable? + refute_predicate tab, :devel? + refute_predicate tab, :head? assert_nil tab.tap assert_nil tab.time assert_nil tab.HEAD @@ -74,6 +77,9 @@ def test_from_old_version_file assert_equal @unused.sort, tab.unused_options.sort refute_predicate tab, :built_as_bottle assert_predicate tab, :poured_from_bottle + assert_predicate tab, :stable? + refute_predicate tab, :devel? + refute_predicate tab, :head? assert_equal "homebrew/core", tab.tap.name assert_equal :stable, tab.spec refute_nil tab.time @@ -90,6 +96,9 @@ def test_from_file assert_equal @unused.sort, tab.unused_options.sort refute_predicate tab, :built_as_bottle assert_predicate tab, :poured_from_bottle + assert_predicate tab, :stable? + refute_predicate tab, :devel? + refute_predicate tab, :head? assert_equal "homebrew/core", tab.tap.name assert_equal :stable, tab.spec refute_nil tab.time
true
Other
Homebrew
brew
30bbb93f2189be88c799bfdb257216909bcd3fde.json
tab: add missing methods This makes `Tab` compatible with `BuildOptions`.
Library/Homebrew/tab.rb
@@ -179,6 +179,18 @@ def build_32_bit? include?("32-bit") end + def head? + spec == :head + end + + def devel? + spec == :devel + end + + def stable? + spec == :stable + end + def used_options Options.create(super) end
false
Other
Homebrew
brew
706e7e71a07784f14abbdf5f019428e04afcfae6.json
mac/super: restore definition of effective_sysroot In https://github.com/Homebrew/brew/commit/0d189fae57bad6c209b471eba9e0b254a2b40886 we completely removed `effective_sysroot`, which consequently left all the `effective_sysroot`/usr/include calls pointing at `/usr/include`. This is wildly problematic on systems where the Command Line Tools aren't installed because `/usr/include` is not a default-created folder prior to CLT installation. I'm unsure if `effective_sysroot` should still be mentioned in Library/Homebrew/extend/ENV/super.rb at all. If it can be deleted, feel free to do that without waiting for me to review. This seems to fix: * https://github.com/Homebrew/homebrew-core/issues/2991 * https://github.com/Homebrew/homebrew-core/issues/2986 * https://github.com/Homebrew/homebrew-core/issues/2962
Library/Homebrew/extend/os/mac/extend/ENV/super.rb
@@ -7,6 +7,10 @@ def self.bin bin.realpath unless bin.nil? end + def effective_sysroot + MacOS::Xcode.without_clt? ? MacOS.sdk_path.to_s : nil + end + def homebrew_extra_paths paths = [] # On 10.9, there are shims for all tools in /usr/bin.
false
Other
Homebrew
brew
2a61c84be38866c5be788eebea932510608ba805.json
test-bot: handle inconsistent Jenkins GIT_URLs.
Library/Homebrew/dev-cmd/test-bot.rb
@@ -307,7 +307,7 @@ def diff_formulae(start_revision, end_revision, path, filter) elsif ENV["GIT_BRANCH"] && ENV["GIT_URL"] %r{origin/pr/(\d+)/(merge|head)} =~ ENV["GIT_BRANCH"] pr = $1 - @url = "#{ENV["GIT_URL"]}/pull/#{pr}" + @url = "#{ENV["GIT_URL"].chomp("/")}/pull/#{pr}" @hash = nil # Use Travis CI pull-request variables for pull request jobs. elsif travis_pr
false
Other
Homebrew
brew
b3ed00b791b5e95519b3a59a578a09dd084c44ab.json
test-bot: use another method to find Jenkins PR.
Library/Homebrew/dev-cmd/test-bot.rb
@@ -304,6 +304,11 @@ def diff_formulae(start_revision, end_revision, path, filter) @url = ENV["ghprbPullLink"] @hash = nil test "git", "checkout", "origin/master" + elsif ENV["GIT_BRANCH"] && ENV["GIT_URL"] + %r{origin/pr/(\d+)/(merge|head)} =~ ENV["GIT_BRANCH"] + pr = $1 + @url = "#{ENV["GIT_URL"]}/pull/#{pr}" + @hash = nil # Use Travis CI pull-request variables for pull request jobs. elsif travis_pr @url = "https://github.com/#{ENV["TRAVIS_REPO_SLUG"]}/pull/#{ENV["TRAVIS_PULL_REQUEST"]}"
false
Other
Homebrew
brew
13730a9dadde8570e41cf5599b4f5c940014f190.json
move LinkageChecker to standalone file
Library/Homebrew/dev-cmd/linkage.rb
@@ -12,126 +12,21 @@ # --reverse - For each dylib the keg references, print the dylib followed by the # binaries which link to it. -require "set" -require "keg" -require "formula" +require "os/mac/linkage_checker" module Homebrew def linkage - found_broken_dylibs = false ARGV.kegs.each do |keg| ohai "Checking #{keg.name} linkage" if ARGV.kegs.size > 1 result = LinkageChecker.new(keg) if ARGV.include?("--test") result.display_test_output + Homebrew.failed = true if result.broken_dylibs? elsif ARGV.include?("--reverse") result.display_reverse_output else result.display_normal_output end - found_broken_dylibs = true unless result.broken_dylibs.empty? - end - if ARGV.include?("--test") && found_broken_dylibs - exit 1 - end - end - - class LinkageChecker - attr_reader :keg - attr_reader :broken_dylibs - - def initialize(keg) - @keg = keg - @brewed_dylibs = Hash.new { |h, k| h[k] = Set.new } - @system_dylibs = Set.new - @broken_dylibs = Set.new - @variable_dylibs = Set.new - @reverse_links = Hash.new { |h, k| h[k] = Set.new } - check_dylibs - end - - def check_dylibs - @keg.find do |file| - next if file.symlink? || file.directory? - next unless file.dylib? || file.mach_o_executable? || file.mach_o_bundle? - file.dynamically_linked_libraries.each do |dylib| - @reverse_links[dylib] << file - if dylib.start_with? "@" - @variable_dylibs << dylib - else - begin - owner = Keg.for Pathname.new(dylib) - rescue NotAKegError - @system_dylibs << dylib - rescue Errno::ENOENT - @broken_dylibs << dylib - else - @brewed_dylibs[owner.name] << dylib - end - end - end - end - - begin - f = Formulary.from_rack(keg.rack) - f.build = Tab.for_keg(keg) - filter_out = proc do |dep| - dep.build? || (dep.optional? && !dep.option_names.any? { |n| f.build.with?(n) }) - end - declared_deps = f.deps.reject { |dep| filter_out.call(dep) }.map(&:name) + - f.requirements.reject { |req| filter_out.call(req) }.map(&:default_formula).compact - @undeclared_deps = @brewed_dylibs.keys - declared_deps.map { |dep| dep.split("/").last } - @undeclared_deps -= [f.name] - rescue FormulaUnavailableError - opoo "Formula unavailable: #{keg.name}" - @undeclared_deps = [] - end - end - - def display_normal_output - display_items "System libraries", @system_dylibs - display_items "Homebrew libraries", @brewed_dylibs - display_items "Variable-referenced libraries", @variable_dylibs - display_items "Missing libraries", @broken_dylibs - display_items "Possible undeclared dependencies", @undeclared_deps - end - - def display_reverse_output - return if @reverse_links.empty? - sorted = @reverse_links.sort - sorted.each do |dylib, files| - puts dylib - files.each do |f| - unprefixed = f.to_s.strip_prefix "#{@keg.to_s}/" - puts " #{unprefixed}" - end - puts unless dylib == sorted.last[0] - end - end - - def display_test_output - display_items "Missing libraries", @broken_dylibs - puts "No broken dylib links" if @broken_dylibs.empty? - end - - private - - # Display a list of things. - # Things may either be an array, or a hash of (label -> array) - def display_items(label, things) - return if things.empty? - puts "#{label}:" - if things.is_a? Hash - things.sort.each do |list_label, list| - list.sort.each do |item| - puts " #{item} (#{list_label})" - end - end - else - things.sort.each do |item| - puts " #{item}" - end - end end end end
true
Other
Homebrew
brew
13730a9dadde8570e41cf5599b4f5c940014f190.json
move LinkageChecker to standalone file
Library/Homebrew/os/mac/linkage_checker.rb
@@ -0,0 +1,113 @@ +require "set" +require "keg" +require "formula" + +class LinkageChecker + attr_reader :keg + attr_reader :brewed_dylibs, :system_dylibs, :broken_dylibs, :variable_dylibs + attr_reader :undeclared_deps, :reverse_links + + def initialize(keg) + @keg = keg + @brewed_dylibs = Hash.new { |h, k| h[k] = Set.new } + @system_dylibs = Set.new + @broken_dylibs = Set.new + @variable_dylibs = Set.new + @undeclared_deps = [] + @reverse_links = Hash.new { |h, k| h[k] = Set.new } + check_dylibs + end + + def check_dylibs + @keg.find do |file| + next if file.symlink? || file.directory? + next unless file.dylib? || file.mach_o_executable? || file.mach_o_bundle? + file.dynamically_linked_libraries.each do |dylib| + @reverse_links[dylib] << file + if dylib.start_with? "@" + @variable_dylibs << dylib + else + begin + owner = Keg.for Pathname.new(dylib) + rescue NotAKegError + @system_dylibs << dylib + rescue Errno::ENOENT + @broken_dylibs << dylib + else + @brewed_dylibs[owner.name] << dylib + end + end + end + end + + begin + f = Formulary.from_rack(keg.rack) + f.build = Tab.for_keg(keg) + filter_out = proc do |dep| + dep.build? || (dep.optional? && !dep.option_names.any? { |n| f.build.with?(n) }) + end + declared_deps = f.deps.reject { |dep| filter_out.call(dep) }.map(&:name) + + f.requirements.reject { |req| filter_out.call(req) }.map(&:default_formula).compact + @undeclared_deps = @brewed_dylibs.keys - declared_deps.map { |dep| dep.split("/").last } + @undeclared_deps -= [f.name] + rescue FormulaUnavailableError + opoo "Formula unavailable: #{keg.name}" + end + end + + def display_normal_output + display_items "System libraries", @system_dylibs + display_items "Homebrew libraries", @brewed_dylibs + display_items "Variable-referenced libraries", @variable_dylibs + display_items "Missing libraries", @broken_dylibs + display_items "Possible undeclared dependencies", @undeclared_deps + end + + def display_reverse_output + return if @reverse_links.empty? + sorted = @reverse_links.sort + sorted.each do |dylib, files| + puts dylib + files.each do |f| + unprefixed = f.to_s.strip_prefix "#{@keg}/" + puts " #{unprefixed}" + end + puts unless dylib == sorted.last[0] + end + end + + def display_test_output + display_items "Missing libraries", @broken_dylibs + puts "No broken dylib links" if @broken_dylibs.empty? + display_items "Possible undeclared dependencies", @undeclared_deps + puts "No undeclared dependencies" if @undeclared_deps.empty? + end + + def broken_dylibs? + !@broken_dylibs.empty? + end + + def undeclared_deps? + !@undeclared_deps.empty? + end + + private + + # Display a list of things. + # Things may either be an array, or a hash of (label -> array) + def display_items(label, things) + return if things.empty? + puts "#{label}:" + if things.is_a? Hash + things.sort.each do |list_label, list| + list.sort.each do |item| + puts " #{item} (#{list_label})" + end + end + else + things.sort.each do |item| + puts " #{item}" + end + end + end +end
true
Other
Homebrew
brew
12c505c093523089710930ac2f393dcb2ac1ca6d.json
audit: avoid unnecessary regex Regex is way slower than normal String#include? and String#start_with?. Also, we often forget to proper escape them. So avoid using them if it is not necessary. Closes #503. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/cmd/audit.rb
@@ -114,6 +114,10 @@ def =~(regex) regex =~ @text end + def include?(s) + @text.include? s + end + def line_number(regex) index = @lines.index { |line| line =~ regex } index ? index + 1 : nil @@ -458,13 +462,13 @@ def audit_homepage # Check for http:// GitHub homepage urls, https:// is preferred. # Note: only check homepages that are repo pages, not *.github.com hosts - if homepage =~ %r{^http://github\.com/} + if homepage.start_with? "http://github.com/" problem "Please use https:// for #{homepage}" end # Savannah has full SSL/TLS support but no auto-redirect. # Doesn't apply to the download URLs, only the homepage. - if homepage =~ %r{^http://savannah\.nongnu\.org/} + if homepage.start_with? "http://savannah.nongnu.org/" problem "Please use https:// for #{homepage}" end @@ -671,19 +675,19 @@ def audit_text problem %(use "xcodebuild *args" instead of "system 'xcodebuild', *args") end - if text =~ /xcodebuild[ (]["'*]/ && text !~ /SYMROOT=/ + if text =~ /xcodebuild[ (]["'*]/ && !text.include?("SYMROOT=") problem %(xcodebuild should be passed an explicit "SYMROOT") end - if text =~ /Formula\.factory\(/ + if text.include? "Formula.factory(" problem "\"Formula.factory(name)\" is deprecated in favor of \"Formula[name]\"" end - if text =~ /def plist/ && text !~ /plist_options/ + if text.include?("def plist") && !text.include?("plist_options") problem "Please set plist_options when using a formula-defined plist." end - if text =~ %r{require "language/go"} && text !~ /go_resource/ + if text.include?('require "language/go"') && !text.include?("go_resource") problem "require \"language/go\" is unnecessary unless using `go_resource`s" end end @@ -694,7 +698,7 @@ def audit_line(line, lineno) end # Commented-out cmake support from default template - if line =~ /# system "cmake/ + if line.include?('# system "cmake') problem "Commented cmake call found" end @@ -779,15 +783,15 @@ def audit_line(line, lineno) problem "Use \"if build.#{$1.downcase}?\" instead" end - if line =~ /make && make/ + if line.include?("make && make") problem "Use separate make calls" end if line =~ /^[ ]*\t/ problem "Use spaces instead of tabs for indentation" end - if line =~ /ENV\.x11/ + if line.include?("ENV.x11") problem "Use \"depends_on :x11\" instead of \"ENV.x11\"" end @@ -844,19 +848,19 @@ def audit_line(line, lineno) problem "Use build instead of ARGV to check options" end - if line =~ /def options/ + if line.include?("def options") problem "Use new-style option definitions" end - if line =~ /def test$/ + if line.end_with?("def test") problem "Use new-style test definitions (test do)" end - if line =~ /MACOS_VERSION/ + if line.include?("MACOS_VERSION") problem "Use MacOS.version instead of MACOS_VERSION" end - if line =~ /MACOS_FULL_VERSION/ + if line.include?("MACOS_FULL_VERSION") problem "Use MacOS.full_version instead of MACOS_FULL_VERSION" end @@ -878,7 +882,7 @@ def audit_line(line, lineno) problem "Define method #{$1.inspect} in the class body, not at the top-level" end - if line =~ /ENV.fortran/ && !formula.requirements.map(&:class).include?(FortranRequirement) + if line.include?("ENV.fortran") && !formula.requirements.map(&:class).include?(FortranRequirement) problem "Use `depends_on :fortran` instead of `ENV.fortran`" end @@ -908,7 +912,7 @@ def audit_line(line, lineno) problem "Use `assert_match` instead of `assert ...include?`" end - if line =~ /system "npm", "install"/ && line !~ /Language::Node/ && formula.name !~ /^kibana(\d{2})?$/ + if line.include?('system "npm", "install"') && !line.include?("Language::Node") && formula.name !~ /^kibana(\d{2})?$/ problem "Use Language::Node for npm install args" end @@ -936,9 +940,9 @@ def audit_line(line, lineno) end def audit_caveats - caveats = formula.caveats + caveats = formula.caveats.to_s - if caveats =~ /setuid/ + if caveats.include?("setuid") problem "Don't recommend setuid in the caveats, suggest sudo instead." end end @@ -1063,7 +1067,7 @@ def audit_version end end - if version.to_s =~ /^v/ + if version.to_s.start_with?("v") problem "version #{version} should not have a leading 'v'" end @@ -1196,8 +1200,8 @@ def audit_urls # Check SourceForge urls urls.each do |p| # Skip if the URL looks like a SVN repo - next if p =~ %r{/svnroot/} - next if p =~ /svn\.sourceforge/ + next if p.include? "/svnroot/" + next if p.include? "svn.sourceforge" # Is it a sourceforge http(s) URL? next unless p =~ %r{^https?://.*\b(sourceforge|sf)\.(com|net)}
false
Other
Homebrew
brew
cdf4f42ab951214fb7fac0781091783552415944.json
cleaner: fix generic executable handling. (#498) Don't unset things that are already set as executable for the generic path. OS X overrides this behaviour and detects if it's an MachO executable but there's no cross-OS generic equivalent so just fall back to whatever the build system has set.
Library/Homebrew/cleaner.rb
@@ -67,7 +67,7 @@ def prune end def executable_path?(path) - path.text_executable? + path.text_executable? || path.executable? end # Clean a top-level (bin, sbin, lib) directory, recursively, by fixing file
false
Other
Homebrew
brew
23306ab434afc185e22a0f357a27e8da687620af.json
github: produce better curl error messages. (#441) * global: add RUBY_TWO global variable. * test-bot: use RUBY_TWO global variable. * github: produce better curl error messages. If we don't know why curl has failed then ensure that the error messages that it produced are included as part of the user output.
Library/Homebrew/dev-cmd/test-bot.rb
@@ -647,11 +647,9 @@ def homebrew @category = __method__ return if @skip_homebrew - ruby_two = RUBY_VERSION.split(".").first.to_i >= 2 - if @tap.nil? tests_args = [] - if ruby_two + if RUBY_TWO tests_args << "--official-cmd-taps" tests_args << "--coverage" if ENV["TRAVIS"] end @@ -892,7 +890,7 @@ def sanitize_ARGV_and_ENV ENV["HOMEBREW_DEVELOPER"] = "1" ENV["HOMEBREW_SANDBOX"] = "1" - ENV["HOMEBREW_RUBY_MACHO"] = "1" if RUBY_VERSION.split(".").first.to_i >= 2 + ENV["HOMEBREW_RUBY_MACHO"] = "1" if RUBY_TWO ENV["HOMEBREW_NO_EMOJI"] = "1" ENV["HOMEBREW_FAIL_LOG_LINES"] = "150" ENV["HOMEBREW_EXPERIMENTAL_FILTER_FLAGS_ON_DEPS"] = "1"
true
Other
Homebrew
brew
23306ab434afc185e22a0f357a27e8da687620af.json
github: produce better curl error messages. (#441) * global: add RUBY_TWO global variable. * test-bot: use RUBY_TWO global variable. * github: produce better curl error messages. If we don't know why curl has failed then ensure that the error messages that it produced are included as part of the user output.
Library/Homebrew/global.rb
@@ -30,6 +30,7 @@ ) end RUBY_BIN = RUBY_PATH.dirname +RUBY_TWO = RUBY_VERSION.split(".").first.to_i >= 2 HOMEBREW_USER_AGENT_CURL = ENV["HOMEBREW_USER_AGENT_CURL"] HOMEBREW_USER_AGENT_RUBY = "#{ENV["HOMEBREW_USER_AGENT"]} ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
true
Other
Homebrew
brew
23306ab434afc185e22a0f357a27e8da687620af.json
github: produce better curl error messages. (#441) * global: add RUBY_TWO global variable. * test-bot: use RUBY_TWO global variable. * github: produce better curl error messages. If we don't know why curl has failed then ensure that the error messages that it produced are included as part of the user output.
Library/Homebrew/utils/curl.rb
@@ -1,4 +1,5 @@ require "pathname" +require "open3" def curl_args(extra_args=[]) curl = Pathname.new ENV["HOMEBREW_CURL"] @@ -19,6 +20,15 @@ def curl(*args) end def curl_output(*args) - curl_args = curl_args(args) - ["--fail"] - Utils.popen_read_text(*curl_args) + curl_args = curl_args(args) + curl_args -= ["--fail"] + if RUBY_TWO + curl_args -= ["--silent"] + Open3.popen3(*curl_args) do |_, stdout, stderr, wait_thread| + [stdout.read, stderr.read, wait_thread.value] + end + else + output = Utils.popen_read_text(*curl_args) + [output, nil, $?] + end end
true
Other
Homebrew
brew
23306ab434afc185e22a0f357a27e8da687620af.json
github: produce better curl error messages. (#441) * global: add RUBY_TWO global variable. * test-bot: use RUBY_TWO global variable. * github: produce better curl error messages. If we don't know why curl has failed then ensure that the error messages that it produced are included as part of the user output.
Library/Homebrew/utils/github.rb
@@ -146,7 +146,8 @@ def open(url, data=nil) args += ["--dump-header", "#{headers_tmpfile.path}"] - output, _, http_code = curl_output(url.to_s, *args).rpartition("\n") + output, errors, status = curl_output(url.to_s, *args) + output, _, http_code = output.rpartition("\n") output, _, http_code = output.rpartition("\n") if http_code == "000" headers = headers_tmpfile.read ensure @@ -159,8 +160,8 @@ def open(url, data=nil) end begin - if !http_code.start_with?("2") && !$?.success? - raise_api_error(output, http_code, headers) + if !http_code.start_with?("2") && !status.success? + raise_api_error(output, errors, http_code, headers) end json = Utils::JSON.load output if block_given? @@ -173,7 +174,7 @@ def open(url, data=nil) end end - def raise_api_error(output, http_code, headers) + def raise_api_error(output, errors, http_code, headers) meta = {} headers.lines.each do |l| key, _, value = l.delete(":").partition(" ") @@ -197,7 +198,7 @@ def raise_api_error(output, http_code, headers) raise HTTPNotFoundError, output else error = Utils::JSON.load(output)["message"] rescue nil - error ||= output + error ||= "curl failed! #{errors}" raise Error, error end end
true
Other
Homebrew
brew
ed1d1e51da6bf464d6e461f5214e49f17b1f1842.json
update.sh: improve verbose output and readability. (#486) Would have made it easier to debug https://github.com/Homebrew/homebrew-core/issues/2804 where wasn't clear which directory was causing the issue.
Library/Homebrew/cmd/update.sh
@@ -107,9 +107,8 @@ pop_stash() { [[ -z "$STASHED" ]] && return if [[ -n "$HOMEBREW_VERBOSE" ]] then + echo "Restoring your stashed changes to $DIR..." git stash pop - echo "Restoring your stashed changes to $DIR:" - git status --short --untracked-files else git stash pop "${QUIET_ARGS[@]}" 1>/dev/null fi @@ -147,6 +146,11 @@ reset_on_interrupt() { } pull() { + if [[ -n "$HOMEBREW_VERBOSE" ]] + then + echo "Updating $DIR..." + fi + local DIR local TAP_VAR @@ -187,8 +191,7 @@ pull() { then if [[ -n "$HOMEBREW_VERBOSE" ]] then - echo "Stashing uncommitted changes to $DIR." - git status --short --untracked-files=all + echo "Stashing uncommitted changes to $DIR..." fi git merge --abort &>/dev/null git rebase --abort &>/dev/null @@ -417,6 +420,7 @@ EOS do [[ -d "$DIR/.git" ]] || continue pull "$DIR" + [[ -n "$HOMEBREW_VERBOSE" ]] && echo done safe_cd "$HOMEBREW_REPOSITORY"
false
Other
Homebrew
brew
768ba34b1428782a2df6c6d0b4d49241d257439e.json
style: use RuboCop 0.41.2, adjust defaults (#489) Changes to our style configuration: - Consolidate all rules related to Ruby 1.8 compatibility in one place. - Codify our de-facto preference for `alias_method` over `alias` (drops offense count by 54 after turning this on). - Drop `Style/SignalException` as `only_raise` has been the new default for quite a while (since RuboCop 0.37.0).
Library/.rubocop.yml
@@ -3,9 +3,13 @@ AllCops: - 'Homebrew/vendor/**/*' - 'Homebrew/test/vendor/**/*' -# 1.8-style hash keys +# Ruby 1.8 compatibility +Style/DotPosition: + EnforcedStyle: trailing Style/HashSyntax: EnforcedStyle: hash_rockets +Style/TrailingCommaInArguments: + EnforcedStyleForMultiline: no_comma # ruby style guide favorite Style/StringLiterals: @@ -23,6 +27,10 @@ Style/CommandLiteral: Style/RegexpLiteral: EnforcedStyle: slashes +# too prevalent to change this now, but might be discussed/changed later +Style/Alias: + EnforcedStyle: prefer_alias_method + # our current conditional style is established, clear and # requiring users to change that now would be confusing. Style/ConditionalAssignment: @@ -115,10 +123,6 @@ Style/WordArray: Style/UnneededCapitalW: Enabled: false -# we use raise, not fail -Style/SignalException: - EnforcedStyle: only_raise - # we prefer compact if-else-end/case-when-end alignment Lint/EndAlignment: AlignWith: variable @@ -129,12 +133,6 @@ Style/CaseIndentation: Style/PerlBackrefs: Enabled: false -# this is required for Ruby 1.8 -Style/DotPosition: - EnforcedStyle: trailing - # makes diffs nicer -Style/TrailingCommaInArguments: - EnforcedStyleForMultiline: no_comma Style/TrailingCommaInLiteral: EnforcedStyleForMultiline: comma
true
Other
Homebrew
brew
768ba34b1428782a2df6c6d0b4d49241d257439e.json
style: use RuboCop 0.41.2, adjust defaults (#489) Changes to our style configuration: - Consolidate all rules related to Ruby 1.8 compatibility in one place. - Codify our de-facto preference for `alias_method` over `alias` (drops offense count by 54 after turning this on). - Drop `Style/SignalException` as `only_raise` has been the new default for quite a while (since RuboCop 0.37.0).
Library/Homebrew/cmd/style.rb
@@ -47,7 +47,7 @@ def check_style_json(files, options = {}) def check_style_impl(files, output_type, options = {}) fix = options[:fix] - Homebrew.install_gem_setup_path! "rubocop", "0.41.1" + Homebrew.install_gem_setup_path! "rubocop", "0.41.2" args = %W[ --force-exclusion
true
Other
Homebrew
brew
fe3915237ef0c530ce1260cf7d2d0ca0d9d0eed1.json
config: show homebrew ruby for all system (#492)
Library/Homebrew/extend/os/mac/system_config.rb
@@ -28,14 +28,8 @@ def describe_xquartz "#{MacOS::XQuartz.version} => #{describe_path(MacOS::XQuartz.prefix)}" end - def describe_system_ruby - s = "" - case RUBY_VERSION - when /^1\.[89]/, /^2\.0/ - s << "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}" - else - s << RUBY_VERSION - end + def describe_homebrew_ruby + s = describe_homebrew_ruby_version if RUBY_PATH.to_s !~ %r{^/System/Library/Frameworks/Ruby.framework/Versions/[12]\.[089]/usr/bin/ruby} s << " => #{RUBY_PATH}" @@ -45,7 +39,6 @@ def describe_system_ruby def dump_verbose_config(f = $stdout) dump_generic_verbose_config(f) - f.puts "System Ruby: #{describe_system_ruby}" f.puts "OS X: #{MacOS.full_version}-#{kernel}" f.puts "Xcode: #{xcode ? xcode : "N/A"}" f.puts "CLT: #{clt ? clt : "N/A"}"
true
Other
Homebrew
brew
fe3915237ef0c530ce1260cf7d2d0ca0d9d0eed1.json
config: show homebrew ruby for all system (#492)
Library/Homebrew/system_config.rb
@@ -85,6 +85,19 @@ def describe_ruby end end + def describe_homebrew_ruby_version + case RUBY_VERSION + when /^1\.[89]/, /^2\.0/ + "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}" + else + RUBY_VERSION + end + end + + def describe_homebrew_ruby + "#{describe_homebrew_ruby_version} => #{RUBY_PATH}" + end + def hardware return if Hardware::CPU.type == :dunno "CPU: #{Hardware.cores_as_words}-core #{Hardware::CPU.bits}-bit #{Hardware::CPU.family}" @@ -129,6 +142,7 @@ def dump_verbose_config(f = $stdout) f.puts "HOMEBREW_CELLAR: #{HOMEBREW_CELLAR}" f.puts "HOMEBREW_BOTTLE_DOMAIN: #{BottleSpecification::DEFAULT_DOMAIN}" f.puts hardware if hardware + f.puts "Homebrew Ruby: #{describe_homebrew_ruby}" f.puts "GCC-4.0: build #{gcc_40}" if gcc_40 f.puts "GCC-4.2: build #{gcc_42}" if gcc_42 f.puts "Clang: #{clang ? "#{clang} build #{clang_build}" : "N/A"}"
true
Other
Homebrew
brew
dff6bfde9a2b841b0b30eb5d54bee351b4594a89.json
ruby.sh: add test flag
Library/Homebrew/utils/ruby.sh
@@ -1,4 +1,33 @@ +origin-setup-ruby-path() { + if [[ -z "$HOMEBREW_DEVELOPER" ]] + then + unset HOMEBREW_RUBY_PATH + fi + + if [[ -z "$HOMEBREW_RUBY_PATH" ]] + then + if [[ -n "$HOMEBREW_OSX" ]] + then + HOMEBREW_RUBY_PATH="/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby" + else + HOMEBREW_RUBY_PATH="$(which ruby)" + if [[ -z "$HOMEBREW_RUBY_PATH" ]] + then + odie "No Ruby found, cannot proceed." + fi + fi + fi + + export HOMEBREW_RUBY_PATH +} + setup-ruby-path() { + if [[ -z "$HOMEBREW_USE_VENDOR_RUBY" ]] + then + origin-setup-ruby-path + return + fi + local vendor_dir local vendor_ruby_current_version local vendor_ruby_path
false
Other
Homebrew
brew
8f178187c0910864c9d811ed00ca93f0ad208d55.json
add file directory for vendor Ruby The vendor Ruby will be put inside `Library/Homebrew/vendor/portable-ruby/<version>`, with a symlink `Library/Homebrew/vendor/portable-ruby/current` pointed to it. In addition, a `Library/Homebrew/vendor/portable-ruby-version` will track the latest version of vendor binaries. This gives us version control on vendor Ruby and enables us to bump vendor Ruby whenever needed such as security update.
.gitignore
@@ -20,6 +20,9 @@ /Library/PinnedTaps /Library/Taps +# Ignore vendored files within `Library` +/Library/Homebrew/vendor/portable-ruby/* + # Ignore `bin` contents (again). /bin
true
Other
Homebrew
brew
8f178187c0910864c9d811ed00ca93f0ad208d55.json
add file directory for vendor Ruby The vendor Ruby will be put inside `Library/Homebrew/vendor/portable-ruby/<version>`, with a symlink `Library/Homebrew/vendor/portable-ruby/current` pointed to it. In addition, a `Library/Homebrew/vendor/portable-ruby-version` will track the latest version of vendor binaries. This gives us version control on vendor Ruby and enables us to bump vendor Ruby whenever needed such as security update.
Library/Homebrew/vendor/portable-ruby-version
@@ -0,0 +1 @@ +2.0.0-p648
true
Other
Homebrew
brew
a00995fa090f905a5fbba97a8c9270246e788a39.json
osxfuse_requirement: remove formula reference. We’re just supporting the Cask now.
Library/Homebrew/requirements/osxfuse_requirement.rb
@@ -2,11 +2,10 @@ class OsxfuseRequirement < Requirement fatal true - default_formula "osxfuse" cask "osxfuse" download "https://osxfuse.github.io/" - satisfy(:build_env => false) { Formula["osxfuse"].installed? || self.class.binary_osxfuse_installed? } + satisfy(:build_env => false) { self.class.binary_osxfuse_installed? } def self.binary_osxfuse_installed? File.exist?("/usr/local/include/osxfuse/fuse.h") &&
false
Other
Homebrew
brew
f950261b99f130b536fa6881959c0a8b8682aff4.json
tuntap_requirement: remove formula reference. We’re just supporting the Cask now.
Library/Homebrew/requirements/tuntap_requirement.rb
@@ -2,9 +2,8 @@ class TuntapRequirement < Requirement fatal true - default_formula "tuntap" cask "tuntap" - satisfy(:build_env => false) { self.class.binary_tuntap_installed? || Formula["tuntap"].installed? } + satisfy(:build_env => false) { self.class.binary_tuntap_installed? } def self.binary_tuntap_installed? %w[
false
Other
Homebrew
brew
5413ddcb6557f1ceb3fbc9bcf28b4cf65ca1c218.json
tuntap_requirement: fix binary logic. Previously this was only using the last line.
Library/Homebrew/requirements/tuntap_requirement.rb
@@ -7,8 +7,11 @@ class TuntapRequirement < Requirement satisfy(:build_env => false) { self.class.binary_tuntap_installed? || Formula["tuntap"].installed? } def self.binary_tuntap_installed? - File.exist?("/Library/Extensions/tun.kext") && File.exist?("/Library/Extensions/tap.kext") - File.exist?("/Library/LaunchDaemons/net.sf.tuntaposx.tun.plist") - File.exist?("/Library/LaunchDaemons/net.sf.tuntaposx.tap.plist") + %w[ + /Library/Extensions/tun.kext + /Library/Extensions/tap.kext + /Library/LaunchDaemons/net.sf.tuntaposx.tun.plist + /Library/LaunchDaemons/net.sf.tuntaposx.tap.plist + ].all? { |file| File.exist?(file) } end end
false
Other
Homebrew
brew
88793ba798cd2dbe3ce44972be912f8f5d892c5e.json
tap-info: improve Bash completion Closes #482. Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
etc/bash_completion.d/brew
@@ -460,6 +460,18 @@ _brew_style () __brew_complete_formulae } +_brew_tap_info () +{ + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + --*) + __brewcomp "--installed --json=v1" + return + ;; + esac + __brew_complete_tapped +} + _brew_tap_readme () { local cur="${COMP_WORDS[COMP_CWORD]}" @@ -625,14 +637,15 @@ _brew () style) _brew_style ;; switch) _brew_switch ;; tap) _brew_complete_tap ;; + tap-info) _brew_tap_info ;; tap-readme) _brew_tap_readme ;; tap-unpin) _brew_tap_unpin ;; tests) _brew_tests ;; uninstall|remove|rm) _brew_uninstall ;; unlinkapps) _brew_unlinkapps ;; unpack) _brew_unpack ;; unpin) __brew_complete_formulae ;; - untap|tap-info|tap-pin) __brew_complete_tapped ;; + untap|tap-pin) __brew_complete_tapped ;; update) _brew_update ;; upgrade) _brew_upgrade ;; uses) _brew_uses ;;
false
Other
Homebrew
brew
df4982ed0810fac1b58aedeb6653ca908dccbd51.json
audit.rb: require https for download.savannah.gnu.org (#438) and download-mirror.savannah.gnu.org
Library/Homebrew/cmd/audit.rb
@@ -1150,6 +1150,8 @@ def audit_urls case p when %r{^http://ftp\.gnu\.org/}, %r{^http://ftpmirror\.gnu\.org/}, + %r{^http://download\.savannah\.gnu\.org/}, + %r{^http://download-mirror\.savannah\.gnu\.org/}, %r{^http://[^/]*\.apache\.org/}, %r{^http://code\.google\.com/}, %r{^http://fossies\.org/},
false
Other
Homebrew
brew
832a08abcdf2256c140d9f81d8753d8bddd323c2.json
extend/os/mac/keg_relocate: fix weird omission
Library/Homebrew/extend/os/mac/keg_relocate.rb
@@ -126,7 +126,7 @@ def mach_o_files def self.file_linked_libraries(file, string) # Check dynamic library linkage. Importantly, do not run otool on static # libraries, which will falsely report "linkage" to themselves. - if file.mach_o_executable? || file.dylib? || file.mach_o_bund + if file.mach_o_executable? || file.dylib? || file.mach_o_bundle? file.dynamically_linked_libraries.select { |lib| lib.include? string } else []
false
Other
Homebrew
brew
a5ec0aa2598d702b68300e7400fad48e8a392527.json
emoji: extract logic into generic OS classes. (#450)
Library/Homebrew/emoji.rb
@@ -0,0 +1,24 @@ +module Emoji + class << self + def tick + # necessary for 1.8.7 unicode handling since many installs are on 1.8.7 + @tick ||= ["2714".hex].pack("U*") + end + + def cross + # necessary for 1.8.7 unicode handling since many installs are on 1.8.7 + @cross ||= ["2718".hex].pack("U*") + end + + def install_badge + ENV["HOMEBREW_INSTALL_BADGE"] || "\xf0\x9f\x8d\xba" + end + + def enabled? + !ENV["HOMEBREW_NO_EMOJI"] + end + alias generic_enabled? enabled? + end +end + +require "extend/os/emoji"
true
Other
Homebrew
brew
a5ec0aa2598d702b68300e7400fad48e8a392527.json
emoji: extract logic into generic OS classes. (#450)
Library/Homebrew/extend/os/emoji.rb
@@ -0,0 +1,6 @@ +require "os" +require "emoji" + +if OS.mac? + require "extend/os/mac/emoji" +end
true
Other
Homebrew
brew
a5ec0aa2598d702b68300e7400fad48e8a392527.json
emoji: extract logic into generic OS classes. (#450)
Library/Homebrew/extend/os/mac/emoji.rb
@@ -0,0 +1,7 @@ +module Emoji + class << self + def enabled? + generic_enabled? && MacOS.version >= :lion + end + end +end
true
Other
Homebrew
brew
a5ec0aa2598d702b68300e7400fad48e8a392527.json
emoji: extract logic into generic OS classes. (#450)
Library/Homebrew/formula_installer.rb
@@ -13,6 +13,7 @@ require "debrew" require "sandbox" require "requirements/cctools_requirement" +require "emoji" class FormulaInstaller include FormulaCellarChecks @@ -492,13 +493,9 @@ def finish unlock end - def emoji - ENV["HOMEBREW_INSTALL_BADGE"] || "\xf0\x9f\x8d\xba" - end - def summary s = "" - s << "#{emoji} " if MacOS.version >= :lion && !ENV["HOMEBREW_NO_EMOJI"] + s << "#{Emoji.install_badge} " if Emoji.enabled? s << "#{formula.prefix}: #{formula.prefix.abv}" s << ", built in #{pretty_duration build_time}" if build_time s
true
Other
Homebrew
brew
a5ec0aa2598d702b68300e7400fad48e8a392527.json
emoji: extract logic into generic OS classes. (#450)
Library/Homebrew/utils.rb
@@ -1,4 +1,5 @@ require "pathname" +require "emoji" require "exceptions" require "utils/hash" require "utils/json" @@ -12,16 +13,6 @@ class Tty class << self - def tick - # necessary for 1.8.7 unicode handling since many installs are on 1.8.7 - @tick ||= ["2714".hex].pack("U*") - end - - def cross - # necessary for 1.8.7 unicode handling since many installs are on 1.8.7 - @cross ||= ["2718".hex].pack("U*") - end - def strip_ansi(string) string.gsub(/\033\[\d+(;\d+)*m/, "") end @@ -124,20 +115,20 @@ def odie(error) def pretty_installed(f) if !$stdout.tty? "#{f}" - elsif ENV["HOMEBREW_NO_EMOJI"] - "#{Tty.highlight}#{Tty.green}#{f} (installed)#{Tty.reset}" + elsif Emoji.enabled? + "#{Tty.highlight}#{f} #{Tty.green}#{Emoji.tick}#{Tty.reset}" else - "#{Tty.highlight}#{f} #{Tty.green}#{Tty.tick}#{Tty.reset}" + "#{Tty.highlight}#{Tty.green}#{f} (installed)#{Tty.reset}" end end def pretty_uninstalled(f) if !$stdout.tty? "#{f}" - elsif ENV["HOMEBREW_NO_EMOJI"] - "#{Tty.red}#{f} (uninstalled)#{Tty.reset}" + elsif Emoji.enabled? + "#{f} #{Tty.red}#{Emoji.cross}#{Tty.reset}" else - "#{f} #{Tty.red}#{Tty.cross}#{Tty.reset}" + "#{Tty.red}#{f} (uninstalled)#{Tty.reset}" end end
true
Other
Homebrew
brew
4da990587f723a563e602a665403393f67fc8e70.json
tap: run readall when tapping. (#396) * readall: move readall logic to new class. * tap: run readall when tapping. This will prevent tapping an tap with syntax errors from causing issues for users. Fixes #58.
Library/Homebrew/cmd/readall.rb
@@ -3,14 +3,12 @@ # when making significant changes to formula.rb, # or to determine if any current formulae have Ruby issues -require "formula" -require "tap" -require "thread" +require "readall" module Homebrew def readall - if ARGV.delete("--syntax") - ruby_files = Queue.new + if ARGV.include?("--syntax") + ruby_files = [] scan_files = %W[ #{HOMEBREW_LIBRARY}/*.rb #{HOMEBREW_LIBRARY}/Homebrew/**/*.rb @@ -20,69 +18,17 @@ def readall ruby_files << rb end - failed = false - workers = (0...Hardware::CPU.cores).map do - Thread.new do - begin - while rb = ruby_files.pop(true) - # As a side effect, print syntax errors/warnings to `$stderr`. - failed = true if syntax_errors_or_warnings?(rb) - end - rescue ThreadError # ignore empty queue error - end - end - end - workers.each(&:join) - Homebrew.failed = failed + Homebrew.failed = true unless Readall.valid_ruby_syntax?(ruby_files) end - formulae = [] - alias_dirs = [] - if ARGV.named.empty? - formulae = Formula.files - alias_dirs = Tap.map(&:alias_dir) + options = { :aliases => ARGV.include?("--aliases") } + taps = if ARGV.named.any? + [Tap.fetch(ARGV.named.first)] else - tap = Tap.fetch(ARGV.named.first) - raise TapUnavailableError, tap.name unless tap.installed? - formulae = tap.formula_files - alias_dirs = [tap.alias_dir] + Tap end - - if ARGV.delete("--aliases") - alias_dirs.each do |alias_dir| - next unless alias_dir.directory? - Pathname.glob("#{alias_dir}/*").each do |f| - next unless f.symlink? - next if f.file? - onoe "Broken alias: #{f}" - Homebrew.failed = true - end - end - end - - formulae.each do |file| - begin - Formulary.factory(file) - rescue Interrupt - raise - rescue Exception => e - onoe "problem in #{file}" - puts e - Homebrew.failed = true - end + taps.each do |tap| + Homebrew.failed = true unless Readall.valid_tap?(tap, options) end end - - private - - def syntax_errors_or_warnings?(rb) - # Retrieve messages about syntax errors/warnings printed to `$stderr`, but - # discard a `Syntax OK` printed to `$stdout` (in absence of syntax errors). - messages = Utils.popen_read("#{RUBY_PATH} -c -w #{rb} 2>&1 >/dev/null") - $stderr.print messages - - # Only syntax errors result in a non-zero status code. To detect syntax - # warnings we also need to inspect the output to `$stderr`. - !$?.success? || !messages.chomp.empty? - end end
true
Other
Homebrew
brew
4da990587f723a563e602a665403393f67fc8e70.json
tap: run readall when tapping. (#396) * readall: move readall logic to new class. * tap: run readall when tapping. This will prevent tapping an tap with syntax errors from causing issues for users. Fixes #58.
Library/Homebrew/readall.rb
@@ -0,0 +1,81 @@ +require "formula" +require "tap" +require "thread" +require "readall" + +module Readall + class << self + def valid_ruby_syntax?(ruby_files) + ruby_files_queue = Queue.new + ruby_files.each { |f| ruby_files_queue << f } + failed = false + workers = (0...Hardware::CPU.cores).map do + Thread.new do + begin + while rb = ruby_files_queue.pop(true) + # As a side effect, print syntax errors/warnings to `$stderr`. + failed = true if syntax_errors_or_warnings?(rb) + end + rescue ThreadError # ignore empty queue error + end + end + end + workers.each(&:join) + !failed + end + + def valid_aliases?(alias_dirs) + failed = false + alias_dirs.each do |alias_dir| + next unless alias_dir.directory? + alias_dir.children.each do |f| + next unless f.symlink? + next if f.file? + onoe "Broken alias: #{f}" + failed = true + end + end + !failed + end + + def valid_formulae?(formulae) + failed = false + formulae.each do |file| + begin + Formulary.factory(file) + rescue Interrupt + raise + rescue Exception => e + onoe "Invalid formula: #{file}" + puts e + failed = true + end + end + !failed + end + + def valid_tap?(tap, options = {}) + failed = false + if options[:aliases] + valid_aliases = valid_aliases?([tap.alias_dir]) + failed = true unless valid_aliases + end + valid_formulae = valid_formulae?(tap.formula_files) + failed = true unless valid_formulae + !failed + end + + private + + def syntax_errors_or_warnings?(rb) + # Retrieve messages about syntax errors/warnings printed to `$stderr`, but + # discard a `Syntax OK` printed to `$stdout` (in absence of syntax errors). + messages = Utils.popen_read("#{RUBY_PATH} -c -w #{rb} 2>&1 >/dev/null") + $stderr.print messages + + # Only syntax errors result in a non-zero status code. To detect syntax + # warnings we also need to inspect the output to `$stderr`. + !$?.success? || !messages.chomp.empty? + end + end +end
true
Other
Homebrew
brew
4da990587f723a563e602a665403393f67fc8e70.json
tap: run readall when tapping. (#396) * readall: move readall logic to new class. * tap: run readall when tapping. This will prevent tapping an tap with syntax errors from causing issues for users. Fixes #58.
Library/Homebrew/tap.rb
@@ -1,4 +1,5 @@ require "extend/string" +require "readall" # a {Tap} is used to extend the formulae provided by Homebrew core. # Usually, it's synced with a remote git repository. And it's likely @@ -211,9 +212,14 @@ def install(options = {}) begin safe_system "git", *args - rescue Interrupt, ErrorDuringExecution + unless Readall.valid_tap?(self, :aliases => true) + raise "Cannot tap #{name}: invalid syntax in tap!" + end + rescue Interrupt, ErrorDuringExecution, RuntimeError ignore_interrupts do - sleep 0.1 # wait for git to cleanup the top directory when interrupt happens. + # wait for git to possibly cleanup the top directory when interrupt happens. + sleep 0.1 + FileUtils.rm_rf path path.parent.rmdir_if_possible end raise
true
Other
Homebrew
brew
4da990587f723a563e602a665403393f67fc8e70.json
tap: run readall when tapping. (#396) * readall: move readall logic to new class. * tap: run readall when tapping. This will prevent tapping an tap with syntax errors from causing issues for users. Fixes #58.
Library/Homebrew/test/test_tap.rb
@@ -135,7 +135,7 @@ def test_remote end refute_predicate version_tap, :private? ensure - version_tap.path.rmtree + version_tap.path.rmtree if version_tap end def test_remote_not_git_repo @@ -220,7 +220,7 @@ def test_install_and_uninstall refute_predicate HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1", :exist? refute_predicate HOMEBREW_PREFIX/"share/man/man1", :exist? ensure - (HOMEBREW_PREFIX/"share").rmtree + (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist? end def test_pin_and_unpin
true
Other
Homebrew
brew
4f2e31b3e3ef3ab4758e3ac3c22dafd190652d5d.json
language/python: fix bogus require Including the extension is not an error, but we don't normally do this.
Library/Homebrew/language/python.rb
@@ -1,4 +1,4 @@ -require "utils.rb" +require "utils" module Language module Python
false
Other
Homebrew
brew
51025a9fa2b5a762179b5c78b1c603a4a65c13ba.json
brew.sh: enable autoupdate for Homebrew developers (#429) Autoupdate has been working well for me/opt-in folks for a while so lets enable it for Homebrew developers to test before we enable it for everyone.
Library/brew.sh
@@ -230,7 +230,7 @@ setup-analytics report-analytics-screenview-command update-preinstall() { - [[ -n "$HOMEBREW_AUTO_UPDATE" ]] || return + [[ -n "$HOMEBREW_DEVELOPER" ]] || return [[ -z "$HOMEBREW_NO_AUTO_UPDATE" ]] || return [[ -z "$HOMEBREW_UPDATE_PREINSTALL" ]] || return
false
Other
Homebrew
brew
b55250c44eacd49646407b26a73753965d4d36d0.json
test_integration_cmds: use a single teardown. (#475) Instead of writing a custom ensure for every test let's just nuke all the files every time. This may be something we might want to use for other unit tests too. It leans heavily on the fact that a `FileUtils.rm_rf` on files that don't exist is very quick and things like `brew cleanup` are super slow in comparison. Before: ``` $ brew tests --only=integration_cmds --official-cmd-taps Finished in 49.764724s, 1.0047 runs/s, 5.2648 assertions/s. ``` After: ``` $ brew tests --only=integration_cmds --official-cmd-taps Finished in 43.014769s, 1.1624 runs/s, 5.8352 assertions/s. ```
Library/Homebrew/test/test_integration_cmds.rb
@@ -6,15 +6,33 @@ class IntegrationCommandTests < Homebrew::TestCase def setup - @formula_files = [] @cmd_id_index = 0 # Assign unique IDs to invocations of `cmd_output`. (HOMEBREW_PREFIX/"bin").mkpath FileUtils.touch HOMEBREW_PREFIX/"bin/brew" end def teardown - (HOMEBREW_PREFIX/"bin").rmtree - @formula_files.each(&:unlink) + coretap = CoreTap.new + paths_to_delete = [ + HOMEBREW_CELLAR.children, + HOMEBREW_CACHE.children, + HOMEBREW_LOCK_DIR.children, + HOMEBREW_LOGS.children, + HOMEBREW_PREFIX/"bin", + HOMEBREW_PREFIX/"share", + HOMEBREW_PREFIX/"opt", + HOMEBREW_LIBRARY/"LinkedKegs", + HOMEBREW_LIBRARY/"Taps/caskroom", + HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bundle", + HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo", + HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-services", + HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-shallow", + HOMEBREW_REPOSITORY/".git", + coretap.path/".git", + coretap.alias_dir, + coretap.formula_dir.children, + ].flatten + FileUtils.rm_rf paths_to_delete end def needs_test_cmd_taps @@ -90,7 +108,6 @@ def cmd_fail(*args) def setup_test_formula(name, content = nil) formula_path = CoreTap.new.formula_dir/"#{name}.rb" - @formula_files << formula_path case name when "testball" @@ -241,24 +258,16 @@ def test_bottle end assert_match(/testball-0\.1.*\.bottle\.tar\.gz/, cmd_output("bottle", "--no-revision", "testball")) - ensure - cmd("uninstall", "--force", "testball") - cmd("cleanup", "--force", "--prune=all") - FileUtils.rm_f Dir["testball-0.1*.bottle.tar.gz"] end def test_uninstall cmd("install", testball) assert_match "Uninstalling testball", cmd("uninstall", "--force", testball) - ensure - cmd("cleanup", "--force", "--prune=all") end def test_cleanup (HOMEBREW_CACHE/"test").write "test" assert_match "#{HOMEBREW_CACHE}/test", cmd("cleanup", "--prune=all") - ensure - FileUtils.rm_f HOMEBREW_CACHE/"test" end def test_readall @@ -268,8 +277,6 @@ def test_readall FileUtils.ln_s formula_file, alias_file cmd("readall", "--aliases", "--syntax") cmd("readall", "homebrew/core") - ensure - alias_file.parent.rmtree end def test_tap @@ -297,8 +304,6 @@ def test_tap assert_match "Untapped", cmd("untap", "homebrew/bar") assert_equal "", cmd("tap", "homebrew/bar", path/".git", "-q", "--full") assert_match "Untapped", cmd("untap", "homebrew/bar") - ensure - path.rmtree end def test_missing @@ -307,8 +312,6 @@ def test_missing (HOMEBREW_CELLAR/"bar/1.0").mkpath assert_match "foo", cmd("missing") - ensure - (HOMEBREW_CELLAR/"bar").rmtree end def test_doctor @@ -346,8 +349,6 @@ def test_desc cmd("desc", "--description", "testball") assert_predicate desc_cache, :exist?, "Cached file should not exist" - ensure - desc_cache.unlink end def test_edit @@ -356,8 +357,6 @@ def test_edit assert_match "# something here", cmd("edit", "testball", "HOMEBREW_EDITOR" => "/bin/cat") - ensure - (HOMEBREW_REPOSITORY/".git").unlink end def test_sh @@ -377,8 +376,6 @@ def test_tap_readme cmd("tap-readme", "foo", "--verbose") readme = HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo/README.md" assert readme.exist?, "The README should be created" - ensure - (HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo").rmtree end def test_unpack @@ -389,8 +386,6 @@ def test_unpack assert File.directory?("#{path}/testball-0.1"), "The tarball should be unpacked" end - ensure - FileUtils.rm_f HOMEBREW_CACHE/"testball-0.1.tbz" end def test_options @@ -407,8 +402,6 @@ def test_outdated (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath assert_equal "testball", cmd("outdated") - ensure - FileUtils.rm_rf HOMEBREW_CELLAR/"testball" end def test_upgrade @@ -418,9 +411,6 @@ def test_upgrade cmd("upgrade") assert((HOMEBREW_CELLAR/"testball/0.1").directory?, "The latest version directory should be created") - ensure - cmd("uninstall", "--force", testball) - cmd("cleanup", "--force", "--prune=all") end def test_linkapps @@ -433,9 +423,6 @@ def test_linkapps source_dir.mkpath assert_match "Linking: #{source_dir}", cmd("linkapps", "--local", "HOME" => home_dir) - ensure - home_dir.rmtree - (HOMEBREW_CELLAR/"testball").rmtree end def test_unlinkapps @@ -452,9 +439,6 @@ def test_unlinkapps assert_match "Unlinking: #{apps_dir}/TestBall.app", cmd("unlinkapps", "--local", "HOME" => home_dir) - ensure - home_dir.rmtree - (HOMEBREW_CELLAR/"testball").rmtree end def test_pin_unpin @@ -470,9 +454,6 @@ def test_pin_unpin cmd("upgrade") assert((HOMEBREW_CELLAR/"testball/0.1").directory?, "The latest version directory should be created") - ensure - cmd("uninstall", "--force", testball) - cmd("cleanup", "--force", "--prune=all") end def test_reinstall @@ -485,9 +466,6 @@ def test_reinstall assert_match "Reinstalling testball with --with-foo", cmd("reinstall", "testball") assert foo_dir.exist? - ensure - cmd("uninstall", "--force", "testball") - cmd("cleanup", "--force", "--prune=all") end def test_home @@ -507,10 +485,6 @@ def test_list assert_equal formulae.join("\n"), cmd("list") - ensure - formulae.each do |f| - (HOMEBREW_CELLAR/"#{f}").rmtree - end end def test_create @@ -520,9 +494,6 @@ def test_create formula_file = CoreTap.new.formula_dir/"testball.rb" assert formula_file.exist?, "The formula source should have been created" assert_match %(sha256 "#{TESTBALL_SHA256}"), formula_file.read - ensure - formula_file.unlink - cmd("cleanup", "--force", "--prune=all") end def test_fetch @@ -531,8 +502,6 @@ def test_fetch cmd("fetch", "testball") assert((HOMEBREW_CACHE/"testball-0.1.tbz").exist?, "The tarball should have been cached") - ensure - cmd("cleanup", "--force", "--prune=all") end def test_deps @@ -569,8 +538,6 @@ def test_log end end assert_match "This is a test commit", cmd("log") - ensure - (HOMEBREW_REPOSITORY/".git").rmtree end def test_log_formula @@ -595,9 +562,6 @@ def test_log_formula cmd("log", "#{shallow_tap}/testball") assert_predicate shallow_tap.path/".git/shallow", :exist?, "A shallow clone should have been created." - ensure - (core_tap.path/".git").rmtree - shallow_tap.path.rmtree end def test_leaves @@ -610,9 +574,6 @@ def test_leaves (HOMEBREW_CELLAR/"bar/0.1/somedir").mkpath assert_equal "bar", cmd("leaves") - ensure - (HOMEBREW_CELLAR/"foo").rmtree - (HOMEBREW_CELLAR/"bar").rmtree end def test_prune @@ -634,8 +595,6 @@ def test_prune # more line with contents `No apps unlinked from /Users/<user/Applications`. assert_match "Nothing pruned\nNo apps unlinked from /Applications", cmd("prune", "--verbose") - ensure - share.rmtree end def test_custom_command @@ -676,8 +635,6 @@ def test_search end assert_predicate desc_cache, :exist?, "Cached file should exist" - ensure - desc_cache.unlink end def test_bundle @@ -697,26 +654,18 @@ def test_bundle cmd("bundle", "check") end end - ensure - FileUtils.rm_rf HOMEBREW_REPOSITORY/".git" - FileUtils.rm_rf HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bundle" end def test_cask needs_test_cmd_taps setup_remote_tap("caskroom/cask") cmd("cask", "list") - ensure - FileUtils.rm_rf HOMEBREW_LIBRARY/"Taps/caskroom" - FileUtils.rm_rf HOMEBREW_PREFIX/"share" end def test_services needs_test_cmd_taps setup_remote_tap("homebrew/services") assert_equal "Warning: No services available to control with `brew services`", cmd("services", "list") - ensure - FileUtils.rm_rf HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-services" end end
false
Other
Homebrew
brew
454645263d3380dfa8d699bd1c42fa907076645f.json
Revert "linkage: check undeclared dependencies for `--test`" This reverts commit 080ddd8804be14f4b18f9558b58270456ff313c2.
Library/Homebrew/dev-cmd/linkage.rb
@@ -18,34 +18,34 @@ module Homebrew def linkage + found_broken_dylibs = false ARGV.kegs.each do |keg| ohai "Checking #{keg.name} linkage" if ARGV.kegs.size > 1 result = LinkageChecker.new(keg) if ARGV.include?("--test") result.display_test_output - if result.broken_dylibs? || result.undeclared_deps? - Homebrew.failed = true - end elsif ARGV.include?("--reverse") result.display_reverse_output else result.display_normal_output end + found_broken_dylibs = true unless result.broken_dylibs.empty? + end + if ARGV.include?("--test") && found_broken_dylibs + exit 1 end end class LinkageChecker attr_reader :keg - attr_reader :brewed_dylibs, :system_dylibs, :broken_dylibs, :variable_dylibs - attr_reader :undeclared_deps, :reverse_links + attr_reader :broken_dylibs def initialize(keg) @keg = keg @brewed_dylibs = Hash.new { |h, k| h[k] = Set.new } @system_dylibs = Set.new @broken_dylibs = Set.new @variable_dylibs = Set.new - @undeclared_deps = [] @reverse_links = Hash.new { |h, k| h[k] = Set.new } check_dylibs end @@ -84,6 +84,7 @@ def check_dylibs @undeclared_deps -= [f.name] rescue FormulaUnavailableError opoo "Formula unavailable: #{keg.name}" + @undeclared_deps = [] end end @@ -111,16 +112,6 @@ def display_reverse_output def display_test_output display_items "Missing libraries", @broken_dylibs puts "No broken dylib links" if @broken_dylibs.empty? - display_items "Possible undeclared dependencies", @undeclared_deps - puts "No undeclared dependencies" if @undeclared_deps.empty? - end - - def broken_dylibs? - !@broken_dylibs.empty? - end - - def undeclared_deps? - !@undeclared_deps.empty? end private
false
Other
Homebrew
brew
68bbe6ee5fc723f154d4a2372997d5bd9682a554.json
Use GitRepositoryExtension for 'path' in Tap Closes #464. Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
Library/Homebrew/tap.rb
@@ -62,6 +62,7 @@ def initialize(user, repo) @repo = repo @name = "#{@user}/#{@repo}".downcase @path = TAP_DIRECTORY/"#{@user}/homebrew-#{@repo}".downcase + @path.extend(GitRepositoryExtension) end # clear internal cache @@ -84,15 +85,8 @@ def clear_cache # The remote path to this {Tap}. # e.g. `https://github.com/user/homebrew-repo` def remote - @remote ||= if installed? - if git? && Utils.git_available? - path.cd do - Utils.popen_read("git", "config", "--get", "remote.origin.url").chomp - end - end - else - raise TapUnavailableError, name - end + raise TapUnavailableError, name unless installed? + @remote ||= path.git_origin end # The default remote path to this {Tap}. @@ -102,35 +96,31 @@ def default_remote # True if this {Tap} is a git repository. def git? - (path/".git").exist? + path.git? end # git HEAD for this {Tap}. def git_head raise TapUnavailableError, name unless installed? - return unless git? && Utils.git_available? - path.cd { Utils.popen_read("git", "rev-parse", "--verify", "-q", "HEAD").chuzzle } + path.git_head end # git HEAD in short format for this {Tap}. def git_short_head raise TapUnavailableError, name unless installed? - return unless git? && Utils.git_available? - path.cd { Utils.popen_read("git", "rev-parse", "--short=4", "--verify", "-q", "HEAD").chuzzle } + path.git_short_head end # time since git last commit for this {Tap}. def git_last_commit raise TapUnavailableError, name unless installed? - return unless git? && Utils.git_available? - path.cd { Utils.popen_read("git", "show", "-s", "--format=%cr", "HEAD").chuzzle } + path.git_last_commit end # git last commit date for this {Tap}. def git_last_commit_date raise TapUnavailableError, name unless installed? - return unless git? && Utils.git_available? - path.cd { Utils.popen_read("git", "show", "-s", "--format=%cd", "--date=short", "HEAD").chuzzle } + path.git_last_commit_date end # The issues URL of this {Tap}.
false
Other
Homebrew
brew
77dd9d56ff39f77391d2f429a9ff25e65a362ba2.json
Use GitRepositoryExtension for HOMEBREW_REPOSITORY
Library/Homebrew/diagnostic.rb
@@ -805,7 +805,7 @@ def check_git_newline_settings def check_git_origin return if !Utils.git_available? || !(HOMEBREW_REPOSITORY/".git").exist? - origin = Homebrew.git_origin + origin = HOMEBREW_REPOSITORY.git_origin if origin.nil? <<-EOS.undent
true
Other
Homebrew
brew
77dd9d56ff39f77391d2f429a9ff25e65a362ba2.json
Use GitRepositoryExtension for HOMEBREW_REPOSITORY
Library/Homebrew/formula_installer.rb
@@ -761,7 +761,7 @@ def pour tab.tap = formula.tap tab.poured_from_bottle = true tab.time = Time.now.to_i - tab.head = Homebrew.git_head + tab.head = HOMEBREW_REPOSITORY.git_head tab.write end
true
Other
Homebrew
brew
77dd9d56ff39f77391d2f429a9ff25e65a362ba2.json
Use GitRepositoryExtension for HOMEBREW_REPOSITORY
Library/Homebrew/global.rb
@@ -20,6 +20,8 @@ require "config" +HOMEBREW_REPOSITORY.extend(GitRepositoryExtension) + if RbConfig.respond_to?(:ruby) RUBY_PATH = Pathname.new(RbConfig.ruby) else
true
Other
Homebrew
brew
77dd9d56ff39f77391d2f429a9ff25e65a362ba2.json
Use GitRepositoryExtension for HOMEBREW_REPOSITORY
Library/Homebrew/system_config.rb
@@ -23,15 +23,15 @@ def clang_build end def head - Homebrew.git_head || "(none)" + HOMEBREW_REPOSITORY.git_head || "(none)" end def last_commit - Homebrew.git_last_commit || "never" + HOMEBREW_REPOSITORY.git_last_commit || "never" end def origin - Homebrew.git_origin || "(none)" + HOMEBREW_REPOSITORY.git_origin || "(none)" end def core_tap_head
true
Other
Homebrew
brew
77dd9d56ff39f77391d2f429a9ff25e65a362ba2.json
Use GitRepositoryExtension for HOMEBREW_REPOSITORY
Library/Homebrew/tab.rb
@@ -24,7 +24,7 @@ def self.create(formula, compiler, stdlib, build, source_modified_time) "poured_from_bottle" => false, "time" => Time.now.to_i, "source_modified_time" => source_modified_time.to_i, - "HEAD" => Homebrew.git_head, + "HEAD" => HOMEBREW_REPOSITORY.git_head, "compiler" => compiler, "stdlib" => stdlib, "source" => {
true
Other
Homebrew
brew
77dd9d56ff39f77391d2f429a9ff25e65a362ba2.json
Use GitRepositoryExtension for HOMEBREW_REPOSITORY
Library/Homebrew/utils.rb
@@ -198,34 +198,9 @@ def self.system(cmd, *args) _system(cmd, *args) end - def self.git_origin - return unless Utils.git_available? - HOMEBREW_REPOSITORY.cd { `git config --get remote.origin.url 2>/dev/null`.chuzzle } - end - - def self.git_head - return unless Utils.git_available? - HOMEBREW_REPOSITORY.cd { `git rev-parse --verify -q HEAD 2>/dev/null`.chuzzle } - end - - def self.git_short_head - return unless Utils.git_available? - HOMEBREW_REPOSITORY.cd { `git rev-parse --short=4 --verify -q HEAD 2>/dev/null`.chuzzle } - end - - def self.git_last_commit - return unless Utils.git_available? - HOMEBREW_REPOSITORY.cd { `git show -s --format="%cr" HEAD 2>/dev/null`.chuzzle } - end - - def self.git_last_commit_date - return unless Utils.git_available? - HOMEBREW_REPOSITORY.cd { `git show -s --format="%cd" --date=short HEAD 2>/dev/null`.chuzzle } - end - def self.homebrew_version_string - if pretty_revision = git_short_head - last_commit = git_last_commit_date + if pretty_revision = HOMEBREW_REPOSITORY.git_short_head + last_commit = HOMEBREW_REPOSITORY.git_last_commit_date "#{HOMEBREW_VERSION} (git revision #{pretty_revision}; last commit #{last_commit})" else "#{HOMEBREW_VERSION} (no git repository)"
true
Other
Homebrew
brew
ec75ca7e42b35ae2932ca3feacfd97e2aab5d278.json
extend/os/mac/diagnostic: remove redundant method Remove an exact duplicate from further up in the same file. (It was accidentally added in 8a582f2bd976ce7044c3b2dc6eef701f94b9ace5.)
Library/Homebrew/extend/os/mac/diagnostic.rb
@@ -271,21 +271,6 @@ def check_for_unsupported_curl_vars EOS end - def check_for_other_package_managers - ponk = MacOS.macports_or_fink - return if ponk.empty? - - <<-EOS.undent - You have MacPorts or Fink installed: - #{ponk.join(", ")} - - This can cause trouble. You don't have to uninstall them, but you may want to - temporarily move them out of the way, e.g. - - sudo mv /opt/local ~/macports - EOS - end - def check_xcode_license_approved # If the user installs Xcode-only, they have to approve the # license or no "xc*" tool will work.
false
Other
Homebrew
brew
11624b9a7da00448e660f1454121a63b3d401729.json
hardware: move generic logic from linux. (#454)
Library/Homebrew/extend/os/linux/hardware/cpu.rb
@@ -1,25 +1,6 @@ module Hardware class CPU class << self - - OPTIMIZATION_FLAGS = { - :penryn => "-march=core2 -msse4.1", - :core2 => "-march=core2", - :core => "-march=prescott" - }.freeze - def optimization_flags - OPTIMIZATION_FLAGS - end - - # Linux supports x86 only, and universal archs do not apply - def arch_32_bit - :i386 - end - - def arch_64_bit - :x86_64 - end - def universal_archs [].extend ArchitectureListExtension end
true
Other
Homebrew
brew
11624b9a7da00448e660f1454121a63b3d401729.json
hardware: move generic logic from linux. (#454)
Library/Homebrew/extend/os/mac/hardware/cpu.rb
@@ -3,19 +3,15 @@ module Hardware class CPU class << self - - OPTIMIZATION_FLAGS = { - :penryn => "-march=core2 -msse4.1", - :core2 => "-march=core2", - :core => "-march=prescott", + PPC_OPTIMIZATION_FLAGS = { :g3 => "-mcpu=750", :g4 => "-mcpu=7400", :g4e => "-mcpu=7450", :g5 => "-mcpu=970", - :g5_64 => "-mcpu=970 -arch ppc64" + :g5_64 => "-mcpu=970 -arch ppc64", }.freeze def optimization_flags - OPTIMIZATION_FLAGS + OPTIMIZATION_FLAGS.merge(PPC_OPTIMIZATION_FLAGS) end # These methods use info spewed out by sysctl.
true
Other
Homebrew
brew
11624b9a7da00448e660f1454121a63b3d401729.json
hardware: move generic logic from linux. (#454)
Library/Homebrew/hardware.rb
@@ -8,6 +8,25 @@ class CPU PPC_64BIT_ARCHS = [:ppc64].freeze class << self + OPTIMIZATION_FLAGS = { + :penryn => "-march=core2 -msse4.1", + :core2 => "-march=core2", + :core => "-march=prescott", + :dunno => "", + }.freeze + + def optimization_flags + OPTIMIZATION_FLAGS + end + + def arch_32_bit + :i386 + end + + def arch_64_bit + :x86_64 + end + def type :dunno end
true
Other
Homebrew
brew
45b3bfd11ac1d9d12d0e885576702eab2acc60cb.json
download_strategy: use short hash for git last_commit Closes #460. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/download_strategy.rb
@@ -592,7 +592,7 @@ def source_modified_time end def last_commit - Utils.popen_read("git", "--git-dir", git_dir ,"rev-parse", "HEAD").chomp + Utils.popen_read("git", "--git-dir", git_dir ,"rev-parse", "--short", "HEAD").chomp end private
false
Other
Homebrew
brew
0b2cc5c20db30f5d0046091f8c2318752f7b0659.json
test_download_strategies: add git tests
Library/Homebrew/test/test_download_strategies.rb
@@ -60,6 +60,69 @@ def cache_tag end end +class GitDownloadStrategyTests < Homebrew::TestCase + include FileUtils + + def setup + resource = ResourceDouble.new("https://github.com/homebrew/foo") + @commit_id = 1 + @strategy = GitDownloadStrategy.new("baz", resource) + @cached_location = @strategy.cached_location + mkpath @cached_location + touch @cached_location/"README" + end + + def teardown + rmtree @cached_location + end + + def git_commit_all + shutup do + system "git", "add", "--all" + system "git", "commit", "-m", "commit number #{@commit_id}" + @commit_id += 1 + end + end + + def inside_repo_using_git_env + initial_env = ENV.to_hash + %w[AUTHOR COMMITTER].each do |role| + ENV["GIT_#{role}_NAME"] = "brew tests" + ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" + ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" + end + @cached_location.cd do + yield + end + ensure + ENV.replace(initial_env) + end + + def setup_git_repo + inside_repo_using_git_env do + shutup do + system "git", "init" + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" + end + git_commit_all + end + end + + def test_source_modified_time + setup_git_repo + assert_equal 1242860651, @strategy.source_modified_time.to_i + end + + def test_last_commit + setup_git_repo + inside_repo_using_git_env do + touch "LICENSE" + git_commit_all + end + assert_equal "c50c79b", @strategy.last_commit + end +end + class DownloadStrategyDetectorTests < Homebrew::TestCase def setup @d = DownloadStrategyDetector.new
false
Other
Homebrew
brew
2f5f352baa95ce9cc6b4e0007ee2fc028ffc2a1a.json
VCSDownloadStrategy: add last_commit method Implement: * VCSDownloadStrategy#last_commit Use last modified file timestamp * SubversionDownloadStrategy#last_commit Use `svn info --show-item revision` * GitDownloadStrategy#last_commit Use `git rev-parse HEAD` * MercurialDownloadStrategy#last_commit Use `hg parent --template {node}` * BazaarDownloadStrategy#last_commit Use `bazaar revno` * FossilDownloadStrategy#last_commit Use `fossil info tip`
Library/Homebrew/download_strategy.rb
@@ -153,6 +153,12 @@ def head? version.head? end + # Return last commit's unique identifier for the repository. + # Return most recent modified timestamp unless overridden. + def last_commit + source_modified_time.to_i.to_s + end + private def cache_tag @@ -501,6 +507,10 @@ def source_modified_time Time.parse REXML::XPath.first(xml, "//date/text()").to_s end + def last_commit + Utils.popen_read("svn", "info", "--show-item", "revision", cached_location.to_s).strip + end + private def repo_url @@ -581,6 +591,10 @@ def source_modified_time Time.parse Utils.popen_read("git", "--git-dir", git_dir, "show", "-s", "--format=%cD") end + def last_commit + Utils.popen_read("git", "--git-dir", git_dir ,"rev-parse", "HEAD").chomp + end + private def cache_tag @@ -818,6 +832,10 @@ def source_modified_time Time.parse Utils.popen_read("hg", "tip", "--template", "{date|isodate}", "-R", cached_location.to_s) end + def last_commit + Utils.popen_read("hg", "parent", "--template", "{node}", "-R", cached_location.to_s) + end + private def cache_tag @@ -854,6 +872,10 @@ def source_modified_time Time.parse Utils.popen_read("bzr", "log", "-l", "1", "--timezone=utc", cached_location.to_s)[/^timestamp: (.+)$/, 1] end + def last_commit + Utils.popen_read("bzr", "revno", cached_location.to_s).chomp + end + private def cache_tag @@ -891,6 +913,10 @@ def source_modified_time Time.parse Utils.popen_read("fossil", "info", "tip", "-R", cached_location.to_s)[/^uuid: +\h+ (.+)$/, 1] end + def last_commit + Utils.popen_read("fossil", "info", "tip", "-R", cached_location.to_s)[/^uuid: +(\h+) .+$/, 1] + end + private def cache_tag
false
Other
Homebrew
brew
61ffa47fd9dc179ddff792db1dc6f55464f6c16b.json
test-bot: fix ruby_has_encoding call regression
Library/Homebrew/dev-cmd/test-bot.rb
@@ -177,7 +177,7 @@ def run verbose = ARGV.verbose? # Step may produce arbitrary output and we read it bytewise, so must # buffer it as binary and convert to UTF-8 once complete - output = Homebrew.ruby_has_encoding? ? "".encode!("BINARY") : "" + output = ruby_has_encoding? ? "".encode!("BINARY") : "" working_dir = Pathname.new(@command.first == "git" ? @repository : Dir.pwd) read, write = IO.pipe
false
Other
Homebrew
brew
a1b0ef1300ff8ac07ef904479b0321a2a5fc0368.json
Remove unnecessary official command tapping.
Library/Homebrew/cmd/tests.rb
@@ -7,21 +7,16 @@ module Homebrew def tests - ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1" - - if ARGV.include? "--official-cmd-taps" - ENV["HOMEBREW_TEST_OFFICIAL_CMD_TAPS"] = "1" - OFFICIAL_CMD_TAPS.each do |tap, _| - tap = Tap.fetch tap - tap.install unless tap.installed? - end - end - (HOMEBREW_LIBRARY/"Homebrew/test").cd do + ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1" ENV["TESTOPTS"] = "-v" if ARGV.verbose? ENV["HOMEBREW_NO_COMPAT"] = "1" if ARGV.include? "--no-compat" ENV["HOMEBREW_TEST_GENERIC_OS"] = "1" if ARGV.include? "--generic" ENV["HOMEBREW_NO_GITHUB_API"] = "1" unless ARGV.include? "--online" + if ARGV.include? "--official-cmd-taps" + ENV["HOMEBREW_TEST_OFFICIAL_CMD_TAPS"] = "1" + end + if ARGV.include? "--coverage" ENV["HOMEBREW_TESTS_COVERAGE"] = "1" FileUtils.rm_f "coverage/.resultset.json"
true
Other
Homebrew
brew
a1b0ef1300ff8ac07ef904479b0321a2a5fc0368.json
Remove unnecessary official command tapping.
Library/Homebrew/dev-cmd/test-bot.rb
@@ -656,9 +656,6 @@ def homebrew if @tap.nil? tests_args = [] if ruby_two - test "brew", "tap", "caskroom/cask" - test "brew", "tap", "homebrew/bundle" - test "brew", "tap", "homebrew/services" tests_args << "--official-cmd-taps" tests_args << "--coverage" if ENV["TRAVIS"] end
true
Other
Homebrew
brew
a1b0ef1300ff8ac07ef904479b0321a2a5fc0368.json
Remove unnecessary official command tapping.
Library/Homebrew/test/test_integration_cmds.rb
@@ -130,6 +130,12 @@ class #{Formulary.class_s(name)} < Formula formula_path end + def setup_remote_tap(name) + tap = Tap.fetch name + tap.install(:full_clone => false, :quiet => true) unless tap.installed? + tap + end + def testball "#{File.expand_path("..", __FILE__)}/testball.rb" end @@ -677,6 +683,7 @@ def test_search def test_bundle needs_test_cmd_taps + setup_remote_tap("homebrew/bundle") HOMEBREW_REPOSITORY.cd do shutup do system "git", "init" @@ -693,16 +700,24 @@ def test_bundle end ensure FileUtils.rm_rf HOMEBREW_REPOSITORY/".git" + FileUtils.rm_rf HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bundle" end def test_cask needs_test_cmd_taps + setup_remote_tap("caskroom/cask") cmd("cask", "list") + ensure + FileUtils.rm_rf HOMEBREW_LIBRARY/"Taps/caskroom" + FileUtils.rm_rf HOMEBREW_PREFIX/"share" end def test_services needs_test_cmd_taps + setup_remote_tap("homebrew/services") assert_equal "Warning: No services available to control with `brew services`", cmd("services", "list") + ensure + FileUtils.rm_rf HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-services" end end
true