diff options
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/brew.sh | 10 | ||||
| -rw-r--r-- | Library/Homebrew/dev-cmd/irb.rb (renamed from Library/Homebrew/cmd/irb.rb) | 34 | ||||
| -rw-r--r-- | Library/Homebrew/dev-cmd/linkage.rb | 2 | ||||
| -rwxr-xr-x | Library/Homebrew/dev-cmd/ruby.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/dev-cmd/tap-new.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/extend/ARGV.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/extend/ENV.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/extend/os/mac/formula_cellar_checks.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/language/python.rb | 7 | ||||
| -rw-r--r-- | Library/Homebrew/linkage_checker.rb (renamed from Library/Homebrew/os/mac/linkage_checker.rb) | 0 | ||||
| -rw-r--r-- | Library/Homebrew/manpages/brew.1.md.erb | 9 | ||||
| -rw-r--r-- | Library/Homebrew/migrator.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/test/ENV_spec.rb | 14 | ||||
| -rw-r--r-- | Library/Homebrew/test/dev-cmd/ruby_spec.rb | 13 |
14 files changed, 82 insertions, 25 deletions
diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 77a60dfc7..590dde363 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -253,6 +253,14 @@ then then export HOMEBREW_DEV_CMD_RUN="1" fi + + # Don't allow non-developers to customise Ruby warnings. + unset HOMEBREW_RUBY_WARNINGS +fi + +if [[ -z "$HOMEBREW_RUBY_WARNINGS" ]] +then + export HOMEBREW_RUBY_WARNINGS="-W0" fi if [[ -f "$HOMEBREW_LIBRARY/Homebrew/cmd/$HOMEBREW_COMMAND.sh" ]] @@ -371,5 +379,5 @@ else # Unshift command back into argument list (unless argument list was empty). [[ "$HOMEBREW_ARG_COUNT" -gt 0 ]] && set -- "$HOMEBREW_COMMAND" "$@" - { update-preinstall; exec "$HOMEBREW_RUBY_PATH" -W0 "$HOMEBREW_LIBRARY/Homebrew/brew.rb" "$@"; } + { update-preinstall; exec "$HOMEBREW_RUBY_PATH" $HOMEBREW_RUBY_WARNINGS "$HOMEBREW_LIBRARY/Homebrew/brew.rb" "$@"; } fi diff --git a/Library/Homebrew/cmd/irb.rb b/Library/Homebrew/dev-cmd/irb.rb index 4cd3d4c9e..700cbe009 100644 --- a/Library/Homebrew/cmd/irb.rb +++ b/Library/Homebrew/dev-cmd/irb.rb @@ -1,11 +1,9 @@ -#: * `irb` [`--examples`]: +#: * `irb` [`--examples`] [`--pry`]: #: Enter the interactive Homebrew Ruby shell. #: #: If `--examples` is passed, several examples will be shown. - -require "formula" -require "keg" -require "irb" +#: If `--pry` is passed or HOMEBREW_PRY is set, pry will be +#: used instead of irb. class Symbol def f(*args) @@ -23,17 +21,33 @@ module Homebrew module_function def irb - $LOAD_PATH.unshift("#{HOMEBREW_LIBRARY_PATH}/cask/lib") - require "hbc" - if ARGV.include? "--examples" puts "'v8'.f # => instance of the v8 formula" puts ":hub.f.installed?" puts ":lua.f.methods - 1.methods" puts ":mpd.f.recursive_dependencies.reject(&:installed?)" + return + end + + if ARGV.pry? + Homebrew.install_gem_setup_path! "pry" + require "pry" + Pry.config.prompt_name = "brew" + else + require "irb" + end + + require "formula" + require "keg" + + $LOAD_PATH.unshift("#{HOMEBREW_LIBRARY_PATH}/cask/lib") + require "hbc" + + ohai "Interactive Homebrew Shell" + puts "Example commands available with: brew irb --examples" + if ARGV.pry? + Pry.start else - ohai "Interactive Homebrew Shell" - puts "Example commands available with: brew irb --examples" IRB.start end end diff --git a/Library/Homebrew/dev-cmd/linkage.rb b/Library/Homebrew/dev-cmd/linkage.rb index 31e9bd103..c33c181a1 100644 --- a/Library/Homebrew/dev-cmd/linkage.rb +++ b/Library/Homebrew/dev-cmd/linkage.rb @@ -10,7 +10,7 @@ #: If `--reverse` is passed, print the dylib followed by the binaries #: which link to it for each library the keg references. -require "os/mac/linkage_checker" +require "linkage_checker" module Homebrew module_function diff --git a/Library/Homebrew/dev-cmd/ruby.rb b/Library/Homebrew/dev-cmd/ruby.rb index 2df212301..c5696d6bb 100755 --- a/Library/Homebrew/dev-cmd/ruby.rb +++ b/Library/Homebrew/dev-cmd/ruby.rb @@ -8,6 +8,6 @@ module Homebrew module_function def ruby - exec ENV["HOMEBREW_RUBY_PATH"], "-I#{HOMEBREW_LIBRARY_PATH}", "-rglobal", "-rcmd/irb", *ARGV + exec ENV["HOMEBREW_RUBY_PATH"], "-I#{HOMEBREW_LIBRARY_PATH}", "-rglobal", "-rdev-cmd/irb", *ARGV end end diff --git a/Library/Homebrew/dev-cmd/tap-new.rb b/Library/Homebrew/dev-cmd/tap-new.rb index 38cdb1c2e..31299d2b0 100644 --- a/Library/Homebrew/dev-cmd/tap-new.rb +++ b/Library/Homebrew/dev-cmd/tap-new.rb @@ -50,8 +50,7 @@ module Homebrew osx_image: xcode9.2 cache: directories: - - $HOME/.gem/ruby - - Library/Homebrew/vendor/bundle + - /usr/local/Homebrew/Library/Homebrew/vendor/bundle branches: only: - master diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb index d9da014f0..2bc84620a 100644 --- a/Library/Homebrew/extend/ARGV.rb +++ b/Library/Homebrew/extend/ARGV.rb @@ -267,6 +267,10 @@ module HomebrewArgvExtension include? "--fetch-HEAD" end + def pry? + include?("--pry") || !ENV["HOMEBREW_PRY"].nil? + end + # eg. `foo -ns -i --bar` has three switches, n, s and i def switch?(char) return false if char.length > 1 diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb index 374be49b9..002220764 100644 --- a/Library/Homebrew/extend/ENV.rb +++ b/Library/Homebrew/extend/ENV.rb @@ -28,9 +28,9 @@ module EnvActivation end def clear_sensitive_environment! - ENV.each_key do |key| + each_key do |key| next unless /(cookie|key|token|password)/i =~ key - ENV.delete key + delete key end end end diff --git a/Library/Homebrew/extend/os/mac/formula_cellar_checks.rb b/Library/Homebrew/extend/os/mac/formula_cellar_checks.rb index 901d8945f..0b1a1643e 100644 --- a/Library/Homebrew/extend/os/mac/formula_cellar_checks.rb +++ b/Library/Homebrew/extend/os/mac/formula_cellar_checks.rb @@ -1,4 +1,4 @@ -require "os/mac/linkage_checker" +require "linkage_checker" module FormulaCellarChecks def check_shadowed_headers diff --git a/Library/Homebrew/language/python.rb b/Library/Homebrew/language/python.rb index 3908f4b8f..648abb5b1 100644 --- a/Library/Homebrew/language/python.rb +++ b/Library/Homebrew/language/python.rb @@ -15,10 +15,11 @@ module Language def self.each_python(build, &block) original_pythonpath = ENV["PYTHONPATH"] - ["python", "python3"].each do |python| - next if build.without? python + { "python@3" => "python3", "python@2" => "python2.7" }.each do |python_formula, python| + python_formula = Formulary.factory(python_formula) + next if build.without? python_formula.to_s version = major_minor_version python - ENV["PYTHONPATH"] = if Formulary.factory(python).installed? + ENV["PYTHONPATH"] = if python_formula.installed? nil else homebrew_site_packages(version) diff --git a/Library/Homebrew/os/mac/linkage_checker.rb b/Library/Homebrew/linkage_checker.rb index cf6c12f22..cf6c12f22 100644 --- a/Library/Homebrew/os/mac/linkage_checker.rb +++ b/Library/Homebrew/linkage_checker.rb diff --git a/Library/Homebrew/manpages/brew.1.md.erb b/Library/Homebrew/manpages/brew.1.md.erb index 533e1d594..618e050f6 100644 --- a/Library/Homebrew/manpages/brew.1.md.erb +++ b/Library/Homebrew/manpages/brew.1.md.erb @@ -183,6 +183,10 @@ can take several different forms: *Note:* Homebrew doesn't require permissions for any of the scopes. + * `HOMEBREW_INSTALL_BADGE`: + Text printed before the installation summary of each successful build. + Defaults to the beer emoji. + * `HOMEBREW_LOGS`: If set, Homebrew will use the given directory to store log files. @@ -220,9 +224,8 @@ can take several different forms: If set, Homebrew will not use the GitHub API for e.g searches or fetching relevant issues on a failed install. - * `HOMEBREW_INSTALL_BADGE`: - Text printed before the installation summary of each successful build. - Defaults to the beer emoji. + * `HOMEBREW_PRY`: + If set, Homebrew will use `pry` for the `brew irb` command. * `HOMEBREW_SVN`: When exporting from Subversion, Homebrew will use `HOMEBREW_SVN` if set, diff --git a/Library/Homebrew/migrator.rb b/Library/Homebrew/migrator.rb index 6c0321938..7287a3c88 100644 --- a/Library/Homebrew/migrator.rb +++ b/Library/Homebrew/migrator.rb @@ -293,7 +293,8 @@ class Migrator new_keg.remove_linked_keg_record if new_keg.linked? begin - new_keg.link + mode = OpenStruct.new(overwrite: true) + new_keg.link(mode) rescue Keg::ConflictError => e onoe "Error while executing `brew link` step on #{newname}" puts e diff --git a/Library/Homebrew/test/ENV_spec.rb b/Library/Homebrew/test/ENV_spec.rb index 07f6cdb6b..8b39e52d7 100644 --- a/Library/Homebrew/test/ENV_spec.rb +++ b/Library/Homebrew/test/ENV_spec.rb @@ -141,6 +141,20 @@ shared_examples EnvActivation do expect(subject["MAKEFLAGS"]).to eq("-j4") end + + describe "#clear_sensitive_environment!" do + it "removes sensitive environment variables" do + subject["SECRET_TOKEN"] = "password" + subject.clear_sensitive_environment! + expect(subject).not_to include("SECRET_TOKEN") + end + + it "leaves non-sensitive environment variables alone" do + subject["FOO"] = "bar" + subject.clear_sensitive_environment! + expect(subject["FOO"]).to eq "bar" + end + end end describe Stdenv do diff --git a/Library/Homebrew/test/dev-cmd/ruby_spec.rb b/Library/Homebrew/test/dev-cmd/ruby_spec.rb new file mode 100644 index 000000000..e05bccc83 --- /dev/null +++ b/Library/Homebrew/test/dev-cmd/ruby_spec.rb @@ -0,0 +1,13 @@ +describe "brew ruby", :integration_test do + it "executes ruby code with Homebrew's libraries loaded" do + expect { brew "ruby", "-e", "exit 0" } + .to be_a_success + .and not_to_output.to_stdout + .and not_to_output.to_stderr + + expect { brew "ruby", "-e", "exit 1" } + .to be_a_failure + .and not_to_output.to_stdout + .and not_to_output.to_stderr + end +end |
