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
1d7aa1fe0b430a4415cb976a2b2c3041f4269b55.json
superenv: help Autotools with 10.12 SDK on 10.11 The GNU Autotools tests for whether a given symbol is defined are reliably coming to incorrect conclusions on 10.11 with the 10.12 SDK in Xcode 8. This overrides its decisions by forcing the right answer in superenv using ac_cv_func_* environment variables and setting them to "no" on 10.11. The list of problematic symbols is from grep 'weak$os10.11' MacOSX.sdk/usr/lib/system/libsystem_c.tbd
Library/Homebrew/extend/os/mac/extend/ENV/super.rb
@@ -94,6 +94,15 @@ def setup_build_environment(formula = nil) self["SDKROOT"] = MacOS.sdk_path end + # Filter out symbols known not to be defined on 10.11 since GNU Autotools + # can't reliably figure this out with Xcode 8 on its own yet. + if MacOS.version == "10.11" && MacOS::Xcode.installed? && MacOS::Xcode.version >= "8.0" + %w[basename_r clock_getres clock_gettime clock_settime dirname_r + getentropy mkostemp mkostemps].each do |s| + ENV["ac_cv_func_#{s}"] = "no" + end + end + # On 10.9, the tools in /usr/bin proxy to the active developer directory. # This means we can use them for any combination of CLT and Xcode. self["HOMEBREW_PREFER_CLT_PROXIES"] = "1" if MacOS.version >= "10.9"
false
Other
Homebrew
brew
842d6ce8bdc2296869c41c5866bbf5f046ac6eb8.json
keg: add ALL_TOP_LEVEL_DIRECTORIES constant. This is used in diagnostic (and will be used in other places later) rather than hard-coding other directories later.
Library/Homebrew/diagnostic.rb
@@ -308,8 +308,7 @@ def check_access_homebrew_repository def check_access_prefix_directories not_writable_dirs = [] - extra_dirs = ["lib/pkgconfig", "share/locale", "share/man", "opt"] - (Keg::TOP_LEVEL_DIRECTORIES + extra_dirs).each do |dir| + Keg::ALL_TOP_LEVEL_DIRECTORIES.each do |dir| path = HOMEBREW_PREFIX/dir next unless path.exist? next if path.writable_real?
true
Other
Homebrew
brew
842d6ce8bdc2296869c41c5866bbf5f046ac6eb8.json
keg: add ALL_TOP_LEVEL_DIRECTORIES constant. This is used in diagnostic (and will be used in other places later) rather than hard-coding other directories later.
Library/Homebrew/keg.rb
@@ -65,6 +65,7 @@ def to_s; <<-EOS.undent LOCALEDIR_RX = /(locale|man)\/([a-z]{2}|C|POSIX)(_[A-Z]{2})?(\.[a-zA-Z\-0-9]+(@.+)?)?/ INFOFILE_RX = %r{info/([^.].*?\.info|dir)$} TOP_LEVEL_DIRECTORIES = %w[bin etc include lib sbin share var Frameworks] + ALL_TOP_LEVEL_DIRECTORIES = (TOP_LEVEL_DIRECTORIES + %w[lib/pkgconfig share/locale share/man opt]).freeze PRUNEABLE_DIRECTORIES = %w[bin etc include lib sbin share Frameworks LinkedKegs].map do |d| case d when "LinkedKegs" then HOMEBREW_LIBRARY/d else HOMEBREW_PREFIX/d end end
true
Other
Homebrew
brew
49e9be1970ae7f58d9ed64ac2dad5187a3ea6d5d.json
Formula-Cookbook: note audit --new-formula for new formula
share/doc/homebrew/Formula-Cookbook.md
@@ -306,7 +306,7 @@ Add aliases by creating symlinks in an `Aliases` directory in the tap root. You can run `brew audit --strict --online` to test formulae for adherence to Homebrew house style. The `audit` command includes warnings for trailing whitespace, preferred URLs for certain source hosts, and a lot of other style issues. Fixing these warnings before committing will make the process a lot quicker for everyone. -New formulae being submitted to Homebrew should run `brew audit --strict --online foo`. This command is performed by the Brew Test Bot on new submissions as part of the automated build and test process, and highlights more potential issues than the standard audit. +New formulae being submitted to Homebrew should run `brew audit --new-formula foo`. This command is performed by the Brew Test Bot on new submissions as part of the automated build and test process, and highlights more potential issues than the standard audit. Use `brew info` and check if the version guessed by Homebrew from the URL is correct. Add an explicit [`version`](http://www.rubydoc.info/github/Homebrew/brew/master/Formula#version-class_method) if not.
false
Other
Homebrew
brew
e4f607e4c8a4368a506edfcbbecfe6d24abc7f34.json
Custom-GCC-and-cross-compilers: remove dead taps
share/doc/homebrew/Custom-GCC-and-cross-compilers.md
@@ -9,7 +9,4 @@ Rather than merging in brews for either of these cases at this time, we're listi * Homebrew provides a `gcc` formula for use with Xcode 4.2+ or when needing C++11 support on earlier versions. * [Homebrew-versions](https://github.com/homebrew/homebrew-versions) provides an up to date GCC duplicates e.g. `brew install homebrew/versions/gcc48` -* [MSP430 development](https://github.com/Homebrew/homebrew/issues/issue/2336) -* [OS161 development](https://github.com/maxpow4h/homebrew-os161) Your university probably uses a different version, replacing the URLs with your university's URLs will probably work. -* [ARM-EABI](https://github.com/paxswill/homebrew-paxswill) provides an arm-none-eabi toolchain formula. * [RISC-V](https://github.com/riscv/homebrew-riscv) provides the RISC-V toolchain including binutils and gcc.
false
Other
Homebrew
brew
4cec6f5dd0aed2ece19b5d3e755d7da7d4178b13.json
Teach brew to recognize gcc-HEAD as valid compiler Building gcc with --HEAD results in most of the executables not having a version suffix, e.g. Building/installing gcc 6 would result in gcc-6, g++-6, etc. being installed, while building/installing gcc --HEAD would result in gcc-, g++-, etc. being installed. The lack of a version suffix prevented brew from recognizing a valid gcc install, resulting in brew instructing users to install gcc before building certain formulae even though gcc is installed. A patch to the gcc formula makes the version number for --HEAD builds the major version number of the stable version + 1 (7 at this time). This patch teaches brew to recognize current --HEAD builds as valid compilers.
Library/Homebrew/compilers.rb
@@ -1,7 +1,7 @@ # @private module CompilerConstants - GNU_GCC_VERSIONS = %w[4.3 4.4 4.5 4.6 4.7 4.8 4.9 5 6] - GNU_GCC_REGEXP = /^gcc-(4\.[3-9]|[5-6])$/ + GNU_GCC_VERSIONS = %w[4.3 4.4 4.5 4.6 4.7 4.8 4.9 5 6 7] + GNU_GCC_REGEXP = /^gcc-(4\.[3-9]|[5-7])$/ COMPILER_SYMBOL_MAP = { "gcc-4.0" => :gcc_4_0, "gcc-4.2" => :gcc,
false
Other
Homebrew
brew
b42f646cec2f8d2ced09e98e9cd37375a183f94d.json
extend/pathname: fix Rubocop warnings.
Library/Homebrew/extend/pathname.rb
@@ -20,7 +20,7 @@ def abv out = "" compute_disk_usage out << "#{number_readable(@file_count)} files, " if @file_count > 1 - out << "#{disk_usage_readable(@disk_usage)}" + out << disk_usage_readable(@disk_usage).to_s end private @@ -153,7 +153,7 @@ def binwrite(contents, *open_args) end unless method_defined?(:binwrite) def binread(*open_args) - open("rb", *open_args) { |f| f.read } + open("rb", *open_args, &:read) end unless method_defined?(:binread) # NOTE always overwrites @@ -196,7 +196,7 @@ def default_stat # @private def cp_path_sub(pattern, replacement) - raise "#{self} does not exist" unless self.exist? + raise "#{self} does not exist" unless exist? dst = sub(pattern, replacement) @@ -295,7 +295,7 @@ def compression_type # @private def text_executable? - /^#!\s*\S+/ === open("r") { |f| f.read(1024) } + /^#!\s*\S+/ =~ open("r") { |f| f.read(1024) } end # @private @@ -334,7 +334,7 @@ def subdirs # @private def resolved_path - self.symlink? ? dirname+readlink : self + symlink? ? dirname+readlink : self end # @private
false
Other
Homebrew
brew
6a81782753d660eb3a9b6b2f303015205177c518.json
extend/os/mac/development_tools: fix Rubocop warnings.
Library/Homebrew/extend/os/mac/development_tools.rb
@@ -24,10 +24,10 @@ def installed? def installation_instructions if MacOS.version >= "10.9" - <<-EOS.undent - Install the Command Line Tools: - xcode-select --install - EOS + <<-EOS.undent + Install the Command Line Tools: + xcode-select --install + EOS elsif MacOS.version == "10.8" || MacOS.version == "10.7" <<-EOS.undent Install the Command Line Tools from
false
Other
Homebrew
brew
df5605fa01cea58928d39bf12b27912c39c3f646.json
extend/fileutils: fix Rubocop warnings.
Library/Homebrew/extend/fileutils.rb
@@ -60,10 +60,10 @@ def run # > When a new file is created, it is given the group of the directory which # contains it. group_id = if HOMEBREW_BREW_FILE.grpowned? - HOMEBREW_BREW_FILE.stat.gid - else - Process.gid - end + HOMEBREW_BREW_FILE.stat.gid + else + Process.gid + end begin chown(nil, group_id, tmpdir) rescue Errno::EPERM
false
Other
Homebrew
brew
fb3bec8d70d375a97554d4c3fed82ad2332b2191.json
extend/ENV/super: fix Rubocop warnings.
Library/Homebrew/extend/ENV/super.rb
@@ -183,7 +183,7 @@ def determine_library_paths end def determine_dependencies - deps.map {|d| d.name}.join(",") + deps.map(&:name).join(",") end def determine_cmake_prefix_path
false
Other
Homebrew
brew
c3dab72e3726c3519b39ce1ef5baa31b24198d41.json
extend/ENV/std: fix Rubocop warnings.
Library/Homebrew/extend/ENV/std.rb
@@ -7,8 +7,8 @@ module Stdenv include SharedEnvExtension # @private - SAFE_CFLAGS_FLAGS = "-w -pipe" - DEFAULT_FLAGS = "-march=core2 -msse4" + SAFE_CFLAGS_FLAGS = "-w -pipe".freeze + DEFAULT_FLAGS = "-march=core2 -msse4".freeze def self.extended(base) unless ORIGINAL_PATHS.include? HOMEBREW_PREFIX/"bin"
false
Other
Homebrew
brew
fe661a809c8ec497c8096ec062908ddcb2c84a03.json
extend/ENV/shared: fix Rubocop warnings.
Library/Homebrew/extend/ENV/shared.rb
@@ -12,9 +12,9 @@ module SharedEnvExtension include CompilerConstants # @private - CC_FLAG_VARS = %w[CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS] + CC_FLAG_VARS = %w[CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS].freeze # @private - FC_FLAG_VARS = %w[FCFLAGS FFLAGS] + FC_FLAG_VARS = %w[FCFLAGS FFLAGS].freeze # @private SANITIZED_VARS = %w[ CDPATH GREP_OPTIONS CLICOLOR_FORCE @@ -25,7 +25,7 @@ module SharedEnvExtension CMAKE_PREFIX_PATH CMAKE_INCLUDE_PATH CMAKE_FRAMEWORK_PATH GOBIN GOPATH GOROOT PERL_MB_OPT PERL_MM_OPT LIBRARY_PATH - ] + ].freeze # @private def setup_build_environment(formula = nil) @@ -193,13 +193,19 @@ def ncurses_define def userpaths! paths = self["PATH"].split(File::PATH_SEPARATOR) # put Superenv.bin and opt path at the first - new_paths = paths.select { |p| p.start_with?("#{HOMEBREW_REPOSITORY}/Library/ENV") || p.start_with?("#{HOMEBREW_PREFIX}/opt") } + new_paths = paths.select { |p| p.start_with?("#{HOMEBREW_REPOSITORY}/Library/ENV", "#{HOMEBREW_PREFIX}/opt") } # XXX hot fix to prefer brewed stuff (e.g. python) over /usr/bin. new_paths << "#{HOMEBREW_PREFIX}/bin" # reset of self["PATH"] new_paths += paths # user paths - new_paths += ORIGINAL_PATHS.map { |p| p.realpath.to_s rescue nil } - %w[/usr/X11/bin /opt/X11/bin] + new_paths += ORIGINAL_PATHS.map do |p| + begin + p.realpath.to_s + rescue + nil + end + end - %w[/usr/X11/bin /opt/X11/bin] self["PATH"] = new_paths.uniq.join(File::PATH_SEPARATOR) end
false
Other
Homebrew
brew
17a7c2388193de0c7aed556df92ca955ffec2753.json
extend/ARGV: fix Rubocop warnings.
Library/Homebrew/extend/ARGV.rb
@@ -57,7 +57,7 @@ def kegs dirs = rack.directory? ? rack.subdirs : [] - raise NoSuchKegError.new(rack.basename) if dirs.empty? + raise NoSuchKegError, rack.basename if dirs.empty? linked_keg_ref = HOMEBREW_LIBRARY.join("LinkedKegs", rack.basename) opt_prefix = HOMEBREW_PREFIX.join("opt", rack.basename) @@ -79,7 +79,7 @@ def kegs if (prefix = f.installed_prefix).directory? Keg.new(prefix) else - raise MultipleVersionsInstalledError.new(rack.basename) + raise MultipleVersionsInstalledError, rack.basename end end rescue FormulaUnavailableError @@ -211,7 +211,7 @@ def build_all_from_source? # installation run. def build_formula_from_source?(f) return true if build_all_from_source? - return false unless (build_from_source? || build_bottle?) + return false unless build_from_source? || build_bottle? formulae.any? { |argv_f| argv_f.full_name == f.full_name } end
false
Other
Homebrew
brew
793a75f3f3e5b46639683df610cc819d796cbba8.json
test-bot: fix bottling non-testing jobs. Need to handle when the `BOT_PARAMS` are `nil`.
Library/Homebrew/dev-cmd/test-bot.rb
@@ -912,7 +912,7 @@ def test_ci_upload(tap) safe_system "brew", "pull", "--clean", pull_pr end - if ENV["UPSTREAM_BOTTLE_KEEP_OLD"] || ENV["BOT_PARAMS"].include?("--keep-old") + if ENV["UPSTREAM_BOTTLE_KEEP_OLD"] || ENV["BOT_PARAMS"].to_s.include?("--keep-old") system "brew", "bottle", "--merge", "--write", "--keep-old", *json_files else system "brew", "bottle", "--merge", "--write", *json_files
false
Other
Homebrew
brew
debc202d1e1e819d9263c85c80669252b3dd650c.json
bottle: remove debug statements.
Library/Homebrew/dev-cmd/bottle.rb
@@ -287,9 +287,6 @@ def bottle_formula(f) bottle.sha256 sha256 => Utils::Bottles.tag old_spec = f.bottle_specification - p root_url - p old_spec.root_url(root_url) - p bottle.root_url(root_url) if ARGV.include?("--keep-old") && !old_spec.checksums.empty? mismatches = [:root_url, :prefix, :cellar, :rebuild].select do |key| old_spec.send(key) != bottle.send(key)
false
Other
Homebrew
brew
e4ef1f062e7af00db859e205043b127afe33272f.json
test-bot: fix regex placement.
Library/Homebrew/dev-cmd/test-bot.rb
@@ -403,7 +403,7 @@ def diff_formulae(start_revision, end_revision, path, filter) @short_url = @url.gsub("https://github.com/", "") if @short_url.include? "/commit/" # 7 characters should be enough for a commit (not 40). - @short_url.gsub!(%r{(commit/\w{7}).*/, '\1'}) + @short_url.gsub!(%r{(commit/\w{7}).*/}, '\1') @name = @short_url else @name = "#{@short_url}-#{diff_end_sha1}" @@ -631,7 +631,7 @@ def formula(formula_name) bottle_step = steps.last if bottle_step.passed? && bottle_step.output? bottle_filename = - bottle_step.output.gsub(%r{.*(\./\S+#{Utils::Bottles.native_regex}).*/m, '\1'}) + bottle_step.output.gsub(%r{.*(\./\S+#{Utils::Bottles.native_regex}).*/m}, '\1') bottle_json_filename = bottle_filename.gsub(/\.(\d+\.)?tar\.gz$/, ".json") bottle_merge_args = ["--merge", "--write", "--no-commit", bottle_json_filename] bottle_merge_args << "--keep-old" if ARGV.include? "--keep-old"
false
Other
Homebrew
brew
e24a890e593d665e8f4bad2588879602e3918a87.json
test/test_tab: fix Rubocop warnings.
Library/Homebrew/test/test_tab.rb
@@ -24,7 +24,7 @@ def setup "stable" => "0.10", "devel" => "0.14", "head" => "HEAD-1111111", - } + }, }) end
false
Other
Homebrew
brew
d937f239324380c839fae6e7ebf9ab97f31e370f.json
test/test_shell: fix Rubocop warnings.
Library/Homebrew/test/test_shell.rb
@@ -2,7 +2,7 @@ require "utils/shell" class ShellSmokeTest < Homebrew::TestCase - def test_path_to_shell() + def test_path_to_shell # raw command name assert_equal :bash, Utils::Shell.path_to_shell("bash") # full path @@ -13,21 +13,21 @@ def test_path_to_shell() assert_equal :zsh, Utils::Shell.path_to_shell("zsh-5.2\n") end - def test_path_to_shell_failure() + def test_path_to_shell_failure assert_equal nil, Utils::Shell.path_to_shell("") assert_equal nil, Utils::Shell.path_to_shell("@@@@@@") assert_equal nil, Utils::Shell.path_to_shell("invalid_shell-4.2") end - def test_sh_quote() + def test_sh_quote assert_equal "''", Utils::Shell.sh_quote("") assert_equal "\\\\", Utils::Shell.sh_quote("\\") assert_equal "'\n'", Utils::Shell.sh_quote("\n") assert_equal "\\$", Utils::Shell.sh_quote("$") assert_equal "word", Utils::Shell.sh_quote("word") end - def test_csh_quote() + def test_csh_quote assert_equal "''", Utils::Shell.csh_quote("") assert_equal "\\\\", Utils::Shell.csh_quote("\\") # note this test is different than for sh @@ -49,7 +49,7 @@ def prepend_path_shell(shell, path, fragment) ENV["SHELL"] = original_shell end - def test_prepend_path_in_shell_profile() + def test_prepend_path_in_shell_profile prepend_path_shell "/bin/tcsh", "/path", "echo 'setenv PATH /path" prepend_path_shell "/bin/bash", "/path", "echo 'export PATH=\"/path"
false
Other
Homebrew
brew
fc7ac2f07b93a4037652df673cafce6619598f6b.json
test/test_resource: fix Rubocop warnings.
Library/Homebrew/test/test_resource.rb
@@ -100,8 +100,8 @@ def test_checksum_setters def test_download_strategy strategy = Object.new - DownloadStrategyDetector. - expects(:detect).with("foo", nil).returns(strategy) + DownloadStrategyDetector + .expects(:detect).with("foo", nil).returns(strategy) @resource.url("foo") assert_equal strategy, @resource.download_strategy end @@ -120,8 +120,8 @@ def test_verify_download_integrity_mismatch fn = stub(:file? => true) checksum = @resource.sha256(TEST_SHA256) - fn.expects(:verify_checksum).with(checksum). - raises(ChecksumMismatchError.new(fn, checksum, Object.new)) + fn.expects(:verify_checksum).with(checksum) + .raises(ChecksumMismatchError.new(fn, checksum, Object.new)) shutup do assert_raises(ChecksumMismatchError) do
false
Other
Homebrew
brew
501774e3bc73d5dd367054b954893d9561bf00d2.json
test/test_os_mac_language: fix Rubocop warnings.
Library/Homebrew/test/test_os_mac_language.rb
@@ -3,6 +3,6 @@ class OSMacLanguageTests < Homebrew::TestCase def test_language_format - assert_match %r{\A[a-z]{2}(-[A-Z]{2})?\Z}, OS::Mac.language + assert_match(/\A[a-z]{2}(-[A-Z]{2})?\Z/, OS::Mac.language) end end
false
Other
Homebrew
brew
e89de3351f69a99bdc5d528c7abe3f771ae47b56.json
test/test_integration_cmds: fix Rubocop warnings.
Library/Homebrew/test/test_integration_cmds.rb
@@ -99,15 +99,15 @@ def cmd_output(*args) def cmd(*args) output = cmd_output(*args) status = $?.exitstatus - puts "\n#{output}" if status != 0 + puts "\n#{output}" if status.nonzero? assert_equal 0, status output end def cmd_fail(*args) output = cmd_output(*args) status = $?.exitstatus - $stderr.puts "\n#{output}" if status == 0 + $stderr.puts "\n#{output}" if status.zero? refute_equal 0, status output end @@ -228,23 +228,23 @@ def test_env end def test_env_bash - assert_match %r{export CMAKE_PREFIX_PATH="#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"}, - cmd("--env", "--shell=bash") + assert_match(/export CMAKE_PREFIX_PATH="#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/, + cmd("--env", "--shell=bash")) end def test_env_fish - assert_match %r{set [-]gx CMAKE_PREFIX_PATH "#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"}, - cmd("--env", "--shell=fish") + assert_match(/set [-]gx CMAKE_PREFIX_PATH "#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/, + cmd("--env", "--shell=fish")) end def test_env_csh - assert_match %r{setenv CMAKE_PREFIX_PATH #{Regexp.quote(HOMEBREW_PREFIX.to_s)};}, - cmd("--env", "--shell=tcsh") + assert_match(/setenv CMAKE_PREFIX_PATH #{Regexp.quote(HOMEBREW_PREFIX.to_s)};/, + cmd("--env", "--shell=tcsh")) end def test_env_plain - assert_match %r{CMAKE_PREFIX_PATH: #{Regexp.quote(HOMEBREW_PREFIX)}}, - cmd("--env", "--plain") + assert_match(/CMAKE_PREFIX_PATH: #{Regexp.quote(HOMEBREW_PREFIX)}/, + cmd("--env", "--plain")) end def test_prefix_formula
false
Other
Homebrew
brew
2cf6184735050319a78063111b6f464f2320e2b7.json
test/test_formula_installer: fix Rubocop warnings.
Library/Homebrew/test/test_formula_installer.rb
@@ -110,7 +110,7 @@ class #{Formulary.class_s(dep_name)} < Formula dependent = formula do url "foo" version "0.5" - depends_on "#{dependency.name}" + depends_on dependency.name.to_s end dependency.prefix("0.1").join("bin/a").mkpath
false
Other
Homebrew
brew
0f09674fe61f58572190f263d9173422d4e417d8.json
test/test_formula: fix Rubocop warnings.
Library/Homebrew/test/test_formula.rb
@@ -574,7 +574,7 @@ def test_pour_bottle_dsl url "foo-1.0" pour_bottle? do reason "true reason" - satisfy { var == var } + satisfy { true } end end assert f_true.pour_bottle? @@ -586,7 +586,10 @@ class OutdatedVersionsTests < Homebrew::TestCase attr_reader :f def setup - @f = formula { url "foo"; version "1.20" } + @f = formula do + url "foo" + version "1.20" + end @outdated_prefix = HOMEBREW_CELLAR/"#{f.name}/1.11" @same_prefix = HOMEBREW_CELLAR/"#{f.name}/1.20" @greater_prefix = HOMEBREW_CELLAR/"#{f.name}/1.21"
false
Other
Homebrew
brew
219c373115dea67d7753ab51e1e95f5f41e8e9f8.json
test/test_dependency_collector: fix Rubocop warnings.
Library/Homebrew/test/test_dependency_collector.rb
@@ -7,7 +7,7 @@ def find_dependency(name) end def find_requirement(klass) - @d.requirements.find { |req| klass === req } + @d.requirements.find { |req| req.is_a? klass } end def setup
false
Other
Homebrew
brew
df1f9806a4e82d3a4f2a2a793f5ac8b6778344c1.json
test-bot: handle more Jenkins configurations. Used in trying to use a `Jenkinsfile`.
Library/Homebrew/dev-cmd/test-bot.rb
@@ -883,11 +883,12 @@ def test_ci_upload(tap) job = ENV["UPSTREAM_JOB_NAME"] id = ENV["UPSTREAM_BUILD_ID"] raise "Missing Jenkins variables!" if !jenkins || !job || !id + bottles = Dir["#{jenkins}/jobs/#{job}/configurations/axis-version/*/builds/#{id}/archive/*.bottle*.*"] return if bottles.empty? - end - FileUtils.cp bottles, Dir.pwd, :verbose => true + FileUtils.cp bottles, Dir.pwd, :verbose => true + end json_files = Dir.glob("*.bottle.json") bottles_hash = json_files.reduce({}) do |hash, json_file| @@ -902,29 +903,34 @@ def test_ci_upload(tap) ENV["GIT_WORK_TREE"] = tap.path ENV["GIT_DIR"] = "#{ENV["GIT_WORK_TREE"]}/.git" - pr = ENV["UPSTREAM_PULL_REQUEST"] - number = ENV["UPSTREAM_BUILD_NUMBER"] - quiet_system "git", "am", "--abort" quiet_system "git", "rebase", "--abort" safe_system "git", "checkout", "-f", "master" safe_system "git", "reset", "--hard", "origin/master" safe_system "brew", "update" - if pr + if (pr = ENV["UPSTREAM_PULL_REQUEST"]) pull_pr = "https://github.com/#{tap.user}/homebrew-#{tap.repo}/pull/#{pr}" safe_system "brew", "pull", "--clean", pull_pr end - if ENV["UPSTREAM_BOTTLE_KEEP_OLD"] + if ENV["UPSTREAM_BOTTLE_KEEP_OLD"] || ENV["BOT_PARAMS"].include?("--keep-old") system "brew", "bottle", "--merge", "--write", "--keep-old", *json_files else system "brew", "bottle", "--merge", "--write", *json_files end remote = "git@github.com:BrewTestBot/homebrew-#{tap.repo}.git" - git_tag = pr ? "pr-#{pr}" : "testing-#{number}" - safe_system "git", "push", "--force", remote, "master:master", ":refs/tags/#{git_tag}" + git_tag = if pr + "pr-#{pr}" + elsif (upstream_number = ENV["UPSTREAM_BUILD_NUMBER"]) + "testing-#{upstream_number}" + elsif (number = ENV["BUILD_NUMBER"]) + "other-#{number}" + end + if git_tag + safe_system "git", "push", "--force", remote, "master:master", ":refs/tags/#{git_tag}" + end formula_packaged = {} @@ -969,8 +975,10 @@ def test_ci_upload(tap) end end - safe_system "git", "tag", "--force", git_tag - safe_system "git", "push", "--force", remote, "master:master", "refs/tags/#{git_tag}" + if git_tag + safe_system "git", "tag", "--force", git_tag + safe_system "git", "push", "--force", remote, "master:master", "refs/tags/#{git_tag}" + end end def sanitize_ARGV_and_ENV
false
Other
Homebrew
brew
51bda9c90efe3c3fbc197b6c1db793575444a711.json
dev-cmd/test-bot: fix Rubocop warnings.
Library/Homebrew/dev-cmd/test-bot.rb
@@ -120,7 +120,7 @@ def resolve_test_tap if git_url = ENV["UPSTREAM_GIT_URL"] || ENV["GIT_URL"] # Also can get tap from Jenkins GIT_URL. - url_path = git_url.sub(%r{^https?://github\.com/}, "").chomp("/").sub(%r{\.git$}, "") + url_path = git_url.sub(%r{^https?://github\.com/}, "").chomp("/").sub(/\.git$/, "") begin return Tap.fetch(url_path) if url_path =~ HOMEBREW_TAP_REGEX rescue @@ -190,7 +190,7 @@ def puts_result puts "#{Tty.white}==>#{Tty.red} FAILED#{Tty.reset}" if failed? end - def has_output? + def output? @output && !@output.empty? end @@ -245,7 +245,6 @@ def run @status = $?.success? ? :passed : :failed puts_result - unless output.empty? @output = Homebrew.fix_encoding!(output) puts @output if (failed? || @puts_output_on_success) && !verbose @@ -259,7 +258,7 @@ def run class Test attr_reader :log_root, :category, :name, :steps - def initialize(argument, options={}) + def initialize(argument, options = {}) @hash = nil @url = nil @formulae = [] @@ -277,7 +276,7 @@ def initialize(argument, options={}) elsif canonical_formula_name = safe_formula_canonical_name(argument) @formulae = [canonical_formula_name] else - raise ArgumentError.new("#{argument} is not a pull request URL, commit URL or formula name.") + raise ArgumentError, "#{argument} is not a pull request URL, commit URL or formula name." end @category = __method__ @@ -404,7 +403,7 @@ def diff_formulae(start_revision, end_revision, path, filter) @short_url = @url.gsub("https://github.com/", "") if @short_url.include? "/commit/" # 7 characters should be enough for a commit (not 40). - @short_url.gsub!(/(commit\/\w{7}).*/, '\1') + @short_url.gsub!(%r{(commit/\w{7}).*/, '\1'}) @name = @short_url else @name = "#{@short_url}-#{diff_end_sha1}" @@ -569,7 +568,7 @@ def formula(formula_name) dependents -= @formulae dependents = dependents.map { |d| Formulary.factory(d) } - bottled_dependents = dependents.select { |d| d.bottled? } + bottled_dependents = dependents.select(&:bottled?) testable_dependents = dependents.select { |d| d.bottled? && d.test_defined? } if (deps | reqs).any? { |d| d.name == "mercurial" && d.build? } @@ -630,9 +629,9 @@ def formula(formula_name) bottle_args << "--skip-relocation" if ARGV.include? "--skip-relocation" test "brew", "bottle", *bottle_args bottle_step = steps.last - if bottle_step.passed? && bottle_step.has_output? + if bottle_step.passed? && bottle_step.output? bottle_filename = - bottle_step.output.gsub(/.*(\.\/\S+#{Utils::Bottles::native_regex}).*/m, '\1') + bottle_step.output.gsub(%r{.*(\./\S+#{Utils::Bottles.native_regex}).*/m, '\1'}) bottle_json_filename = bottle_filename.gsub(/\.(\d+\.)?tar\.gz$/, ".json") bottle_merge_args = ["--merge", "--write", "--no-commit", bottle_json_filename] bottle_merge_args << "--keep-old" if ARGV.include? "--keep-old" @@ -666,11 +665,10 @@ def formula(formula_name) next if steps.last.failed? end end - if dependent.installed? - test "brew", "linkage", "--test", dependent.name - if testable_dependents.include? dependent - test "brew", "test", "--verbose", dependent.name - end + next unless dependent.installed? + test "brew", "linkage", "--test", dependent.name + if testable_dependents.include? dependent + test "brew", "test", "--verbose", dependent.name end end test "brew", "uninstall", "--force", formula_name @@ -795,7 +793,7 @@ def cleanup_after end def test(*args) - options = Hash === args.last ? args.pop : {} + options = args.last.is_a?(Hash) ? args.pop : {} options[:repository] = @repository step = Step.new self, args, options step.run @@ -934,7 +932,7 @@ def test_ci_upload(tap) bintray_repo = bottle_hash["bintray"]["repository"] bintray_repo_url = "https://api.bintray.com/packages/homebrew/#{bintray_repo}" - bottle_hash["bottle"]["tags"].each do |tag, tag_hash| + bottle_hash["bottle"]["tags"].each do |_tag, tag_hash| filename = tag_hash["filename"] if system "curl", "-I", "--silent", "--fail", "--output", "/dev/null", "#{BottleSpecification::DEFAULT_DOMAIN}/#{bintray_repo}/#{filename}" @@ -973,7 +971,7 @@ def test_ci_upload(tap) safe_system "git", "push", "--force", remote, "master:master", "refs/tags/#{git_tag}" end - def sanitize_ARGV_and_ENV + def sanitize_argv_and_env if Pathname.pwd == HOMEBREW_PREFIX && ARGV.include?("--cleanup") odie "cannot use --cleanup from HOMEBREW_PREFIX as it will delete all output." end @@ -1016,7 +1014,7 @@ def sanitize_ARGV_and_ENV end def test_bot - sanitize_ARGV_and_ENV + sanitize_argv_and_env tap = resolve_test_tap # Tap repository if required, this is done before everything else @@ -1070,19 +1068,18 @@ def test_bot testcase.add_attribute "status", step.status testcase.add_attribute "time", step.time - if step.has_output? - output = sanitize_output_for_xml(step.output) - cdata = REXML::CData.new output + next unless step.output? + output = sanitize_output_for_xml(step.output) + cdata = REXML::CData.new output - if step.passed? - elem = testcase.add_element "system-out" - else - elem = testcase.add_element "failure" - elem.add_attribute "message", "#{step.status}: #{step.command.join(" ")}" - end - - elem << cdata + if step.passed? + elem = testcase.add_element "system-out" + else + elem = testcase.add_element "failure" + elem.add_attribute "message", "#{step.status}: #{step.command.join(" ")}" end + + elem << cdata end end
false
Other
Homebrew
brew
f1c64f1cdce6f2ce1d45d93e553ae2629c2e419f.json
dev-cmd/pull: fix Rubocop warnings.
Library/Homebrew/dev-cmd/pull.rb
@@ -237,7 +237,7 @@ def force_utf8!(str) private - def publish_changed_formula_bottles(tap, changed_formulae_names) + def publish_changed_formula_bottles(_tap, changed_formulae_names) if ENV["HOMEBREW_DISABLE_LOAD_FORMULA"] raise "Need to load formulae to publish them!" end @@ -360,7 +360,13 @@ def current_versions_from_info_external(formula_name) def subject_for_bump(formula, old, new) if old[:nonexistent] # New formula - headline_ver = new[:stable] ? new[:stable] : new[:devel] ? new[:devel] : new[:head] + headline_ver = if new[:stable] + new[:stable] + elsif new[:devel] + new[:devel] + else + new[:head] + end subject = "#{formula.name} #{headline_ver} (new formula)" else # Update to existing formula @@ -430,7 +436,7 @@ def self.lookup(name) FormulaInfoFromJson.new(Utils::JSON.load(json)[0]) end - def bottle_tags() + def bottle_tags return [] unless info["bottle"]["stable"] info["bottle"]["stable"]["files"].keys end @@ -467,7 +473,6 @@ def revision end end - # Bottle info as used internally by pull, with alternate platform support class BottleInfo # URL of bottle as string @@ -522,7 +527,7 @@ def verify_bintray_published(formulae_names) http.use_ssl = true retry_count = 0 http.start do - while true do + loop do req = Net::HTTP::Head.new bottle_info.url req.initialize_http_header "User-Agent" => HOMEBREW_USER_AGENT_RUBY res = http.request req @@ -551,7 +556,7 @@ def verify_bintray_published(formulae_names) max_curl_retries = 1 retry_count = 0 # We're in the cache; make sure to force re-download - while true do + loop do begin curl url, "-o", filename break
false
Other
Homebrew
brew
71fd2bb4b0b30b03fbb7b19c53d008b1780006bb.json
dev-cmd/man: fix Rubocop warnings.
Library/Homebrew/dev-cmd/man.rb
@@ -34,15 +34,15 @@ def regenerate_man_pages end def path_glob_commands(glob) - Pathname.glob(glob). - sort_by { |source_file| sort_key_for_path(source_file) }. - map { |source_file| - source_file.read.lines. - grep(/^#:/). - map { |line| line.slice(2..-1) }. - join - }. - reject { |s| s.strip.empty? || s.include?("@hide_from_man_page") } + Pathname.glob(glob) + .sort_by { |source_file| sort_key_for_path(source_file) } + .map do |source_file| + source_file.read.lines + .grep(/^#:/) + .map { |line| line.slice(2..-1) } + .join + end + .reject { |s| s.strip.empty? || s.include?("@hide_from_man_page") } end def build_man_page @@ -51,11 +51,11 @@ def build_man_page variables[:commands] = path_glob_commands("#{HOMEBREW_LIBRARY_PATH}/cmd/*.{rb,sh}") variables[:developer_commands] = path_glob_commands("#{HOMEBREW_LIBRARY_PATH}/dev-cmd/*.{rb,sh}") - variables[:maintainers] = (HOMEBREW_REPOSITORY/"README.md"). - read[/Homebrew's current maintainers are (.*)\./, 1]. - scan(/\[([^\]]*)\]/).flatten + variables[:maintainers] = (HOMEBREW_REPOSITORY/"README.md") + .read[/Homebrew's current maintainers are (.*)\./, 1] + .scan(/\[([^\]]*)\]/).flatten - ERB.new(template, nil, ">").result(variables.instance_eval{ binding }) + ERB.new(template, nil, ">").result(variables.instance_eval { binding }) end def sort_key_for_path(path)
false
Other
Homebrew
brew
e6b057ea76756fa02ee059febf779aec7759f3e3.json
dev-cmd/edit: fix Rubocop warnings.
Library/Homebrew/dev-cmd/edit.rb
@@ -44,7 +44,9 @@ def edit def library_folders Dir["#{HOMEBREW_LIBRARY}/*"].reject do |d| - case File.basename(d) when "LinkedKegs", "Aliases" then true end + case File.basename(d) + when "LinkedKegs", "Aliases" then true + end end end end
false
Other
Homebrew
brew
d01993da82bcb106aeac349ed5e66a445a40d1d2.json
dev-cmd/create: fix Rubocop warnings.
Library/Homebrew/dev-cmd/create.rb
@@ -91,7 +91,7 @@ def create def __gets gots = $stdin.gets.chomp - if gots.empty? then nil else gots end + gots.empty? ? nil : gots end end
false
Other
Homebrew
brew
bba6a59c0c491eab7fdf3141a9810f86a2ed9ae0.json
dev-cmd/bump-formula-pr: fix Rubocop warnings.
Library/Homebrew/dev-cmd/bump-formula-pr.rb
@@ -101,7 +101,7 @@ def bump_formula_pr old_formula_version = formula_version(formula, requested_spec) replacement_pairs = [] - if requested_spec == :stable && formula.revision != 0 + if requested_spec == :stable && formula.revision.nonzero? replacement_pairs << [/^ revision \d+\n(\n( head "))?/m, "\\2"] end
false
Other
Homebrew
brew
9b5c45a7df6a9a170389d6045bf06803fe4bc78b.json
dev-cmd/bottle: fix Rubocop warnings.
Library/Homebrew/dev-cmd/bottle.rb
@@ -13,7 +13,7 @@ require "erb" require "extend/pathname" -BOTTLE_ERB = <<-EOS +BOTTLE_ERB = <<-EOS.freeze bottle do <% if !root_url.start_with?(BottleSpecification::DEFAULT_DOMAIN) %> root_url "<%= root_url %>" @@ -89,15 +89,14 @@ def print_filename(string, filename) end end - if ARGV.verbose? && !text_matches.empty? - print_filename string, file - text_matches.first(MAXIMUM_STRING_MATCHES).each do |match, offset| - puts " #{Tty.gray}-->#{Tty.reset} match '#{match}' at offset #{Tty.em}0x#{offset}#{Tty.reset}" - end + next unless ARGV.verbose? && !text_matches.empty? + print_filename string, file + text_matches.first(MAXIMUM_STRING_MATCHES).each do |match, offset| + puts " #{Tty.gray}-->#{Tty.reset} match '#{match}' at offset #{Tty.em}0x#{offset}#{Tty.reset}" + end - if text_matches.size > MAXIMUM_STRING_MATCHES - puts "Only the first #{MAXIMUM_STRING_MATCHES} matches were output" - end + if text_matches.size > MAXIMUM_STRING_MATCHES + puts "Only the first #{MAXIMUM_STRING_MATCHES} matches were output" end end @@ -107,10 +106,9 @@ def print_filename(string, filename) def keg_contain_absolute_symlink_starting_with?(string, keg) absolute_symlinks_start_with_string = [] keg.find do |pn| - if pn.symlink? && (link = pn.readlink).absolute? - if link.to_s.start_with?(string) - absolute_symlinks_start_with_string << pn - end + next unless pn.symlink? && (link = pn.readlink).absolute? + if link.to_s.start_with?(string) + absolute_symlinks_start_with_string << pn end end @@ -146,7 +144,7 @@ def bottle_formula(f) return end - unless Utils::Bottles::built_as? f + unless Utils::Bottles.built_as? f return ofail "Formula not installed with '--build-bottle': #{f.full_name}" end @@ -289,6 +287,9 @@ def bottle_formula(f) bottle.sha256 sha256 => Utils::Bottles.tag old_spec = f.bottle_specification + p root_url + p old_spec.root_url(root_url) + p bottle.root_url(root_url) if ARGV.include?("--keep-old") && !old_spec.checksums.empty? mismatches = [:root_url, :prefix, :cellar, :rebuild].select do |key| old_spec.send(key) != bottle.send(key) @@ -332,7 +333,7 @@ def bottle_formula(f) "filename" => filename.to_s, "sha256" => sha256, }, - } + }, }, "bintray" => { "package" => Utils::Bottles::Bintray.package(f.name), @@ -372,7 +373,7 @@ def merge output = bottle_output bottle if write - path = Pathname.new("#{HOMEBREW_REPOSITORY/bottle_hash["formula"]["path"]}") + path = Pathname.new((HOMEBREW_REPOSITORY/bottle_hash["formula"]["path"]).to_s) update_or_add = nil Utils::Inreplace.inreplace(path) do |s| @@ -391,7 +392,7 @@ def merge old_value = old_value_original.to_s.delete ":'\"" tag = tag.to_s.delete ":" - if !tag.empty? + unless tag.empty? if !bottle_hash["bottle"]["tags"][tag].to_s.empty? mismatches << "#{key} => #{tag}" else @@ -403,11 +404,10 @@ def merge value_original = bottle_hash["bottle"][key] value = value_original.to_s next if key == "cellar" && old_value == "any" && value == "any_skip_relocation" - if old_value.empty? || value != old_value - old_value = old_value_original.inspect - value = value_original.inspect - mismatches << "#{key}: old: #{old_value}, new: #{value}" - end + next unless old_value.empty? || value != old_value + old_value = old_value_original.inspect + value = value_original.inspect + mismatches << "#{key}: old: #{old_value}, new: #{value}" end unless mismatches.empty? @@ -444,7 +444,8 @@ def merge rebuild\ \d+ # rebuild with a number )\n+ # multiple empty lines )+ - /mx, '\0' + output + "\n") + /mx, '\0' + output + "\n" + ) end odie "Bottle block addition failed!" unless string end
false
Other
Homebrew
brew
264afb67dfe275d6bc82f4d8ea700f770513a5b1.json
dev-cmd/audit: fix Rubocop warnings.
Library/Homebrew/dev-cmd/audit.rb
@@ -101,20 +101,20 @@ def without_patch @text.split("\n__END__").first end - def has_DATA? + def data? /^[^#]*\bDATA\b/ =~ @text end - def has_END? + def end? /^__END__$/ =~ @text end - def has_trailing_newline? + def trailing_newline? /\Z\n/ =~ @text end - def =~(regex) - regex =~ @text + def =~(other) + other =~ @text end def include?(s) @@ -152,15 +152,15 @@ class FormulaAuditor smake sphinx-doc swig - ] + ].freeze FILEUTILS_METHODS = FileUtils.singleton_methods(false).map { |m| Regexp.escape(m) }.join "|" def initialize(formula, options = {}) @formula = formula - @new_formula = !!options[:new_formula] - @strict = !!options[:strict] - @online = !!options[:online] + @new_formula = options[:new_formula] + @strict = options[:strict] + @online = options[:online] # Accept precomputed style offense results, for efficiency @style_offenses = options[:style_offenses] @problems = [] @@ -214,7 +214,7 @@ def audit_components(reverse = true, previous_pair = nil) previous_before = previous_pair[0] previous_after = previous_pair[1] end - offset = (previous_after && previous_after[0] && previous_after[0] >= 1) ? previous_after[0] - 1 : 0 + offset = previous_after && previous_after[0] && previous_after[0] >= 1 ? previous_after[0] - 1 : 0 present = component_list.map do |regex, name| lineno = if reverse text.reverse_line_number regex @@ -229,7 +229,7 @@ def audit_components(reverse = true, previous_pair = nil) if reverse # scan in the forward direction from the offset audit_components(false, [c1, c2]) if c1[0] > c2[0] # at least one more offense - elsif c1[0] > c2[0] && (offset == 0 || previous_pair.nil? || (c1[0] + offset) != previous_before[0] || (c2[0] + offset) != previous_after[0]) + elsif c1[0] > c2[0] && (offset.zero? || previous_pair.nil? || (c1[0] + offset) != previous_before[0] || (c2[0] + offset) != previous_after[0]) component_problem c1, c2, offset no_problem = false end @@ -251,19 +251,19 @@ def audit_file actual_mode & 0777, wanted_mode & 0777, formula.path) end - if text.has_DATA? && !text.has_END? + if text.data? && !text.end? problem "'DATA' was found, but no '__END__'" end - if text.has_END? && !text.has_DATA? + if text.end? && !text.data? problem "'__END__' was found, but 'DATA' is not used" end if text =~ /inreplace [^\n]* do [^\n]*\n[^\n]*\.gsub![^\n]*\n\ *end/m problem "'inreplace ... do' was used for a single substitution (use the non-block form instead)." end - unless text.has_trailing_newline? + unless text.trailing_newline? problem "File should end with a newline" end @@ -328,13 +328,13 @@ def audit_formula_name return end - @@local_official_taps_name_map ||= Tap.select(&:official?).flat_map(&:formula_names). - reduce(Hash.new) do |name_map, tap_formula_full_name| - tap_formula_name = tap_formula_full_name.split("/").last - name_map[tap_formula_name] ||= [] - name_map[tap_formula_name] << tap_formula_full_name - name_map - end + @@local_official_taps_name_map ||= Tap.select(&:official?).flat_map(&:formula_names) + .each_with_object({}) do |tap_formula_full_name, name_map| + tap_formula_name = tap_formula_full_name.split("/").last + name_map[tap_formula_name] ||= [] + name_map[tap_formula_name] << tap_formula_full_name + name_map + end same_name_tap_formulae = @@local_official_taps_name_map[name] || [] @@ -396,14 +396,6 @@ def audit_deps end case dep.name - when *BUILD_TIME_DEPS - next if dep.build? || dep.run? - problem <<-EOS.undent - #{dep} dependency should be - depends_on "#{dep}" => :build - Or if it is indeed a runtime dependency - depends_on "#{dep}" => :run - EOS when "git" problem "Don't use git as a dependency" when "mercurial" @@ -419,6 +411,9 @@ def audit_deps where "1.8" is the minimum version of Ruby required. EOS when "open-mpi", "mpich" + problem <<-EOS.undent + when *BUILD_TIME_DEPS + next if dep.build? || dep.run? problem <<-EOS.undent There are multiple conflicting ways to install MPI. Use an MPIRequirement: depends_on :mpi => [<lang list>] @@ -452,10 +447,9 @@ def audit_options problem "Options should begin with with/without. Migrate '--#{o.name}' with `deprecated_option`." end - if o.name =~ /^with(out)?-(?:checks?|tests)$/ - unless formula.deps.any? { |d| d.name == "check" && (d.optional? || d.recommended?) } - problem "Use '--with#{$1}-test' instead of '--#{o.name}'. Migrate '--#{o.name}' with `deprecated_option`." - end + next unless o.name =~ /^with(out)?-(?:checks?|tests)$/ + unless formula.deps.any? { |d| d.name == "check" && (d.optional? || d.recommended?) } + problem "Use '--with#{$1}-test' instead of '--#{o.name}'. Migrate '--#{o.name}' with `deprecated_option`." end end end @@ -667,15 +661,14 @@ def audit_revision_and_version_scheme attributes.each do |attribute| attributes_for_version = attributes_map[attribute][formula.version] - if !attributes_for_version.empty? - if formula.send(attribute) < attributes_for_version.max - problem "#{attribute} should not decrease" - end + next if attributes_for_version.empty? + if formula.send(attribute) < attributes_for_version.max + problem "#{attribute} should not decrease" end end revision_map = attributes_map[:revision] - if formula.revision != 0 + if formula.revision.nonzero? if formula.stable if revision_map[formula.stable.version].empty? # check stable spec problem "'revision #{formula.revision}' should be removed" @@ -772,7 +765,7 @@ def audit_line(line, lineno) # FileUtils is included in Formula # encfs modifies a file with this name, so check for some leading characters - if line =~ /[^'"\/]FileUtils\.(\w+)/ + if line =~ %r{[^'"/]FileUtils\.(\w+)} problem "Don't need 'FileUtils.' before #{$1}." end @@ -1038,7 +1031,7 @@ def audit_conditional_dep(dep, condition, line) end def quote_dep(dep) - Symbol === dep ? dep.inspect : "'#{dep}'" + dep.is_a?(Symbol) ? dep.inspect : "'#{dep}'" end def audit_check_output(output)
true
Other
Homebrew
brew
264afb67dfe275d6bc82f4d8ea700f770513a5b1.json
dev-cmd/audit: fix Rubocop warnings.
Library/Homebrew/test/test_cmd_audit.rb
@@ -29,9 +29,9 @@ class #{Formulary.class_s(name)} < Formula def test_simple_valid_formula ft = formula_text "valid", 'url "http://www.example.com/valid-1.0.tar.gz"' - refute ft.has_DATA?, "The formula should not have DATA" - refute ft.has_END?, "The formula should not have __END__" - assert ft.has_trailing_newline?, "The formula should have a trailing newline" + refute ft.data?, "The formula should not have DATA" + refute ft.end?, "The formula should not have __END__" + assert ft.trailing_newline?, "The formula should have a trailing newline" assert ft =~ /\burl\b/, "The formula should match 'url'" assert_nil ft.line_number(/desc/), "The formula should not match 'desc'" @@ -41,17 +41,17 @@ def test_simple_valid_formula def test_trailing_newline ft = formula_text "newline" - assert ft.has_trailing_newline?, "The formula must have a trailing newline" + assert ft.trailing_newline?, "The formula must have a trailing newline" end def test_has_data ft = formula_text "data", "patch :DATA" - assert ft.has_DATA?, "The formula must have DATA" + assert ft.data?, "The formula must have DATA" end def test_has_end ft = formula_text "end", "", :patch => "__END__\na patch here" - assert ft.has_END?, "The formula must have __END__" + assert ft.end?, "The formula must have __END__" assert_equal "class End < Formula\n \nend", ft.without_patch end end
true
Other
Homebrew
brew
aa3d53f249a7afcaa76fc7652380dfc4099c66bf.json
utils/shell: fix Rubocop warnings.
Library/Homebrew/utils/shell.rb
@@ -10,7 +10,7 @@ module Utils }.freeze module Shell - UNSAFE_SHELL_CHAR = /([^A-Za-z0-9_\-.,:\/@\n])/ + UNSAFE_SHELL_CHAR = %r{([^A-Za-z0-9_\-.,:\/@\n])} # take a path and heuristically convert it # to a shell name, return nil if there's no match @@ -45,7 +45,7 @@ def csh_quote(str) str end module_function :csh_quote - + def sh_quote(str) # ruby's implementation of shell_escape str = str.to_s @@ -81,7 +81,7 @@ def shell_profile module_function :shell_profile def prepend_path_in_shell_profile(path) - case preferred_shell + case preferred_shell when :bash, :ksh, :sh, :zsh, nil "echo 'export PATH=\"#{sh_quote(path)}:$PATH\"' >> #{shell_profile}" when :csh, :tcsh
false
Other
Homebrew
brew
ecf46b841b24fe650504a7388f25d1093189a09d.json
utils/inreplace: fix Rubocop warnings.
Library/Homebrew/utils/inreplace.rb
@@ -1,9 +1,9 @@ module Utils class InreplaceError < RuntimeError def initialize(errors) - super errors.inject("inreplace failed\n") { |s, (path, errs)| + super errors.inject("inreplace failed\n") do |s, (path, errs)| s << "#{path}:\n" << errs.map { |e| " #{e}\n" }.join - } + end end end @@ -24,7 +24,7 @@ def inreplace(paths, before = nil, after = nil, audit_result = true) if before.nil? && after.nil? yield s else - after = after.to_s if Symbol === after + after = after.to_s if after.is_a? Symbol s.gsub!(before, after, audit_result) end @@ -33,7 +33,7 @@ def inreplace(paths, before = nil, after = nil, audit_result = true) Pathname(path).atomic_write(s) end - raise InreplaceError.new(errors) unless errors.empty? + raise InreplaceError, errors unless errors.empty? end module_function :inreplace end
false
Other
Homebrew
brew
1f2abbdd6e960399b50f35e3e34261d13b9cf893.json
utils/hash: fix Rubocop warnings.
Library/Homebrew/utils/hash.rb
@@ -1,6 +1,6 @@ def deep_merge_hashes(hash1, hash2) - merger = proc do |key, v1, v2| - if Hash === v1 && Hash === v2 + merger = proc do |_key, v1, v2| + if v1.is_a?(Hash) && v2.is_a?(Hash) v1.merge v2, &merger else v2
false
Other
Homebrew
brew
6cfb84152464097901a9b9a437b37cc8c5aeb45c.json
utils/github: fix Rubocop warnings.
Library/Homebrew/utils/github.rb
@@ -121,7 +121,7 @@ def api_credentials_error_message(response_headers) end end - def open(url, data=nil) + def open(url, data = nil) # This is a no-op if the user is opting out of using the GitHub API. return if ENV["HOMEBREW_NO_GITHUB_API"] @@ -154,7 +154,7 @@ def open(url, data=nil) args += ["--data", "@#{data_tmpfile.path}"] end - args += ["--dump-header", "#{headers_tmpfile.path}"] + args += ["--dump-header", headers_tmpfile.path.to_s] output, errors, status = curl_output(url.to_s, *args) output, _, http_code = output.rpartition("\n") @@ -203,11 +203,15 @@ def raise_api_error(output, errors, http_code, headers) case http_code when "401", "403" - raise AuthenticationFailedError.new(output) + raise AuthenticationFailedError, output when "404" raise HTTPNotFoundError, output else - error = Utils::JSON.load(output)["message"] rescue nil + error = begin + Utils::JSON.load(output)["message"] + rescue + nil + end error ||= "curl failed! #{errors}" raise Error, error end @@ -232,7 +236,7 @@ def build_query_string(query, qualifiers) def build_search_qualifier_string(qualifiers) { :repo => "Homebrew/homebrew-core", - :in => "title" + :in => "title", }.update(qualifiers).map do |qualifier, value| "#{qualifier}:#{value}" end.join("+")
false
Other
Homebrew
brew
3bf5e779ab04bf399963183eb59f815b5df77c5d.json
utils/curl: fix Rubocop warnings.
Library/Homebrew/utils/curl.rb
@@ -1,15 +1,15 @@ require "pathname" require "open3" -def curl_args(extra_args=[]) +def curl_args(extra_args = []) curl = Pathname.new ENV["HOMEBREW_CURL"] curl = Pathname.new "/usr/bin/curl" unless curl.exist? raise "#{curl} is not executable" unless curl.exist? && curl.executable? flags = HOMEBREW_CURL_ARGS flags -= ["--progress-bar"] if ARGV.verbose? - args = ["#{curl}"] + flags + extra_args + args = [curl.to_s] + flags + extra_args args << "--verbose" if ENV["HOMEBREW_CURL_VERBOSE"] args << "--silent" if !$stdout.tty? || ENV["TRAVIS"] args
false
Other
Homebrew
brew
56b6c43686be4710af7ddfeee06d456abc3aa0cf.json
utils: fix Rubocop warnings.
Library/Homebrew/utils.rb
@@ -138,11 +138,10 @@ def odeprecated(method, replacement = nil, options = {}) backtrace = options.fetch(:caller, caller) tap_message = nil caller_message = backtrace.detect do |line| - if line =~ %r{^#{Regexp.escape HOMEBREW_LIBRARY}/Taps/([^/]+/[^/]+)/} - tap = Tap.fetch $1 - tap_message = "\nPlease report this to the #{tap} tap!" - true - end + next unless line =~ %r{^#{Regexp.escape HOMEBREW_LIBRARY}/Taps/([^/]+/[^/]+)/} + tap = Tap.fetch $1 + tap_message = "\nPlease report this to the #{tap} tap!" + true end caller_message ||= backtrace.detect do |line| !line.start_with?("#{HOMEBREW_LIBRARY_PATH}/compat/") @@ -170,7 +169,7 @@ def odisabled(method, replacement = nil, options = {}) def pretty_installed(f) if !$stdout.tty? - "#{f}" + f.to_s elsif Emoji.enabled? "#{Tty.highlight}#{f} #{Tty.green}#{Emoji.tick}#{Tty.reset}" else @@ -180,7 +179,7 @@ def pretty_installed(f) def pretty_uninstalled(f) if !$stdout.tty? - "#{f}" + f.to_s elsif Emoji.enabled? "#{f} #{Tty.red}#{Emoji.cross}#{Tty.reset}" else @@ -196,15 +195,15 @@ def pretty_duration(s) m = s / 60 s %= 60 res = "#{m} minute#{plural m}" - return res if s == 0 + return res if s.zero? res << " " end res + "#{s} second#{plural s}" end def plural(n, s = "s") - (n == 1) ? "" : s + n == 1 ? "" : s end def interactive_shell(f = nil) @@ -233,7 +232,11 @@ def self._system(cmd, *args) pid = fork do yield if block_given? args.collect!(&:to_s) - exec(cmd, *args) rescue nil + begin + exec(cmd, *args) + rescue + nil + end exit! 1 # never gets here unless exec failed end Process.wait(pid) @@ -291,7 +294,7 @@ def self.install_gem_setup_path!(name, version = nil, executable = name) rescue Gem::SystemExitException => e exit_code = e.exit_code end - odie "Failed to install/update the '#{name}' gem." if exit_code != 0 + odie "Failed to install/update the '#{name}' gem." if exit_code.nonzero? end unless which executable @@ -542,10 +545,10 @@ def disk_usage_readable(size_in_bytes) end # avoid trailing zero after decimal point - if (size * 10).to_i % 10 == 0 + if ((size * 10).to_i % 10).zero? "#{size.to_i}#{unit}" else - "#{"%.1f" % size}#{unit}" + "#{format("%.1f", size)}#{unit}" end end @@ -572,10 +575,10 @@ def truncate_text_to_approximate_size(s, max_bytes, options = {}) glue_bytes = glue.encode("BINARY") n_front_bytes = (max_bytes_in * front_weight).floor n_back_bytes = max_bytes_in - n_front_bytes - if n_front_bytes == 0 + if n_front_bytes.zero? front = bytes[1..0] back = bytes[-max_bytes_in..-1] - elsif n_back_bytes == 0 + elsif n_back_bytes.zero? front = bytes[0..(max_bytes_in - 1)] back = bytes[1..0] else
false
Other
Homebrew
brew
90d16a8f8667bc54cb134a46470492e371970538.json
dev-cmd/aspell-dictionaries: fix Rubocop warnings.
Library/Homebrew/dev-cmd/aspell-dictionaries.rb
@@ -14,8 +14,8 @@ def aspell_dictionaries open("#{dict_url}/0index.html") do |content| content.each_line do |line| - break if %r{^</table} === line - next unless /^<tr><td><a/ === line + break if %r{^</table} =~ line + next unless /^<tr><td><a/ =~ line fields = line.split('"') lang = fields[1]
false
Other
Homebrew
brew
1174264d47b03bbcdb6900896b2a512c05686549.json
cmd/uses: fix Rubocop warnings.
Library/Homebrew/cmd/uses.rb
@@ -27,7 +27,7 @@ def uses raise FormulaUnspecifiedError if ARGV.named.empty? used_formulae = ARGV.formulae - formulae = (ARGV.include? "--installed") ? Formula.installed : Formula + formulae = ARGV.include?("--installed") ? Formula.installed : Formula recursive = ARGV.flag? "--recursive" includes = [] ignores = [] @@ -65,17 +65,24 @@ def uses Requirement.prune unless includes.include?("build?") end end - deps.any? { |dep| dep.to_formula.full_name == ff.full_name rescue dep.name == ff.name } || - reqs.any? { |req| req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) } else deps = f.deps.reject do |dep| ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } end reqs = f.requirements.reject do |req| ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) } end - deps.any? { |dep| dep.to_formula.full_name == ff.full_name rescue dep.name == ff.name } || - reqs.any? { |req| req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) } + end + next true if deps.any? do |dep| + begin + dep.to_formula.full_name == ff.full_name + rescue + dep.name == ff.name + end + end + + reqs.any? do |req| + req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) end rescue FormulaUnavailableError # Silently ignore this case as we don't care about things used in
false
Other
Homebrew
brew
2c5beb0effd113bd0342f052d735d697e3e5af95.json
cmd/upgrade: fix Rubocop warnings.
Library/Homebrew/cmd/upgrade.rb
@@ -35,7 +35,7 @@ def upgrade end (ARGV.resolved_formulae - outdated).each do |f| - versions = f.installed_kegs.map { |keg| keg.version } + versions = f.installed_kegs.map(&:version) if versions.empty? onoe "#{f.full_name} not installed" else @@ -51,11 +51,11 @@ def upgrade outdated -= pinned end - unless outdated.empty? + if outdated.empty? + oh1 "No packages to upgrade" + else oh1 "Upgrading #{outdated.length} outdated package#{plural(outdated.length)}, with result:" puts outdated.map { |f| "#{f.full_name} #{f.pkg_version}" } * ", " - else - oh1 "No packages to upgrade" end unless upgrade_pinned? || pinned.empty? @@ -116,6 +116,10 @@ def upgrade_formula(f) ofail e ensure # restore previous installation state if build failed - outdated_keg.link if outdated_keg && !f.installed? rescue nil + begin + outdated_keg.link if outdated_keg && !f.installed? + rescue + nil + end end end
false
Other
Homebrew
brew
cc526601cfe14861260b76359f6f1a2ec5fa33d2.json
cmd/update-report: fix Rubocop warnings.
Library/Homebrew/cmd/update-report.rb
@@ -134,13 +134,13 @@ def migrate_legacy_cache_if_necessary world_writable = legacy_cache.stat.mode & 0777 == 0777 return if world_writable return if legacy_cache.symlink? - return if !legacy_cache.owned? && legacy_cache.lstat.uid != 0 + return if !legacy_cache.owned? && legacy_cache.lstat.uid.nonzero? ohai "Migrating #{legacy_cache} to #{HOMEBREW_CACHE}..." HOMEBREW_CACHE.mkpath legacy_cache.cd do legacy_cache.entries.each do |f| - next if [".", "..", ".migration_attempted"].include? "#{f}" + next if [".", "..", ".migration_attempted"].include? f.to_s begin FileUtils.cp_r f, HOMEBREW_CACHE rescue @@ -173,7 +173,7 @@ def link_completions_and_docs link_src_dst_dirs(HOMEBREW_REPOSITORY/"etc/bash_completion.d", HOMEBREW_PREFIX/"etc/bash_completion.d", command) link_src_dst_dirs(HOMEBREW_REPOSITORY/"share/doc/homebrew", - HOMEBREW_PREFIX/"share/doc/homebrew", command, link_dir: true) + HOMEBREW_PREFIX/"share/doc/homebrew", command, :link_dir => true) link_src_dst_dirs(HOMEBREW_REPOSITORY/"share/zsh/site-functions", HOMEBREW_PREFIX/"share/zsh/site-functions", command) link_path_manpages(HOMEBREW_REPOSITORY/"share", command) @@ -359,10 +359,10 @@ def migrate_formula_rename private def repo_var - @repo_var ||= tap.path.to_s. - strip_prefix(Tap::TAP_DIRECTORY.to_s). - tr("^A-Za-z0-9", "_"). - upcase + @repo_var ||= tap.path.to_s + .strip_prefix(Tap::TAP_DIRECTORY.to_s) + .tr("^A-Za-z0-9", "_") + .upcase end def diff @@ -387,7 +387,7 @@ def select_formula(key) def add(reporter) @reporters << reporter - report = reporter.report.delete_if { |k,v| v.empty? } + report = reporter.report.delete_if { |_k, v| v.empty? } @hash.update(report) { |_key, oldval, newval| oldval.concat(newval) } end
false
Other
Homebrew
brew
49e009df296d64edbd48a9b8ec657b735f02e89b.json
cmd/unpack: fix Rubocop warnings.
Library/Homebrew/cmd/unpack.rb
@@ -43,13 +43,12 @@ def unpack end ENV["VERBOSE"] = nil - if ARGV.git? - ohai "Setting up git repository" - cd stage_dir - system "git", "init", "-q" - system "git", "add", "-A" - system "git", "commit", "-q", "-m", "brew-unpack" - end + next unless ARGV.git? + ohai "Setting up git repository" + cd stage_dir + system "git", "init", "-q" + system "git", "add", "-A" + system "git", "commit", "-q", "-m", "brew-unpack" end end end
false
Other
Homebrew
brew
7b41ccd2ea842f81929c747d3a558123f98834be.json
cmd/unlinkapps: fix Rubocop warnings.
Library/Homebrew/cmd/unlinkapps.rb
@@ -65,7 +65,7 @@ def unlinkapps_from_dir(target_dir, opts = {}) def unlinkapps_unlink?(target_app, opts = {}) # Skip non-symlinks and symlinks that don't point into the Homebrew prefix. - app = "#{target_app.readlink}" if target_app.symlink? + app = target_app.readlink.to_s if target_app.symlink? return false unless app && app.start_with?(*UNLINKAPPS_PREFIXES) if opts.fetch(:prune, false)
false
Other
Homebrew
brew
56fc1c725a752ef411e8f56aafe2602f2bb47592.json
cmd/uninstall: fix Rubocop warnings.
Library/Homebrew/cmd/uninstall.rb
@@ -60,6 +60,8 @@ def uninstall end def rm_pin(rack) - Formulary.from_rack(rack).unpin rescue nil + Formulary.from_rack(rack).unpin + rescue + nil end end
false
Other
Homebrew
brew
a0c29eb1af9abe25a29616bdcdd6aa19348e7eb3.json
cmd/tap-info: fix Rubocop warnings.
Library/Homebrew/cmd/tap-info.rb
@@ -59,7 +59,7 @@ def print_tap_info(taps) puts info else taps.each_with_index do |tap, i| - puts unless i == 0 + puts unless i.zero? info = "#{tap}: " if tap.installed? info += tap.pinned? ? "pinned" : "unpinned" @@ -70,7 +70,7 @@ def print_tap_info(taps) if (command_count = tap.command_files.size) > 0 info += ", #{command_count} command#{plural(command_count)}" end - info += ", no formulae/commands" if formula_count + command_count == 0 + info += ", no formulae/commands" if (formula_count + command_count).zero? info += "\n#{tap.path} (#{tap.path.abv})" info += "\nFrom: #{tap.remote.nil? ? "N/A" : tap.remote}" else
false
Other
Homebrew
brew
b9b07fc082f72dd0c3a886735cbcffe7f7244733.json
cmd/search: fix Rubocop warnings.
Library/Homebrew/cmd/search.rb
@@ -71,7 +71,7 @@ def search puts end puts msg - elsif count == 0 + elsif count.zero? puts "No formula found for #{query.inspect}." begin GitHub.print_pull_requests_matching(query) @@ -100,7 +100,7 @@ def search SEARCHABLE_TAPS = OFFICIAL_TAPS.map { |tap| ["Homebrew", tap] } + [ %w[Caskroom cask], - %w[Caskroom versions] + %w[Caskroom versions], ] def query_regexp(query) @@ -151,7 +151,7 @@ def search_tap(user, repo, rx) names = remote_tap_formulae["#{user}/#{repo}"] user = user.downcase if user == "Homebrew" # special handling for the Homebrew organization names.select { |name| rx === name }.map { |name| "#{user}/#{repo}/#{name}" } - rescue GitHub::HTTPNotFoundError => e + rescue GitHub::HTTPNotFoundError opoo "Failed to search tap: #{user}/#{repo}. Please run `brew update`" [] rescue GitHub::Error => e
false
Other
Homebrew
brew
f9c621304da00c0645950506a4d7eddab70ccbdf.json
cmd/prune: fix Rubocop warnings.
Library/Homebrew/cmd/prune.rb
@@ -47,14 +47,16 @@ def prune end end - if ObserverPathnameExtension.total.zero? - puts "Nothing pruned" if ARGV.verbose? - else - n, d = ObserverPathnameExtension.counts - print "Pruned #{n} symbolic links " - print "and #{d} directories " if d > 0 - puts "from #{HOMEBREW_PREFIX}" - end unless ARGV.dry_run? + unless ARGV.dry_run? + if ObserverPathnameExtension.total.zero? + puts "Nothing pruned" if ARGV.verbose? + else + n, d = ObserverPathnameExtension.counts + print "Pruned #{n} symbolic links " + print "and #{d} directories " if d > 0 + puts "from #{HOMEBREW_PREFIX}" + end + end unlinkapps_prune(:dry_run => ARGV.dry_run?, :quiet => true) end
false
Other
Homebrew
brew
ae43b79ca2b4e9ad595fbc70854423e214206102.json
cmd/missing: fix Rubocop warnings.
Library/Homebrew/cmd/missing.rb
@@ -18,7 +18,7 @@ def missing Diagnostic.missing_deps(ff) do |name, missing| print "#{name}: " if ff.size > 1 - puts "#{missing * " "}" + puts (missing * " ").to_s end end end
false
Other
Homebrew
brew
4e090530b11bbd61c13024bbdb1ef82387b5fb86.json
cmd/log: fix Rubocop warnings.
Library/Homebrew/cmd/log.rb
@@ -18,7 +18,7 @@ def log private - def git_log(path=nil) + def git_log(path = nil) if File.exist? "#{`git rev-parse --show-toplevel`.chomp}/.git/shallow" opoo <<-EOS.undent The git repository is a shallow clone therefore the filtering may be incorrect.
false
Other
Homebrew
brew
9d782454abc21787e26885a5aa17114c60312919.json
cmd/list: fix Rubocop warnings.
Library/Homebrew/cmd/list.rb
@@ -29,7 +29,7 @@ def list # Unbrewed uses the PREFIX, which will exist # Things below use the CELLAR, which doesn't until the first formula is installed. unless HOMEBREW_CELLAR.exist? - raise NoSuchKegError.new(ARGV.named.first) unless ARGV.named.empty? + raise NoSuchKegError, ARGV.named.first unless ARGV.named.empty? return end @@ -60,7 +60,7 @@ def list private - UNBREWED_EXCLUDE_FILES = %w[.DS_Store] + UNBREWED_EXCLUDE_FILES = %w[.DS_Store].freeze UNBREWED_EXCLUDE_PATHS = %w[ .github/* bin/brew @@ -80,7 +80,7 @@ def list share/man/man1/brew.1 share/man/whatis share/zsh/site-functions/_brew - ] + ].freeze def list_unbrewed dirs = HOMEBREW_PREFIX.subdirs.map { |dir| dir.basename.to_s } @@ -117,7 +117,7 @@ def filtered_list end end pinned_versions.each do |d, version| - puts "#{d.basename}".concat(ARGV.include?("--versions") ? " #{version}" : "") + puts d.basename.to_s.concat(ARGV.include?("--versions") ? " #{version}" : "") end else # --versions without --pinned names.each do |d|
false
Other
Homebrew
brew
5d761f651abf13cc461398c6d542d495a1766a48.json
cmd/install: fix Rubocop warnings.
Library/Homebrew/cmd/install.rb
@@ -71,13 +71,16 @@ def install raise "Specify `--HEAD` in uppercase to build from trunk." end - ARGV.named.each do |name| - if !File.exist?(name) && - (name =~ HOMEBREW_TAP_FORMULA_REGEX || name =~ HOMEBREW_CASK_TAP_FORMULA_REGEX) + unless ARGV.force? + ARGV.named.each do |name| + next if File.exist?(name) + if name !~ HOMEBREW_TAP_FORMULA_REGEX && name !~ HOMEBREW_CASK_TAP_FORMULA_REGEX + next + end tap = Tap.fetch($1, $2) tap.install unless tap.installed? end - end unless ARGV.force? + end begin formulae = []
false
Other
Homebrew
brew
990ee4f36c1d65f712c3ff05ba011cf8d92cba32.json
cmd/info: fix Rubocop warnings.
Library/Homebrew/cmd/info.rb
@@ -45,7 +45,7 @@ def print_info end else ARGV.named.each_with_index do |f, i| - puts unless i == 0 + puts unless i.zero? begin if f.include?("/") || File.exist?(f) info_formula Formulary.factory(f)
false
Other
Homebrew
brew
d9b8d0f6b11a7928dd997efb8905a9019ec6a6e9.json
cmd/help: fix Rubocop warnings.
Library/Homebrew/cmd/help.rb
@@ -1,4 +1,4 @@ -HOMEBREW_HELP = <<-EOS +HOMEBREW_HELP = <<-EOS.freeze Example usage: brew search [TEXT|/REGEX/] brew (info|home|options) [FORMULA...] @@ -78,11 +78,11 @@ def command_help(path) HOMEBREW_HELP else help_lines.map do |line| - line.slice(2..-1). - sub(/^ \* /, "#{Tty.highlight}brew#{Tty.reset} "). - gsub(/`(.*?)`/, "#{Tty.highlight}\\1#{Tty.reset}"). - gsub(/<(.*?)>/, "#{Tty.em}\\1#{Tty.reset}"). - gsub("@hide_from_man_page", "") + line.slice(2..-1) + .sub(/^ \* /, "#{Tty.highlight}brew#{Tty.reset} ") + .gsub(/`(.*?)`/, "#{Tty.highlight}\\1#{Tty.reset}") + .gsub(/<(.*?)>/, "#{Tty.em}\\1#{Tty.reset}") + .gsub("@hide_from_man_page", "") end.join.strip end end
false
Other
Homebrew
brew
c8084b17437cff4aa28997246860cdba591e2f52.json
cmd/fetch: fix Rubocop warnings.
Library/Homebrew/cmd/fetch.rb
@@ -56,11 +56,10 @@ def fetch end end - unless fetched_bottle - fetch_formula(f) - f.resources.each { |r| fetch_resource(r) } - f.patchlist.each { |p| fetch_patch(p) if p.external? } - end + next if fetched_bottle + fetch_formula(f) + f.resources.each { |r| fetch_resource(r) } + f.patchlist.each { |p| fetch_patch(p) if p.external? } end end
false
Other
Homebrew
brew
c45e36ffde1805ec7706fa28895b120909f69de7.json
cmd/doctor: fix Rubocop warnings.
Library/Homebrew/cmd/doctor.rb
@@ -40,20 +40,19 @@ def doctor end out = checks.send(method) - unless out.nil? || out.empty? - if first_warning - $stderr.puts <<-EOS.undent + next if out.nil? || out.empty? + if first_warning + $stderr.puts <<-EOS.undent #{Tty.white}Please note that these warnings are just used to help the Homebrew maintainers with debugging if you file an issue. If everything you use Homebrew for is working fine: please don't worry and just ignore them. Thanks!#{Tty.reset} - EOS - end - - $stderr.puts - opoo out - Homebrew.failed = true - first_warning = false + EOS end + + $stderr.puts + opoo out + Homebrew.failed = true + first_warning = false end puts "Your system is ready to brew." unless Homebrew.failed?
false
Other
Homebrew
brew
5e0c22202955243e07ab18a56ea8019b3dd200c6.json
cmd/desc: fix Rubocop warnings.
Library/Homebrew/cmd/desc.rb
@@ -26,14 +26,12 @@ def desc results.print elsif search_type.size > 1 odie "Pick one, and only one, of -s/--search, -n/--name, or -d/--description." + elsif arg = ARGV.named.first + regex = Homebrew.query_regexp(arg) + results = Descriptions.search(regex, search_type.first) + results.print else - if arg = ARGV.named.first - regex = Homebrew::query_regexp(arg) - results = Descriptions.search(regex, search_type.first) - results.print - else - odie "You must provide a search term." - end + odie "You must provide a search term." end end end
false
Other
Homebrew
brew
128729988ed8feadbdac31d4edd613c5afa64d24.json
cmd/commands: fix Rubocop warnings.
Library/Homebrew/cmd/commands.rb
@@ -41,22 +41,20 @@ def internal_developer_commands end def external_commands - paths.reduce([]) do |cmds, path| + paths.each_with_object([]) do |path, cmds| Dir["#{path}/brew-*"].each do |file| next unless File.executable?(file) cmd = File.basename(file, ".rb")[5..-1] cmds << cmd unless cmd.include?(".") end - cmds end.sort end private def find_internal_commands(directory) - directory.children.reduce([]) do |cmds, f| + directory.children.each_with_object([]) do |f, cmds| cmds << f.basename.to_s.sub(/\.(?:rb|sh)$/, "") if f.file? - cmds end end end
false
Other
Homebrew
brew
caecead7a7157e51b4ff3989604816e087707895.json
os/mac/xquartz: fix Rubocop warnings.
Library/Homebrew/os/mac/xquartz.rb
@@ -5,9 +5,9 @@ module Mac module XQuartz extend self - FORGE_BUNDLE_ID = "org.macosforge.xquartz.X11" - APPLE_BUNDLE_ID = "org.x.X11" - FORGE_PKG_ID = "org.macosforge.xquartz.pkg" + FORGE_BUNDLE_ID = "org.macosforge.xquartz.X11".freeze + APPLE_BUNDLE_ID = "org.x.X11".freeze + FORGE_PKG_ID = "org.macosforge.xquartz.pkg".freeze PKGINFO_VERSION_MAP = { "2.6.34" => "2.6.3",
false
Other
Homebrew
brew
8271e357867692edfddf3d70328dd568bd7eebf2.json
os/mac/xcode: fix Rubocop warnings.
Library/Homebrew/os/mac/xcode.rb
@@ -3,8 +3,8 @@ module Mac module Xcode extend self - V4_BUNDLE_ID = "com.apple.dt.Xcode" - V3_BUNDLE_ID = "com.apple.Xcode" + V4_BUNDLE_ID = "com.apple.dt.Xcode".freeze + V3_BUNDLE_ID = "com.apple.Xcode".freeze def latest_version case MacOS.version @@ -104,18 +104,17 @@ def uncached_version #{prefix}/usr/bin/xcodebuild #{which("xcodebuild")} ].uniq.each do |xcodebuild_path| - if File.executable? xcodebuild_path - xcodebuild_output = Utils.popen_read(xcodebuild_path, "-version") - next unless $?.success? + next unless File.executable? xcodebuild_path + xcodebuild_output = Utils.popen_read(xcodebuild_path, "-version") + next unless $?.success? - xcode_version = xcodebuild_output[/Xcode (\d(\.\d)*)/, 1] - return xcode_version if xcode_version + xcode_version = xcodebuild_output[/Xcode (\d(\.\d)*)/, 1] + return xcode_version if xcode_version - # Xcode 2.x's xcodebuild has a different version string - case xcodebuild_output[/DevToolsCore-(\d+\.\d)/, 1] - when "515.0" then return "2.0" - when "798.0" then return "2.5" - end + # Xcode 2.x's xcodebuild has a different version string + case xcodebuild_output[/DevToolsCore-(\d+\.\d)/, 1] + when "515.0" then return "2.0" + when "798.0" then return "2.5" end end @@ -125,25 +124,25 @@ def uncached_version # be removed in a future version. To remain compatible, guard usage of # Xcode.version with an Xcode.installed? check. case (DevelopmentTools.clang_version.to_f * 10).to_i - when 0 then "dunno" - when 1..14 then "3.2.2" - when 15 then "3.2.4" - when 16 then "3.2.5" - when 17..20 then "4.0" - when 21 then "4.1" - when 22..30 then "4.2" - when 31 then "4.3" - when 40 then "4.4" - when 41 then "4.5" - when 42 then "4.6" - when 50 then "5.0" - when 51 then "5.1" - when 60 then "6.0" - when 61 then "6.1" - when 70 then "7.0" - when 73 then "7.3" - when 80 then "8.0" - else "8.0" + when 0 then "dunno" + when 1..14 then "3.2.2" + when 15 then "3.2.4" + when 16 then "3.2.5" + when 17..20 then "4.0" + when 21 then "4.1" + when 22..30 then "4.2" + when 31 then "4.3" + when 40 then "4.4" + when 41 then "4.5" + when 42 then "4.6" + when 50 then "5.0" + when 51 then "5.1" + when 60 then "6.0" + when 61 then "6.1" + when 70 then "7.0" + when 73 then "7.3" + when 80 then "8.0" + else "8.0" end end @@ -167,11 +166,11 @@ def default_prefix? module CLT extend self - STANDALONE_PKG_ID = "com.apple.pkg.DeveloperToolsCLILeo" - FROM_XCODE_PKG_ID = "com.apple.pkg.DeveloperToolsCLI" - MAVERICKS_PKG_ID = "com.apple.pkg.CLTools_Executables" - MAVERICKS_NEW_PKG_ID = "com.apple.pkg.CLTools_Base" # obsolete - MAVERICKS_PKG_PATH = "/Library/Developer/CommandLineTools" + STANDALONE_PKG_ID = "com.apple.pkg.DeveloperToolsCLILeo".freeze + FROM_XCODE_PKG_ID = "com.apple.pkg.DeveloperToolsCLI".freeze + MAVERICKS_PKG_ID = "com.apple.pkg.CLTools_Executables".freeze + MAVERICKS_NEW_PKG_ID = "com.apple.pkg.CLTools_Base".freeze # obsolete + MAVERICKS_PKG_PATH = "/Library/Developer/CommandLineTools".freeze # Returns true even if outdated tools are installed, e.g. # tools from Xcode 4.x on 10.9
false
Other
Homebrew
brew
00f5aa81f2b2e5c29d6afdeb7a4025a4620e7df7.json
os/mac/version: fix Rubocop warnings.
Library/Homebrew/os/mac/version.rb
@@ -12,8 +12,8 @@ class Version < ::Version :lion => "10.7", :snow_leopard => "10.6", :leopard => "10.5", - :tiger => "10.4" - } + :tiger => "10.4", + }.freeze def self.from_symbol(sym) str = SYMBOLS.fetch(sym) do
false
Other
Homebrew
brew
f421374af1c70880e8e3abf0362f3efb55f62baf.json
os/mac/sdk: fix Rubocop warnings.
Library/Homebrew/os/mac/sdk.rb
@@ -24,7 +24,7 @@ def sdk_for(v) def latest_sdk return if sdk_paths.empty? - v, path = sdk_paths.max {|a, b| OS::Mac::Version.new(a[0]) <=> OS::Mac::Version.new(b[0])} + v, path = sdk_paths.max { |a, b| OS::Mac::Version.new(a[0]) <=> OS::Mac::Version.new(b[0]) } SDK.new v, path end
false
Other
Homebrew
brew
ecda1c9c54bce43803236fdf1d92ce452905e9be.json
os/mac/linkage_checker: fix Rubocop warnings.
Library/Homebrew/os/mac/linkage_checker.rb
@@ -51,28 +51,28 @@ def check_dylibs end def check_undeclared_deps - filter_out = proc do |dep| - next true if dep.build? - 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 - declared_dep_names = (declared_deps + declared_requirement_deps).map { |dep| dep.split("/").last } - undeclared_deps = @brewed_dylibs.keys.select do |full_name| - name = full_name.split("/").last - next false if name == formula.name - !declared_dep_names.include?(name) - end - undeclared_deps.sort do |a,b| - if a.include?("/") && !b.include?("/") - 1 - elsif !a.include?("/") && b.include?("/") - -1 - else - a <=> b - end + filter_out = proc do |dep| + next true if dep.build? + 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 + declared_dep_names = (declared_deps + declared_requirement_deps).map { |dep| dep.split("/").last } + undeclared_deps = @brewed_dylibs.keys.select do |full_name| + name = full_name.split("/").last + next false if name == formula.name + !declared_dep_names.include?(name) + end + undeclared_deps.sort do |a, b| + if a.include?("/") && !b.include?("/") + 1 + elsif !a.include?("/") && b.include?("/") + -1 + else + a <=> b end + end end def display_normal_output
false
Other
Homebrew
brew
6d1d3ff013dbf8e6bedbb9710fa15f4749fcc4e3.json
os/mac/cctools_mach: fix Rubocop warnings.
Library/Homebrew/os/mac/cctools_mach.rb
@@ -73,7 +73,7 @@ def parse_otool_L_output id = libs.shift[OTOOL_RX, 1] if path.dylib? libs.map! { |lib| lib[OTOOL_RX, 1] }.compact! - return id, libs + [id, libs] end end
false
Other
Homebrew
brew
d1191c8bb0a60baf14f78cf7c5e903aa363ce53e.json
os/mac/architecture_list: fix Rubocop warnings.
Library/Homebrew/os/mac/architecture_list.rb
@@ -28,7 +28,7 @@ def universal? end def ppc? - (Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).any? { |a| self.include? a } + (Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).any? { |a| include? a } end # @private @@ -48,7 +48,7 @@ def as_cmake_arch_flags def intersects_all?(*set) set.all? do |archset| - archset.any? { |a| self.include? a } + archset.any? { |a| include? a } end end end
false
Other
Homebrew
brew
cefaef75e1f7f8a4332ad5bd7468be7b3eead104.json
os/mac: fix Rubocop warnings.
Library/Homebrew/os/mac.rb
@@ -200,7 +200,7 @@ def preferred_arch "7.3" => { :clang => "7.3", :clang_build => 703 }, "7.3.1" => { :clang => "7.3", :clang_build => 703 }, "8.0" => { :clang => "8.0", :clang_build => 800 }, - } + }.freeze def compilers_standard? STANDARD_COMPILERS.fetch(Xcode.version.to_s).all? do |method, build|
false
Other
Homebrew
brew
5cba530eef15ece440be63adb4d625018c97badc.json
requirements/x11_requirement: fix Rubocop warnings.
Library/Homebrew/requirements/x11_requirement.rb
@@ -12,7 +12,7 @@ class X11Requirement < Requirement def initialize(name = "x11", tags = []) @name = name - if /(\d\.)+\d/ === tags.first + if /(\d\.)+\d/ =~ tags.first @min_version = Version.create(tags.shift) @min_version_string = " #{@min_version}" else @@ -33,7 +33,7 @@ def message end def <=>(other) - return unless X11Requirement === other + return unless other.is_a? X11Requirement min_version <=> other.min_version end
false
Other
Homebrew
brew
784e804fc23bbfa83a0104bb138f4802f8397d8a.json
requirements/ruby_requirement: fix Rubocop warnings.
Library/Homebrew/requirements/ruby_requirement.rb
@@ -3,7 +3,7 @@ class RubyRequirement < Requirement default_formula "ruby" def initialize(tags) - @version = tags.shift if /(\d\.)+\d/ === tags.first + @version = tags.shift if /(\d\.)+\d/ =~ tags.first raise "RubyRequirement requires a version!" unless @version super end
false
Other
Homebrew
brew
dab681e71563b8d633d290f2f381a2101b56a3d8.json
requirements/perl_requirement: fix Rubocop warnings.
Library/Homebrew/requirements/perl_requirement.rb
@@ -3,7 +3,7 @@ class PerlRequirement < Requirement default_formula "perl" def initialize(tags) - @version = tags.shift if /^\d+\.\d+$/ === tags.first + @version = tags.shift if /^\d+\.\d+$/ =~ tags.first raise "PerlRequirement requires a version!" unless @version super end
false
Other
Homebrew
brew
fb0e121686fa5212362d701b1d0dfb705c56c5d6.json
requirements/java_requirement: fix Rubocop warnings.
Library/Homebrew/requirements/java_requirement.rb
@@ -9,7 +9,7 @@ class JavaRequirement < Requirement next false unless File.executable? "/usr/libexec/java_home" args = %w[--failfast] - args << "--version" << "#{@version}" if @version + args << "--version" << @version.to_s if @version @java_home = Utils.popen_read("/usr/libexec/java_home", *args).chomp $?.success? end @@ -27,7 +27,7 @@ class JavaRequirement < Requirement end def initialize(tags) - @version = tags.shift if /(\d\.)+\d/ === tags.first + @version = tags.shift if /(\d\.)+\d/ =~ tags.first super end
false
Other
Homebrew
brew
7e42c5d08003fd38addbcd84af17df84e14a69b2.json
requirements/emacs_requirement: fix Rubocop warnings.
Library/Homebrew/requirements/emacs_requirement.rb
@@ -3,7 +3,7 @@ class EmacsRequirement < Requirement default_formula "emacs" def initialize(tags) - @version = tags.shift if /\d+\.*\d*/ === tags.first + @version = tags.shift if /\d+\.*\d*/ =~ tags.first super end
false
Other
Homebrew
brew
d0c33b370528ce57bfc049a3b939cada1481cc96.json
bottle: use key/value rather than field. Consistent naming is good.
Library/Homebrew/dev-cmd/bottle.rb
@@ -289,17 +289,17 @@ def bottle_formula(f) old_spec = f.bottle_specification if ARGV.include?("--keep-old") && !old_spec.checksums.empty? - mismatches = [:root_url, :prefix, :cellar, :rebuild].select do |field| - old_spec.send(field) != bottle.send(field) + mismatches = [:root_url, :prefix, :cellar, :rebuild].select do |key| + old_spec.send(key) != bottle.send(key) end mismatches.delete(:cellar) if old_spec.cellar == :any && bottle.cellar == :any_skip_relocation unless mismatches.empty? bottle_path.unlink if bottle_path.exist? - mismatches.map! do |field| - old_value = old_spec.send(field).inspect - value = bottle.send(field).inspect - "#{field}: old: #{old_value}, new: #{value}" + mismatches.map! do |key| + old_value = old_spec.send(key).inspect + value = bottle.send(key).inspect + "#{key}: old: #{old_value}, new: #{value}" end odie <<-EOS.undent @@ -405,7 +405,7 @@ def merge if old_value.empty? || value != old_value old_value = old_value_original.inspect value = value_original.inspect - mismatches << "#{field}: old: #{old_value}, new: #{value}" + mismatches << "#{key}: old: #{old_value}, new: #{value}" end end
false
Other
Homebrew
brew
ba852444131d021b1190cb670b038b78818229fb.json
language/python_virtualenv_constants: fix Rubocop warnings.
Library/Homebrew/language/python_virtualenv_constants.rb
@@ -1,2 +1,2 @@ -PYTHON_VIRTUALENV_URL = "https://files.pythonhosted.org/packages/5c/79/5dae7494b9f5ed061cff9a8ab8d6e1f02db352f3facf907d9eb614fb80e9/virtualenv-15.0.2.tar.gz" -PYTHON_VIRTUALENV_SHA256 = "fab40f32d9ad298fba04a260f3073505a16d52539a84843cf8c8369d4fd17167" +PYTHON_VIRTUALENV_URL = "https://files.pythonhosted.org/packages/5c/79/5dae7494b9f5ed061cff9a8ab8d6e1f02db352f3facf907d9eb614fb80e9/virtualenv-15.0.2.tar.gz".freeze +PYTHON_VIRTUALENV_SHA256 = "fab40f32d9ad298fba04a260f3073505a16d52539a84843cf8c8369d4fd17167".freeze
false
Other
Homebrew
brew
16be0f105ed3eef07133cdd09e48e562b85b7697.json
language/python: fix Rubocop warnings.
Library/Homebrew/language/python.rb
@@ -187,12 +187,11 @@ def create # Robustify symlinks to survive python3 patch upgrades @venv_root.find do |f| next unless f.symlink? - if (rp = f.realpath.to_s).start_with? HOMEBREW_CELLAR - python = rp.include?("python3") ? "python3" : "python" - new_target = rp.sub %r{#{HOMEBREW_CELLAR}/#{python}/[^/]+}, Formula[python].opt_prefix - f.unlink - f.make_symlink new_target - end + next unless (rp = f.realpath.to_s).start_with? HOMEBREW_CELLAR + python = rp.include?("python3") ? "python3" : "python" + new_target = rp.sub %r{#{HOMEBREW_CELLAR}/#{python}/[^/]+}, Formula[python].opt_prefix + f.unlink + f.make_symlink new_target end end
false
Other
Homebrew
brew
bde8d69d6e1129530fa2bbe1e88cf88e350521af.json
language/node: fix Rubocop warnings.
Library/Homebrew/language/node.rb
@@ -21,7 +21,7 @@ def self.std_npm_install_args(libexec) setup_npm_environment # tell npm to not install .brew_home by adding it to the .npmignore file # (or creating a new one if no .npmignore file already exists) - open(".npmignore", "a") { |f| f.write( "\n.brew_home\n") } + open(".npmignore", "a") { |f| f.write("\n.brew_home\n") } # npm install args for global style module format installed into libexec ["--verbose", "--global", "--prefix=#{libexec}", "."] end
false
Other
Homebrew
brew
78603a24f687b75e5487953f9212667e14cba8d2.json
language/haskell: fix Rubocop warnings.
Library/Homebrew/language/haskell.rb
@@ -72,7 +72,7 @@ def cabal_install_tools(*tools) end def install_cabal_package(*args) - options = if args[-1].kind_of?(Hash) then args.pop else {} end + options = args[-1].is_a?(Hash) ? args.pop : {} cabal_sandbox do cabal_install_tools(*options[:using]) if options[:using]
false
Other
Homebrew
brew
30fd4f3fe5d13f4fce9ba273580073327e17cf35.json
diagnostic: remove duplicate checks.
Library/Homebrew/diagnostic.rb
@@ -283,35 +283,16 @@ def check_for_broken_symlinks EOS end - def __check_subdir_access(base) - target = HOMEBREW_PREFIX+base - return unless target.exist? - - cant_read = [] - target.find do |d| - next unless d.directory? - cant_read << d unless d.writable_real? - end - return if cant_read.empty? - - inject_file_list cant_read.sort, <<-EOS.undent - Some directories in #{target} aren't writable. - This can happen if you "sudo make install" software that isn't managed - by Homebrew. If a brew tries to add locale information to one of these - directories, then the install will fail during the link step. + def check_tmpdir_sticky_bit + world_writable = HOMEBREW_TEMP.stat.mode & 0777 == 0777 + return if !world_writable || HOMEBREW_TEMP.sticky? - You should `sudo chown -R $(whoami)` them: + <<-EOS.undent + #{HOMEBREW_TEMP} is world-writable but does not have the sticky bit set. + Please execute `sudo chmod +t #{HOMEBREW_TEMP}` in your Terminal. EOS end - def check_access_share_locale - __check_subdir_access "share/locale" - end - - def check_access_share_man - __check_subdir_access "share/man" - end - def check_access_homebrew_repository return if HOMEBREW_REPOSITORY.writable_real? @@ -324,22 +305,11 @@ def check_access_homebrew_repository EOS end - def check_access_homebrew_cellar - return if HOMEBREW_CELLAR.writable_real? - - <<-EOS.undent - #{HOMEBREW_CELLAR} is not writable. - - You should change the ownership and permissions of #{HOMEBREW_CELLAR} - back to your user account. - sudo chown -R $(whoami) #{HOMEBREW_CELLAR} - EOS - end - - def check_access_top_level_directories + def check_access_prefix_directories not_writable_dirs = [] - (Keg::TOP_LEVEL_DIRECTORIES + ["opt"]).each do |dir| + extra_dirs = ["lib/pkgconfig", "share/locale", "share/man", "opt"] + (Keg::TOP_LEVEL_DIRECTORIES + extra_dirs).each do |dir| path = HOMEBREW_PREFIX/dir next unless path.exist? next if path.writable_real? @@ -352,42 +322,16 @@ def check_access_top_level_directories The following directories are not writable: #{not_writable_dirs.join("\n")} + This can happen if you "sudo make install" software that isn't managed + by Homebrew. If a formula tries to write a file to this directory, the + install will fail during the link step. + You should change the ownership and permissions of these directories. back to your user account. sudo chown -R $(whoami) #{not_writable_dirs.join(" ")} EOS end - def check_tmpdir_sticky_bit - world_writable = HOMEBREW_TEMP.stat.mode & 0777 == 0777 - return if !world_writable || HOMEBREW_TEMP.sticky? - - <<-EOS.undent - #{HOMEBREW_TEMP} is world-writable but does not have the sticky bit set. - Please execute `sudo chmod +t #{HOMEBREW_TEMP}` in your Terminal. - EOS - end - - (Keg::TOP_LEVEL_DIRECTORIES + ["lib/pkgconfig"]).each do |d| - define_method("check_access_#{d.sub("/", "_")}") do - dir = HOMEBREW_PREFIX.join(d) - return unless dir.exist? - return if dir.writable_real? - - <<-EOS.undent - #{dir} isn't writable. - - This can happen if you "sudo make install" software that isn't managed - by Homebrew. If a formula tries to write a file to this directory, the - install will fail during the link step. - - You should change the ownership and permissions of #{dir} back to - your user account. - sudo chown -R $(whoami) #{dir} - EOS - end - end - def check_access_site_packages return unless Language::Python.homebrew_site_packages.exist? return if Language::Python.homebrew_site_packages.writable_real? @@ -446,20 +390,6 @@ def check_access_cellar EOS end - def check_access_prefix_opt - opt = HOMEBREW_PREFIX.join("opt") - return unless opt.exist? - return if opt.writable_real? - - <<-EOS.undent - #{opt} isn't writable. - - You should change the ownership and permissions of #{opt} - back to your user account. - sudo chown -R $(whoami) #{opt} - EOS - end - def check_homebrew_prefix return if HOMEBREW_PREFIX.to_s == "/usr/local"
true
Other
Homebrew
brew
30fd4f3fe5d13f4fce9ba273580073327e17cf35.json
diagnostic: remove duplicate checks.
Library/Homebrew/test/test_diagnostic.rb
@@ -83,17 +83,6 @@ def test_check_access_cellar HOMEBREW_CELLAR.chmod mod end - def test_check_access_prefix_opt - opt = HOMEBREW_PREFIX.join("opt") - opt.mkpath - opt.chmod 0555 - - assert_match "#{opt} isn't writable.", - @checks.check_access_prefix_opt - ensure - opt.unlink - end - def test_check_homebrew_prefix # the integration tests are run in a special prefix assert_match "Your Homebrew is not installed to /usr/local",
true
Other
Homebrew
brew
ae57057afae0a714143de090a62ea772b097569c.json
help: use Commands module.
Library/Homebrew/cmd/help.rb
@@ -31,12 +31,14 @@ # NOTE Keep lines less than 80 characters! Wrapping is just not cricket. # NOTE The reason the string is at the top is so 25 lines is easy to measure! +require "commands" + module Homebrew def help(cmd = nil, flags = {}) # Resolve command aliases and find file containing the implementation. if cmd cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd) - path = command_path(cmd) + path = Commands.path(cmd) end # Display command-specific (or generic) help in response to `UsageError`. @@ -69,18 +71,6 @@ def help(cmd = nil, flags = {}) private - def command_path(cmd) - if File.exist?(HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.sh") - HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.sh" - elsif File.exist?(HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.sh") - HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.sh" - elsif File.exist?(HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb") - HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb" - elsif File.exist?(HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.rb") - HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.rb" - end - end - def command_help(path) help_lines = path.read.lines.grep(/^#:/) if help_lines.empty?
false
Other
Homebrew
brew
49dcbee99c46d92d65e9132a555ed3fc2865c1e6.json
command: use Commands module.
Library/Homebrew/cmd/command.rb
@@ -1,27 +1,20 @@ #: * `command` <cmd>: #: Display the path to the file which is used when invoking `brew` <cmd>. +require "commands" + module Homebrew def command abort "This command requires a command argument" if ARGV.empty? cmd = ARGV.first cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd) - if (path = internal_command_path cmd) + if (path = Commands.path(cmd)) puts path elsif (path = which("brew-#{cmd}") || which("brew-#{cmd}.rb")) puts path else odie "Unknown command: #{cmd}" end end - - private - - def internal_command_path(cmd) - extensions = %w[rb sh] - paths = extensions.map { |ext| HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.#{ext}" } - paths += extensions.map { |ext| HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.#{ext}" } - paths.find { |p| p.file? } - end end
false
Other
Homebrew
brew
0bb7fda143f3a609fdfed27e84422ff55f85db02.json
commands: add commands module for path lookup.
Library/Homebrew/commands.rb
@@ -0,0 +1,13 @@ +module Commands + def self.path(cmd) + if File.exist?(HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.sh") + HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.sh" + elsif File.exist?(HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.sh") + HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.sh" + elsif File.exist?(HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb") + HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb" + elsif File.exist?(HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.rb") + HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.rb" + end + end +end
true
Other
Homebrew
brew
0bb7fda143f3a609fdfed27e84422ff55f85db02.json
commands: add commands module for path lookup.
Library/Homebrew/test/test_commands.rb
@@ -63,16 +63,16 @@ def test_external_commands def test_internal_command_path assert_equal HOMEBREW_LIBRARY_PATH/"cmd/rbcmd.rb", - Homebrew.send(:internal_command_path, "rbcmd") + Commands.path("rbcmd") assert_equal HOMEBREW_LIBRARY_PATH/"cmd/shcmd.sh", - Homebrew.send(:internal_command_path, "shcmd") - assert_nil Homebrew.send(:internal_command_path, "idontexist1234") + Commands.path("shcmd") + assert_nil Commands.path("idontexist1234") end def test_internal_dev_command_path assert_equal HOMEBREW_LIBRARY_PATH/"dev-cmd/rbdevcmd.rb", - Homebrew.send(:internal_command_path, "rbdevcmd") + Commands.path("rbdevcmd") assert_equal HOMEBREW_LIBRARY_PATH/"dev-cmd/shdevcmd.sh", - Homebrew.send(:internal_command_path, "shdevcmd") + Commands.path("shdevcmd") end end
true
Other
Homebrew
brew
71881fd7a66227738a654d98f04647d412c11980.json
Add DEVELOPER COMMANDS to manpage.
Library/Homebrew/dev-cmd/man.rb
@@ -33,11 +33,8 @@ def regenerate_man_pages convert_man_page(cask_markup, TARGET_MAN_PATH/"brew-cask.1") end - def build_man_page - template = (SOURCE_PATH/"brew.1.md.erb").read - variables = OpenStruct.new - - variables[:commands] = Pathname.glob("#{HOMEBREW_LIBRARY_PATH}/cmd/*.{rb,sh}"). + def path_glob_commands(glob) + Pathname.glob(glob). sort_by { |source_file| sort_key_for_path(source_file) }. map { |source_file| source_file.read.lines. @@ -46,7 +43,14 @@ def build_man_page join }. reject { |s| s.strip.empty? || s.include?("@hide_from_man_page") } + end + + def build_man_page + template = (SOURCE_PATH/"brew.1.md.erb").read + variables = OpenStruct.new + variables[:commands] = path_glob_commands("#{HOMEBREW_LIBRARY_PATH}/cmd/*.{rb,sh}") + variables[:developer_commands] = path_glob_commands("#{HOMEBREW_LIBRARY_PATH}/dev-cmd/*.{rb,sh}") variables[:maintainers] = (HOMEBREW_REPOSITORY/"README.md"). read[/Homebrew's current maintainers are (.*)\./, 1]. scan(/\[([^\]]*)\]/).flatten
true
Other
Homebrew
brew
71881fd7a66227738a654d98f04647d412c11980.json
Add DEVELOPER COMMANDS to manpage.
Library/Homebrew/manpages/brew.1.md.erb
@@ -50,6 +50,10 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note <%= commands.join("\n") %> +## DEVELOPER COMMANDS + +<%= developer_commands.join("\n") %> + ## EXTERNAL COMMANDS Homebrew, like `git`(1), supports external commands. These are executable
true
Other
Homebrew
brew
71881fd7a66227738a654d98f04647d412c11980.json
Add DEVELOPER COMMANDS to manpage.
share/doc/homebrew/brew.1.html
@@ -39,29 +39,6 @@ <h2 id="COMMANDS">COMMANDS</h2> Read more at <a href="https://git.io/brew-analytics" data-bare-link="true">https://git.io/brew-analytics</a>.</p></dd> <dt><code>analytics</code> (<code>on</code>|<code>off</code>)</dt><dd><p>Turn on/off Homebrew's analytics.</p></dd> <dt><code>analytics</code> <code>regenerate-uuid</code></dt><dd><p>Regenerate UUID used in Homebrew's analytics.</p></dd> -<dt><code>audit</code> [<code>--strict</code>] [<code>--online</code>] [<code>--new-formula</code>] [<code>--display-cop-names</code>] [<code>--display-filename</code>] [<var>formulae</var>]</dt><dd><p>Check <var>formulae</var> for Homebrew coding style violations. This should be -run before submitting a new formula.</p> - -<p>If no <var>formulae</var> are provided, all of them are checked.</p> - -<p>If <code>--strict</code> is passed, additional checks are run, including RuboCop -style checks.</p> - -<p>If <code>--online</code> is passed, additional slower checks that require a network -connection are run.</p> - -<p>If <code>--new-formula</code> is passed, various additional checks are run that check -if a new formula is eligable for Homebrew. This should be used when creating -new formulae and implies <code>--strict</code> and <code>--online</code>.</p> - -<p>If <code>--display-cop-names</code> is passed, the RuboCop cop name for each violation -is included in the output.</p> - -<p>If <code>--display-filename</code> is passed, every line of output is prefixed with the -name of the file or formula being audited, to make the output easy to grep.</p> - -<p><code>audit</code> exits with a non-zero status if any errors are found. This is useful, -for instance, for implementing pre-commit hooks.</p></dd> <dt><code>cat</code> <var>formula</var></dt><dd><p>Display the source to <var>formula</var>.</p></dd> <dt><code>cleanup</code> [<code>--prune=</code><var>days</var>] [<code>--dry-run</code>] [<code>-s</code>] [<var>formulae</var>]</dt><dd><p>For all installed or specific formulae, remove any older versions from the cellar. In addition, old downloads from the Homebrew download-cache are deleted.</p> @@ -82,24 +59,6 @@ <h2 id="COMMANDS">COMMANDS</h2> <dt class="flush"><code>config</code></dt><dd><p>Show Homebrew and system configuration useful for debugging. If you file a bug report, you will likely be asked for this information if you do not provide it.</p></dd> -<dt><code>create</code> <var>URL</var> [<code>--autotools</code>|<code>--cmake</code>] [<code>--no-fetch</code>] [<code>--set-name</code> <var>name</var>] [<code>--set-version</code> <var>version</var>] [<code>--tap</code> <var>user</var><code>/</code><var>repo</var>]</dt><dd><p>Generate a formula for the downloadable file at <var>URL</var> and open it in the editor. -Homebrew will attempt to automatically derive the formula name -and version, but if it fails, you'll have to make your own template. The <code>wget</code> -formula serves as a simple example. For the complete API have a look at</p> - -<p><a href="http://www.rubydoc.info/github/Homebrew/brew/master/Formula" data-bare-link="true">http://www.rubydoc.info/github/Homebrew/brew/master/Formula</a></p> - -<p>If <code>--autotools</code> is passed, create a basic template for an Autotools-style build. -If <code>--cmake</code> is passed, create a basic template for a CMake-style build.</p> - -<p>If <code>--no-fetch</code> is passed, Homebrew will not download <var>URL</var> to the cache and -will thus not add the SHA256 to the formula for you.</p> - -<p>The options <code>--set-name</code> and <code>--set-version</code> each take an argument and allow -you to explicitly set the name and version of the package you are creating.</p> - -<p>The option <code>--tap</code> takes a tap as its argument and generates the formula in -the specified tap.</p></dd> <dt><code>deps</code> [<code>--1</code>] [<code>-n</code>] [<code>--union</code>] [<code>--full-name</code>] [<code>--installed</code>] [<code>--include-build</code>] [<code>--include-optional</code>] [<code>--skip-recommended</code>] <var>formulae</var></dt><dd><p>Show dependencies for <var>formulae</var>. When given multiple formula arguments, show the intersection of dependencies for <var>formulae</var>.</p> @@ -149,8 +108,6 @@ <h2 id="COMMANDS">COMMANDS</h2> installing.</p></dd> <dt class="flush"><code>doctor</code></dt><dd><p>Check your system for potential problems. Doctor exits with a non-zero status if any problems are found.</p></dd> -<dt class="flush"><code>edit</code></dt><dd><p>Open all of Homebrew for editing.</p></dd> -<dt><code>edit</code> <var>formula</var></dt><dd><p>Open <var>formula</var> in the editor.</p></dd> <dt><code>fetch</code> [<code>--force</code>] [<code>--retry</code>] [<code>-v</code>] [<code>--devel</code>|<code>--HEAD</code>] [<code>--deps</code>] [<code>--build-from-source</code>|<code>--force-bottle</code>] <var>formulae</var></dt><dd><p>Download the source packages for the given <var>formulae</var>. For tarballs, also print SHA-256 checksums.</p> @@ -395,21 +352,6 @@ <h2 id="COMMANDS">COMMANDS</h2> <dt><code>tap-pin</code> <var>tap</var></dt><dd><p>Pin <var>tap</var>, prioritizing its formulae over core when formula names are supplied by the user. See also <code>tap-unpin</code>.</p></dd> <dt><code>tap-unpin</code> <var>tap</var></dt><dd><p>Unpin <var>tap</var> so its formulae are no longer prioritized. See also <code>tap-pin</code>.</p></dd> -<dt><code>test</code> [<code>--devel</code>|<code>--HEAD</code>] [<code>--debug</code>] [<code>--keep-tmp</code>] <var>formula</var></dt><dd><p>A few formulae provide a test method. <code>brew test</code> <var>formula</var> runs this -test method. There is no standard output or return code, but it should -generally indicate to the user if something is wrong with the installed -formula.</p> - -<p>To test the development or head version of a formula, use <code>--devel</code> or -<code>--HEAD</code>.</p> - -<p>If <code>--debug</code> is passed and the test fails, an interactive debugger will be -launched with access to IRB or a shell inside the temporary test directory.</p> - -<p>If <code>--keep-tmp</code> is passed, the temporary files created for the test are -not deleted.</p> - -<p>Example: <code>brew install jruby &amp;&amp; brew test jruby</code></p></dd> <dt><code>uninstall</code>, <code>rm</code>, <code>remove</code> [<code>--force</code>] <var>formula</var></dt><dd><p>Uninstall <var>formula</var>.</p> <p>If <code>--force</code> is passed, and there are multiple versions of <var>formula</var> @@ -494,6 +436,156 @@ <h2 id="COMMANDS">COMMANDS</h2> </dl> +<h2 id="DEVELOPER-COMMANDS">DEVELOPER COMMANDS</h2> + +<dl> +<dt><code>audit</code> [<code>--strict</code>] [<code>--online</code>] [<code>--new-formula</code>] [<code>--display-cop-names</code>] [<code>--display-filename</code>] [<var>formulae</var>]</dt><dd><p>Check <var>formulae</var> for Homebrew coding style violations. This should be +run before submitting a new formula.</p> + +<p>If no <var>formulae</var> are provided, all of them are checked.</p> + +<p>If <code>--strict</code> is passed, additional checks are run, including RuboCop +style checks.</p> + +<p>If <code>--online</code> is passed, additional slower checks that require a network +connection are run.</p> + +<p>If <code>--new-formula</code> is passed, various additional checks are run that check +if a new formula is eligable for Homebrew. This should be used when creating +new formulae and implies <code>--strict</code> and <code>--online</code>.</p> + +<p>If <code>--display-cop-names</code> is passed, the RuboCop cop name for each violation +is included in the output.</p> + +<p>If <code>--display-filename</code> is passed, every line of output is prefixed with the +name of the file or formula being audited, to make the output easy to grep.</p> + +<p><code>audit</code> exits with a non-zero status if any errors are found. This is useful, +for instance, for implementing pre-commit hooks.</p></dd> +<dt><code>bottle</code> [<code>--verbose</code>] [<code>--no-rebuild</code>] [<code>--keep-old</code>] [<code>--skip-relocation</code>] [<code>--root-url=&lt;root_url></code>]:</dt><dd><p></p></dd> +<dt><code>bottle</code> <code>--merge</code> [<code>--no-commit</code>] [<code>--keep-old</code>] [<code>--write</code>]:</dt><dd><p></p> + +<p>Generate a bottle (binary package) from a formula installed with +<code>--build-bottle</code>.</p></dd> +<dt><code>bump-formula-pr</code> [<code>--devel</code>] [<code>--dry-run</code>] [<code>--audit</code>|<code>--strict</code>] <code>--url=</code><var>url</var> <code>--sha256=</code><var>sha-256</var> <var>formula</var>:</dt><dd><p></p></dd> +<dt><code>bump-formula-pr</code> [<code>--devel</code>] [<code>--dry-run</code>] [<code>--audit</code>|<code>--strict</code>] <code>--tag=</code><var>tag</var> <code>--revision=</code><var>revision</var> <var>formula</var></dt><dd><p>Creates a pull request to update the formula with a new url or a new tag.</p> + +<p>If a <var>url</var> is specified, the <var>sha-256</var> checksum of the new download must +also be specified.</p> + +<p>If a <var>tag</var> is specified, the git commit <var>revision</var> corresponding to that +tag must also be specified.</p> + +<p>If <code>--devel</code> is passed, bump the development rather than stable version. +The development spec must already exist.</p> + +<p>If <code>--dry-run</code> is passed, print what would be done rather than doing it.</p> + +<p>If <code>--audit</code> is passed, run <code>brew audit</code> before opening the PR.</p> + +<p>If <code>--strict</code> is passed, run <code>brew audit --strict</code> before opening the PR.</p> + +<p>Note that this command cannot be used to transition a formula from a +url-and-sha256 style specification into a tag-and-revision style +specification, nor vice versa. It must use whichever style specification +the preexisting formula already uses.</p></dd> +<dt><code>create</code> <var>URL</var> [<code>--autotools</code>|<code>--cmake</code>] [<code>--no-fetch</code>] [<code>--set-name</code> <var>name</var>] [<code>--set-version</code> <var>version</var>] [<code>--tap</code> <var>user</var><code>/</code><var>repo</var>]</dt><dd><p>Generate a formula for the downloadable file at <var>URL</var> and open it in the editor. +Homebrew will attempt to automatically derive the formula name +and version, but if it fails, you'll have to make your own template. The <code>wget</code> +formula serves as a simple example. For the complete API have a look at</p> + +<p><a href="http://www.rubydoc.info/github/Homebrew/brew/master/Formula" data-bare-link="true">http://www.rubydoc.info/github/Homebrew/brew/master/Formula</a></p> + +<p>If <code>--autotools</code> is passed, create a basic template for an Autotools-style build. +If <code>--cmake</code> is passed, create a basic template for a CMake-style build.</p> + +<p>If <code>--no-fetch</code> is passed, Homebrew will not download <var>URL</var> to the cache and +will thus not add the SHA256 to the formula for you.</p> + +<p>The options <code>--set-name</code> and <code>--set-version</code> each take an argument and allow +you to explicitly set the name and version of the package you are creating.</p> + +<p>The option <code>--tap</code> takes a tap as its argument and generates the formula in +the specified tap.</p></dd> +<dt class="flush"><code>edit</code></dt><dd><p>Open all of Homebrew for editing.</p></dd> +<dt><code>edit</code> <var>formula</var></dt><dd><p>Open <var>formula</var> in the editor.</p></dd> +<dt><code>linkage</code> [<code>--test</code>] [<code>--reverse</code>] <var>formula-name</var></dt><dd><p>Checks the library links of an installed formula.</p> + +<p>Only works on installed formulae. An error is raised if it is run on +uninstalled formulae.</p> + +<p>If <code>--test</code> is passed, only display missing libraries and exit with a +non-zero exit code if any missing libraries were found.</p> + +<p>If <code>--reverse</code> is passed, print the dylib followed by the binaries +which link to it for each library the keg references.</p></dd> +<dt class="flush"><code>man</code></dt><dd><p>Generate Homebrew's manpages.</p></dd> +</dl> + + +<p> <code>pull</code> [<code>--bottle</code>] [<code>--bump</code>] [<code>--clean</code>] [<code>--ignore-whitespace</code>] [<code>--resolve</code>] [<code>--branch-okay</code>] [<code>--no-pbcopy</code>] [<code>--no-publish</code>] <var>patch-source</var> [<var>patch-source</var>]</p> + +<pre><code>Gets a patch from a GitHub commit or pull request and applies it to Homebrew. +Optionally, installs the formulae changed by the patch. + +Each &lt;patch-source> may be one of: + * The ID number of a PR (Pull Request) in the homebrew/core GitHub + repository + * The URL of a PR on GitHub, using either the web page or API URL + formats. In this form, the PR may be on Homebrew/brew, + Homebrew/homebrew-core or any tap. + * The URL of a commit on GitHub + * A "http://bot.brew.sh/job/..." string specifying a testing job ID +</code></pre> + +<p> If <code>--bottle</code> was passed, handle bottles, pulling the bottle-update + commit and publishing files on Bintray. + If <code>--bump</code> was passed, for one-formula PRs, automatically reword + commit message to our preferred format. + If <code>--clean</code> was passed, do not rewrite or otherwise modify the + commits found in the pulled PR. + If <code>--ignore-whitespace</code> was passed, silently ignore whitespace + discrepancies when applying diffs. + If <code>--resolve</code> was passed, when a patch fails to apply, leave in + progress and allow user to + resolve, instead of aborting. + If <code>--branch-okay</code> was passed, do not warn if pulling to a branch + besides master (useful for testing). + If <code>--no-pbcopy</code> was passed, do not copy anything to the system + If <code>--no-publish</code> was passed, do not publish bottles to Bintray.</p> + +<dl> +<dt><code>tap_readme</code> [<code>-v</code>] <var>name</var></dt><dd><p>Generate the README.md file for a new tap.</p></dd> +<dt><code>test</code> [<code>--devel</code>|<code>--HEAD</code>] [<code>--debug</code>] [<code>--keep-tmp</code>] <var>formula</var></dt><dd><p>A few formulae provide a test method. <code>brew test</code> <var>formula</var> runs this +test method. There is no standard output or return code, but it should +generally indicate to the user if something is wrong with the installed +formula.</p> + +<p>To test the development or head version of a formula, use <code>--devel</code> or +<code>--HEAD</code>.</p> + +<p>If <code>--debug</code> is passed and the test fails, an interactive debugger will be +launched with access to IRB or a shell inside the temporary test directory.</p> + +<p>If <code>--keep-tmp</code> is passed, the temporary files created for the test are +not deleted.</p> + +<p>Example: <code>brew install jruby &amp;&amp; brew test jruby</code></p></dd> +<dt><code>tests</code> [<code>-v</code>] [<code>--coverage</code>] [<code>--generic</code>] [<code>--no-compat</code>] [<code>--only=</code><test_script/test_method>] [<code>--seed</code> <var>seed</var>] [<code>--trace</code>] [<code>--online</code>] [<code>--official-cmd-taps</code>]</dt><dd><p>Run Homebrew's unit and integration tests.</p></dd> +<dt><code>update-test</code> [<code>--commit=&lt;sha1></code>] [<code>--before=&lt;date></code>] [<code>--keep-tmp</code>]</dt><dd><p>Runs a test of <code>brew update</code> with a new repository clone.</p> + +<p>If no arguments are passed, use <code>origin/master</code> as the start commit.</p> + +<p>If <code>--commit=&lt;sha1></code> is passed, use <code>&lt;sha1></code> as the start commit.</p> + +<p>If <code>--before=&lt;date></code> is passed, use the commit at <code>&lt;date></code> as the +start commit.</p> + +<p>If <code>--keep-tmp</code> is passed, retain the temporary directory containing +the new repository clone.</p></dd> +</dl> + + <h2 id="EXTERNAL-COMMANDS">EXTERNAL COMMANDS</h2> <p>Homebrew, like <code>git</code>(1), supports external commands. These are executable
true
Other
Homebrew
brew
71881fd7a66227738a654d98f04647d412c11980.json
Add DEVELOPER COMMANDS to manpage.
share/man/man1/brew.1
@@ -56,31 +56,6 @@ Turn on/off Homebrew\'s analytics\. Regenerate UUID used in Homebrew\'s analytics\. . .TP -\fBaudit\fR [\fB\-\-strict\fR] [\fB\-\-online\fR] [\fB\-\-new\-formula\fR] [\fB\-\-display\-cop\-names\fR] [\fB\-\-display\-filename\fR] [\fIformulae\fR] -Check \fIformulae\fR for Homebrew coding style violations\. This should be run before submitting a new formula\. -. -.IP -If no \fIformulae\fR are provided, all of them are checked\. -. -.IP -If \fB\-\-strict\fR is passed, additional checks are run, including RuboCop style checks\. -. -.IP -If \fB\-\-online\fR is passed, additional slower checks that require a network connection are run\. -. -.IP -If \fB\-\-new\-formula\fR is passed, various additional checks are run that check if a new formula is eligable for Homebrew\. This should be used when creating new formulae and implies \fB\-\-strict\fR and \fB\-\-online\fR\. -. -.IP -If \fB\-\-display\-cop\-names\fR is passed, the RuboCop cop name for each violation is included in the output\. -. -.IP -If \fB\-\-display\-filename\fR is passed, every line of output is prefixed with the name of the file or formula being audited, to make the output easy to grep\. -. -.IP -\fBaudit\fR exits with a non\-zero status if any errors are found\. This is useful, for instance, for implementing pre\-commit hooks\. -. -.TP \fBcat\fR \fIformula\fR Display the source to \fIformula\fR\. . @@ -113,25 +88,6 @@ If \fB\-\-quiet\fR is passed, list only the names of commands without the header Show Homebrew and system configuration useful for debugging\. If you file a bug report, you will likely be asked for this information if you do not provide it\. . .TP -\fBcreate\fR \fIURL\fR [\fB\-\-autotools\fR|\fB\-\-cmake\fR] [\fB\-\-no\-fetch\fR] [\fB\-\-set\-name\fR \fIname\fR] [\fB\-\-set\-version\fR \fIversion\fR] [\fB\-\-tap\fR \fIuser\fR\fB/\fR\fIrepo\fR] -Generate a formula for the downloadable file at \fIURL\fR and open it in the editor\. Homebrew will attempt to automatically derive the formula name and version, but if it fails, you\'ll have to make your own template\. The \fBwget\fR formula serves as a simple example\. For the complete API have a look at -. -.IP -\fIhttp://www\.rubydoc\.info/github/Homebrew/brew/master/Formula\fR -. -.IP -If \fB\-\-autotools\fR is passed, create a basic template for an Autotools\-style build\. If \fB\-\-cmake\fR is passed, create a basic template for a CMake\-style build\. -. -.IP -If \fB\-\-no\-fetch\fR is passed, Homebrew will not download \fIURL\fR to the cache and will thus not add the SHA256 to the formula for you\. -. -.IP -The options \fB\-\-set\-name\fR and \fB\-\-set\-version\fR each take an argument and allow you to explicitly set the name and version of the package you are creating\. -. -.IP -The option \fB\-\-tap\fR takes a tap as its argument and generates the formula in the specified tap\. -. -.TP \fBdeps\fR [\fB\-\-1\fR] [\fB\-n\fR] [\fB\-\-union\fR] [\fB\-\-full\-name\fR] [\fB\-\-installed\fR] [\fB\-\-include\-build\fR] [\fB\-\-include\-optional\fR] [\fB\-\-skip\-recommended\fR] \fIformulae\fR Show dependencies for \fIformulae\fR\. When given multiple formula arguments, show the intersection of dependencies for \fIformulae\fR\. . @@ -193,14 +149,6 @@ The options \fB\-\-name=\fR\fIname\fR and \fB\-\-version=\fR\fIversion\fR each t Check your system for potential problems\. Doctor exits with a non\-zero status if any problems are found\. . .TP -\fBedit\fR -Open all of Homebrew for editing\. -. -.TP -\fBedit\fR \fIformula\fR -Open \fIformula\fR in the editor\. -. -.TP \fBfetch\fR [\fB\-\-force\fR] [\fB\-\-retry\fR] [\fB\-v\fR] [\fB\-\-devel\fR|\fB\-\-HEAD\fR] [\fB\-\-deps\fR] [\fB\-\-build\-from\-source\fR|\fB\-\-force\-bottle\fR] \fIformulae\fR Download the source packages for the given \fIformulae\fR\. For tarballs, also print SHA\-256 checksums\. . @@ -542,22 +490,6 @@ Pin \fItap\fR, prioritizing its formulae over core when formula names are suppli Unpin \fItap\fR so its formulae are no longer prioritized\. See also \fBtap\-pin\fR\. . .TP -\fBtest\fR [\fB\-\-devel\fR|\fB\-\-HEAD\fR] [\fB\-\-debug\fR] [\fB\-\-keep\-tmp\fR] \fIformula\fR -A few formulae provide a test method\. \fBbrew test\fR \fIformula\fR runs this test method\. There is no standard output or return code, but it should generally indicate to the user if something is wrong with the installed formula\. -. -.IP -To test the development or head version of a formula, use \fB\-\-devel\fR or \fB\-\-HEAD\fR\. -. -.IP -If \fB\-\-debug\fR is passed and the test fails, an interactive debugger will be launched with access to IRB or a shell inside the temporary test directory\. -. -.IP -If \fB\-\-keep\-tmp\fR is passed, the temporary files created for the test are not deleted\. -. -.IP -Example: \fBbrew install jruby && brew test jruby\fR -. -.TP \fBuninstall\fR, \fBrm\fR, \fBremove\fR [\fB\-\-force\fR] \fIformula\fR Uninstall \fIformula\fR\. . @@ -684,6 +616,182 @@ Display where tap \fIuser\fR\fB/\fR\fIrepo\fR\'s directory is located\. \fB\-\-version\fR Print the version number of Homebrew to standard output and exit\. . +.SH "DEVELOPER COMMANDS" +. +.TP +\fBaudit\fR [\fB\-\-strict\fR] [\fB\-\-online\fR] [\fB\-\-new\-formula\fR] [\fB\-\-display\-cop\-names\fR] [\fB\-\-display\-filename\fR] [\fIformulae\fR] +Check \fIformulae\fR for Homebrew coding style violations\. This should be run before submitting a new formula\. +. +.IP +If no \fIformulae\fR are provided, all of them are checked\. +. +.IP +If \fB\-\-strict\fR is passed, additional checks are run, including RuboCop style checks\. +. +.IP +If \fB\-\-online\fR is passed, additional slower checks that require a network connection are run\. +. +.IP +If \fB\-\-new\-formula\fR is passed, various additional checks are run that check if a new formula is eligable for Homebrew\. This should be used when creating new formulae and implies \fB\-\-strict\fR and \fB\-\-online\fR\. +. +.IP +If \fB\-\-display\-cop\-names\fR is passed, the RuboCop cop name for each violation is included in the output\. +. +.IP +If \fB\-\-display\-filename\fR is passed, every line of output is prefixed with the name of the file or formula being audited, to make the output easy to grep\. +. +.IP +\fBaudit\fR exits with a non\-zero status if any errors are found\. This is useful, for instance, for implementing pre\-commit hooks\. +. +.TP +\fBbottle\fR [\fB\-\-verbose\fR] [\fB\-\-no\-rebuild\fR] [\fB\-\-keep\-old\fR] [\fB\-\-skip\-relocation\fR] [\fB\-\-root\-url=<root_url>\fR]: + +. +.TP +\fBbottle\fR \fB\-\-merge\fR [\fB\-\-no\-commit\fR] [\fB\-\-keep\-old\fR] [\fB\-\-write\fR]: +. +.IP +Generate a bottle (binary package) from a formula installed with \fB\-\-build\-bottle\fR\. +. +.TP +\fBbump\-formula\-pr\fR [\fB\-\-devel\fR] [\fB\-\-dry\-run\fR] [\fB\-\-audit\fR|\fB\-\-strict\fR] \fB\-\-url=\fR\fIurl\fR \fB\-\-sha256=\fR\fIsha\-256\fR \fIformula\fR: + +. +.TP +\fBbump\-formula\-pr\fR [\fB\-\-devel\fR] [\fB\-\-dry\-run\fR] [\fB\-\-audit\fR|\fB\-\-strict\fR] \fB\-\-tag=\fR\fItag\fR \fB\-\-revision=\fR\fIrevision\fR \fIformula\fR +Creates a pull request to update the formula with a new url or a new tag\. +. +.IP +If a \fIurl\fR is specified, the \fIsha\-256\fR checksum of the new download must also be specified\. +. +.IP +If a \fItag\fR is specified, the git commit \fIrevision\fR corresponding to that tag must also be specified\. +. +.IP +If \fB\-\-devel\fR is passed, bump the development rather than stable version\. The development spec must already exist\. +. +.IP +If \fB\-\-dry\-run\fR is passed, print what would be done rather than doing it\. +. +.IP +If \fB\-\-audit\fR is passed, run \fBbrew audit\fR before opening the PR\. +. +.IP +If \fB\-\-strict\fR is passed, run \fBbrew audit \-\-strict\fR before opening the PR\. +. +.IP +Note that this command cannot be used to transition a formula from a url\-and\-sha256 style specification into a tag\-and\-revision style specification, nor vice versa\. It must use whichever style specification the preexisting formula already uses\. +. +.TP +\fBcreate\fR \fIURL\fR [\fB\-\-autotools\fR|\fB\-\-cmake\fR] [\fB\-\-no\-fetch\fR] [\fB\-\-set\-name\fR \fIname\fR] [\fB\-\-set\-version\fR \fIversion\fR] [\fB\-\-tap\fR \fIuser\fR\fB/\fR\fIrepo\fR] +Generate a formula for the downloadable file at \fIURL\fR and open it in the editor\. Homebrew will attempt to automatically derive the formula name and version, but if it fails, you\'ll have to make your own template\. The \fBwget\fR formula serves as a simple example\. For the complete API have a look at +. +.IP +\fIhttp://www\.rubydoc\.info/github/Homebrew/brew/master/Formula\fR +. +.IP +If \fB\-\-autotools\fR is passed, create a basic template for an Autotools\-style build\. If \fB\-\-cmake\fR is passed, create a basic template for a CMake\-style build\. +. +.IP +If \fB\-\-no\-fetch\fR is passed, Homebrew will not download \fIURL\fR to the cache and will thus not add the SHA256 to the formula for you\. +. +.IP +The options \fB\-\-set\-name\fR and \fB\-\-set\-version\fR each take an argument and allow you to explicitly set the name and version of the package you are creating\. +. +.IP +The option \fB\-\-tap\fR takes a tap as its argument and generates the formula in the specified tap\. +. +.TP +\fBedit\fR +Open all of Homebrew for editing\. +. +.TP +\fBedit\fR \fIformula\fR +Open \fIformula\fR in the editor\. +. +.TP +\fBlinkage\fR [\fB\-\-test\fR] [\fB\-\-reverse\fR] \fIformula\-name\fR +Checks the library links of an installed formula\. +. +.IP +Only works on installed formulae\. An error is raised if it is run on uninstalled formulae\. +. +.IP +If \fB\-\-test\fR is passed, only display missing libraries and exit with a non\-zero exit code if any missing libraries were found\. +. +.IP +If \fB\-\-reverse\fR is passed, print the dylib followed by the binaries which link to it for each library the keg references\. +. +.TP +\fBman\fR +Generate Homebrew\'s manpages\. +. +.P +\fBpull\fR [\fB\-\-bottle\fR] [\fB\-\-bump\fR] [\fB\-\-clean\fR] [\fB\-\-ignore\-whitespace\fR] [\fB\-\-resolve\fR] [\fB\-\-branch\-okay\fR] [\fB\-\-no\-pbcopy\fR] [\fB\-\-no\-publish\fR] \fIpatch\-source\fR [\fIpatch\-source\fR] +. +.IP "" 4 +. +.nf + +Gets a patch from a GitHub commit or pull request and applies it to Homebrew\. +Optionally, installs the formulae changed by the patch\. + +Each <patch\-source> may be one of: + * The ID number of a PR (Pull Request) in the homebrew/core GitHub + repository + * The URL of a PR on GitHub, using either the web page or API URL + formats\. In this form, the PR may be on Homebrew/brew, + Homebrew/homebrew\-core or any tap\. + * The URL of a commit on GitHub + * A "http://bot\.brew\.sh/job/\.\.\." string specifying a testing job ID +. +.fi +. +.IP "" 0 +. +.P +If \fB\-\-bottle\fR was passed, handle bottles, pulling the bottle\-update commit and publishing files on Bintray\. If \fB\-\-bump\fR was passed, for one\-formula PRs, automatically reword commit message to our preferred format\. If \fB\-\-clean\fR was passed, do not rewrite or otherwise modify the commits found in the pulled PR\. If \fB\-\-ignore\-whitespace\fR was passed, silently ignore whitespace discrepancies when applying diffs\. If \fB\-\-resolve\fR was passed, when a patch fails to apply, leave in progress and allow user to resolve, instead of aborting\. If \fB\-\-branch\-okay\fR was passed, do not warn if pulling to a branch besides master (useful for testing)\. If \fB\-\-no\-pbcopy\fR was passed, do not copy anything to the system If \fB\-\-no\-publish\fR was passed, do not publish bottles to Bintray\. +. +.TP +\fBtap_readme\fR [\fB\-v\fR] \fIname\fR +Generate the README\.md file for a new tap\. +. +.TP +\fBtest\fR [\fB\-\-devel\fR|\fB\-\-HEAD\fR] [\fB\-\-debug\fR] [\fB\-\-keep\-tmp\fR] \fIformula\fR +A few formulae provide a test method\. \fBbrew test\fR \fIformula\fR runs this test method\. There is no standard output or return code, but it should generally indicate to the user if something is wrong with the installed formula\. +. +.IP +To test the development or head version of a formula, use \fB\-\-devel\fR or \fB\-\-HEAD\fR\. +. +.IP +If \fB\-\-debug\fR is passed and the test fails, an interactive debugger will be launched with access to IRB or a shell inside the temporary test directory\. +. +.IP +If \fB\-\-keep\-tmp\fR is passed, the temporary files created for the test are not deleted\. +. +.IP +Example: \fBbrew install jruby && brew test jruby\fR +. +.TP +\fBtests\fR [\fB\-v\fR] [\fB\-\-coverage\fR] [\fB\-\-generic\fR] [\fB\-\-no\-compat\fR] [\fB\-\-only=\fR<test_script/test_method>] [\fB\-\-seed\fR \fIseed\fR] [\fB\-\-trace\fR] [\fB\-\-online\fR] [\fB\-\-official\-cmd\-taps\fR] +Run Homebrew\'s unit and integration tests\. +. +.TP +\fBupdate\-test\fR [\fB\-\-commit=<sha1>\fR] [\fB\-\-before=<date>\fR] [\fB\-\-keep\-tmp\fR] +Runs a test of \fBbrew update\fR with a new repository clone\. +. +.IP +If no arguments are passed, use \fBorigin/master\fR as the start commit\. +. +.IP +If \fB\-\-commit=<sha1>\fR is passed, use \fB<sha1>\fR as the start commit\. +. +.IP +If \fB\-\-before=<date>\fR is passed, use the commit at \fB<date>\fR as the start commit\. +. +.IP +If \fB\-\-keep\-tmp\fR is passed, retain the temporary directory containing the new repository clone\. +. .SH "EXTERNAL COMMANDS" Homebrew, like \fBgit\fR(1), supports external commands\. These are executable scripts that reside somewhere in the \fBPATH\fR, named \fBbrew\-\fR\fIcmdname\fR or \fBbrew\-\fR\fIcmdname\fR\fB\.rb\fR, which can be invoked like \fBbrew\fR \fIcmdname\fR\. This allows you to create your own commands without modifying Homebrew\'s internals\. .
true
Other
Homebrew
brew
4f1d47bc156253ab0eabf6b7aba1fcfa46d80633.json
Test source.path on Tab.create and .for_formula
Library/Homebrew/test/test_tab.rb
@@ -121,6 +121,40 @@ def test_from_file assert_equal source_path, tab.source["path"] end + def test_create + f = formula { url "foo-1.0" } + compiler = DevelopmentTools.default_compiler + stdlib = :libcxx + tab = Tab.create(f, compiler, stdlib) + + assert_equal f.path.to_s, tab.source["path"] + end + + def test_create_from_alias + alias_path = CoreTap.instance.alias_dir/"bar" + f = formula(:alias_path => alias_path) { url "foo-1.0" } + compiler = DevelopmentTools.default_compiler + stdlib = :libcxx + tab = Tab.create(f, compiler, stdlib) + + assert_equal f.alias_path.to_s, tab.source["path"] + end + + def test_for_formula + f = formula { url "foo-1.0" } + tab = Tab.for_formula(f) + + assert_equal f.path.to_s, tab.source["path"] + end + + def test_for_formula_from_alias + alias_path = CoreTap.instance.alias_dir/"bar" + f = formula(:alias_path => alias_path) { url "foo-1.0" } + tab = Tab.for_formula(f) + + assert_equal alias_path.to_s, tab.source["path"] + end + def test_to_json tab = Tab.new(Utils::JSON.load(@tab.to_json)) assert_equal @tab.used_options.sort, tab.used_options.sort
true
Other
Homebrew
brew
4f1d47bc156253ab0eabf6b7aba1fcfa46d80633.json
Test source.path on Tab.create and .for_formula
Library/Homebrew/test/testing_env.rb
@@ -72,8 +72,8 @@ class TestCase < ::Minitest::Test TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze - def formula(name = "formula_name", path = Formulary.core_path(name), spec = :stable, &block) - @_f = Class.new(Formula, &block).new(name, path, spec) + def formula(name = "formula_name", path = Formulary.core_path(name), spec = :stable, alias_path: nil, &block) + @_f = Class.new(Formula, &block).new(name, path, spec, :alias_path => alias_path) end def mktmpdir(prefix_suffix = nil, &block)
true
Other
Homebrew
brew
f9e16ee2e04b7b23b273bfa683ab54a85ed40660.json
Combine Tab alias_path with source.path
Library/Homebrew/tab.rb
@@ -27,11 +27,10 @@ def self.create(formula, compiler, stdlib) "time" => Time.now.to_i, "source_modified_time" => formula.source_modified_time.to_i, "HEAD" => HOMEBREW_REPOSITORY.git_head, - "alias_path" => formula.alias_path.to_s, "compiler" => compiler, "stdlib" => stdlib, "source" => { - "path" => formula.path.to_s, + "path" => formula.specified_path.to_s, "tap" => formula.tap ? formula.tap.name : nil, "spec" => formula.active_spec_sym.to_s, "versions" => { @@ -56,10 +55,6 @@ def self.from_file_content(content, path) attributes["source_modified_time"] ||= 0 attributes["source"] ||= {} - if alias_path = attributes["alias_path"] - attributes["alias_path"] = Pathname.new(alias_path) - end - tapped_from = attributes["tapped_from"] unless tapped_from.nil? || tapped_from == "path or URL" attributes["source"]["tap"] = attributes.delete("tapped_from") @@ -142,7 +137,7 @@ def self.for_formula(f) tab = empty tab.unused_options = f.options.as_flags tab.source = { - "path" => f.path.to_s, + "path" => f.specified_path.to_s, "tap" => f.tap ? f.tap.name : f.tap, "spec" => f.active_spec_sym.to_s, "versions" => { @@ -166,7 +161,6 @@ def self.empty "time" => nil, "source_modified_time" => 0, "HEAD" => nil, - "alias_path" => nil, "stdlib" => nil, "compiler" => DevelopmentTools.default_compiler, "source" => { @@ -298,7 +292,6 @@ def to_json "time" => time, "source_modified_time" => source_modified_time.to_i, "HEAD" => self.HEAD, - "alias_path" => (alias_path.to_s if alias_path), "stdlib" => (stdlib.to_s if stdlib), "compiler" => (compiler.to_s if compiler), "source" => source
true
Other
Homebrew
brew
f9e16ee2e04b7b23b273bfa683ab54a85ed40660.json
Combine Tab alias_path with source.path
Library/Homebrew/test/test_tab.rb
@@ -43,9 +43,9 @@ def test_defaults assert_nil tab.stable_version assert_nil tab.devel_version assert_nil tab.head_version - assert_nil tab.alias_path assert_equal DevelopmentTools.default_compiler, tab.cxxstdlib.compiler assert_nil tab.cxxstdlib.type + assert_nil tab.source["path"] end def test_include? @@ -100,7 +100,7 @@ def test_from_old_version_file def test_from_file path = Pathname.new(TEST_DIRECTORY).join("fixtures", "receipt.json") tab = Tab.from_file(path) - alias_path = Pathname.new("/usr/local/Library/Taps/homebrew/homebrew-core/Aliases/test-formula") + source_path = "/usr/local/Library/Taps/hombrew/homebrew-core/Formula/foo.rb" assert_equal @used.sort, tab.used_options.sort assert_equal @unused.sort, tab.unused_options.sort @@ -118,7 +118,7 @@ def test_from_file assert_equal "2.14", tab.stable_version.to_s assert_equal "2.15", tab.devel_version.to_s assert_equal "HEAD-0000000", tab.head_version.to_s - assert_equal alias_path, tab.alias_path + assert_equal source_path, tab.source["path"] end def test_to_json @@ -136,7 +136,7 @@ def test_to_json assert_equal @tab.stable_version, tab.stable_version assert_equal @tab.devel_version, tab.devel_version assert_equal @tab.head_version, tab.head_version - assert_equal @tab.alias_path, tab.alias_path + assert_equal @tab.source["path"], tab.source["path"] end def test_remap_deprecated_options
true
Other
Homebrew
brew
159ba9b012415ec5bd1c446c66a02702a7909225.json
test-bot: put exception, retry on missing formula. This will be useful in debugging (and recovering from) the situation where sometimes formulae can't be found when specifying multiple on the command-line.
Library/Homebrew/dev-cmd/test-bot.rb
@@ -247,11 +247,13 @@ def no_args? def safe_formula_canonical_name(formula_name) Formulary.factory(formula_name).full_name - rescue TapFormulaUnavailableError => e + rescue TapFormulaUnavailableError, FormulaUnavailableError => e raise if e.tap.installed? test "brew", "tap", e.tap.name retry unless steps.last.failed? - rescue FormulaUnavailableError, TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError => e + onoe e + puts e.backtrace + rescue TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError => e onoe e puts e.backtrace end
false
Other
Homebrew
brew
2498d99a143d0e50e92a0aa60316d47c9ea83edc.json
Implement opoo in bash
Library/Homebrew/brew.sh
@@ -1,20 +1,35 @@ HOMEBREW_VERSION="0.9.9" -onoe() { - if [[ -t 2 ]] # check whether stderr is a tty. +o() { + if [[ $# -eq 0 ]] then - echo -ne "\033[4;31mError\033[0m: " >&2 # highlight Error with underline and red color + /bin/cat else - echo -n "Error: " >&2 + echo "$*" fi - if [[ $# -eq 0 ]] +} + +highlight() { + if [[ -t 1 ]] # check whether stdout is a tty. then - /bin/cat >&2 + echo -ne "\033[4;$1m$2\033[0m" else - echo "$*" >&2 + echo -n "$2" fi } +opoo() { + highlight 33 Warning >&2 # yellow + echo -n ": " >&2 + o "$@" >&2 +} + +onoe() { + highlight 31 Error >&2 # red + echo -n ": " >&2 + o "$@" >&2 +} + odie() { onoe "$@" exit 1
false
Other
Homebrew
brew
d8a2a90daccfb23705ef9eada2f49b800ec2c9ee.json
test-bot: add missing @tap check.
Library/Homebrew/dev-cmd/test-bot.rb
@@ -671,7 +671,7 @@ def homebrew # test no-op update from current commit (to current commit, a no-op). test "brew", "update-test", "--commit=HEAD" end - else + elsif @tap test "brew", "readall", "--aliases", @tap.name end end
false
Other
Homebrew
brew
0ef3e1e0dcbcd5aa55408fe81d23613e1c2c5e79.json
Preserve alias when installing formulae Part of #567
Library/Homebrew/formula.rb
@@ -58,6 +58,11 @@ class Formula # e.g. `this-formula` attr_reader :name + # The name specified when installing this {Formula}. + # Could be the name of the {Formula}, or an alias. + # e.g. `another-name-for-this-formula` + attr_reader :install_name + # The fully-qualified name of this {Formula}. # For core formula it's the same as {#name}. # e.g. `homebrew/tap-name/this-formula` @@ -143,9 +148,10 @@ class Formula attr_accessor :build # @private - def initialize(name, path, spec) + def initialize(name, path, spec, install_name: name) @name = name @path = path + @install_name = install_name @revision = self.class.revision || 0 @version_scheme = self.class.version_scheme || 0 @@ -502,6 +508,21 @@ def installed_kegs installed_prefixes.map { |dir| Keg.new(dir) } end + # Formula reference to use to get an identical installation of the formula. + # + # Usually, the formula's path is a good canonical identifier for the formula. + # Just using whatever was passed to `brew install` isn't a good idea, because + # if it was e.g. a URL, it could end up being downloaded twice. + # + # However, if the formula was installed with an alias (i.e. `install_name` is + # different from `name`), that should be used instead so that information is + # preserved. Aliases are looked up in repositories that have already been + # tapped, so we don't have to worry about doing extra HTTP requests, or other + # expensive operations, when looking them up again. + def install_ref + install_name == name ? path : install_name + end + # The directory where the formula's binaries should be installed. # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only.
true
Other
Homebrew
brew
0ef3e1e0dcbcd5aa55408fe81d23613e1c2c5e79.json
Preserve alias when installing formulae Part of #567
Library/Homebrew/formula_installer.rb
@@ -589,7 +589,7 @@ def build -I #{HOMEBREW_LOAD_PATH} -- #{HOMEBREW_LIBRARY_PATH}/build.rb - #{formula.path} + #{formula.install_ref} ].concat(build_argv) Sandbox.print_sandbox_message if Sandbox.formula?(formula)
true
Other
Homebrew
brew
0ef3e1e0dcbcd5aa55408fe81d23613e1c2c5e79.json
Preserve alias when installing formulae Part of #567
Library/Homebrew/formulary.rb
@@ -68,15 +68,18 @@ class FormulaLoader attr_reader :name # The formula's ruby file's path or filename attr_reader :path + # The name used to install the formula + attr_reader :install_name def initialize(name, path) @name = name @path = path.resolved_path + @install_name = name end # Gets the formula instance. def get_formula(spec) - klass.new(name, path, spec) + klass.new(name, path, spec, install_name: install_name) end def klass @@ -118,6 +121,7 @@ def initialize(alias_path) path = alias_path.resolved_path name = path.basename(".rb").to_s super name, path + @install_name = alias_path.basename.to_s end end
true
Other
Homebrew
brew
0ef3e1e0dcbcd5aa55408fe81d23613e1c2c5e79.json
Preserve alias when installing formulae Part of #567
Library/Homebrew/tab.rb
@@ -27,6 +27,7 @@ def self.create(formula, compiler, stdlib) "time" => Time.now.to_i, "source_modified_time" => formula.source_modified_time.to_i, "HEAD" => HOMEBREW_REPOSITORY.git_head, + "install_name" => formula.install_name, "compiler" => compiler, "stdlib" => stdlib, "source" => { @@ -161,6 +162,7 @@ def self.empty "time" => nil, "source_modified_time" => 0, "HEAD" => nil, + "install_name" => nil, "stdlib" => nil, "compiler" => DevelopmentTools.default_compiler, "source" => { @@ -292,6 +294,7 @@ def to_json "time" => time, "source_modified_time" => source_modified_time.to_i, "HEAD" => self.HEAD, + "install_name" => install_name, "stdlib" => (stdlib.to_s if stdlib), "compiler" => (compiler.to_s if compiler), "source" => source
true
Other
Homebrew
brew
0ef3e1e0dcbcd5aa55408fe81d23613e1c2c5e79.json
Preserve alias when installing formulae Part of #567
Library/Homebrew/test/fixtures/receipt.json
@@ -11,6 +11,7 @@ "poured_from_bottle": true, "time": 1403827774, "HEAD": "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef", + "install_name": "test-formula", "stdlib": "libcxx", "compiler": "clang", "source": {
true