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
acde828a45c452b54413a3cd711752343e54f3cf.json
ARGV: Replace ARGV.verbose? with Homebrew.args.verbose?
Library/Homebrew/cli/parser.rb
@@ -64,10 +64,14 @@ def switch(*names, description: nil, env: nil, required_for: nil, depends_on: ni set_constraints(name, required_for: required_for, depends_on: depends_on) end - enable_switch(*names, from: :env) if !env.nil? && !ENV["HOMEBREW_#{env.to_s.upcase}"].nil? + enable_switch(*names, from: :env) if env?(env) end alias switch_option switch + def env?(env) + env.present? && ENV["HOMEBREW_#{env.to_s.upcase}"].present? + end + def usage_banner(text) @parser.banner = Formatter.wrap("#{text}\n", COMMAND_DESC_WIDTH) end
true
Other
Homebrew
brew
acde828a45c452b54413a3cd711752343e54f3cf.json
ARGV: Replace ARGV.verbose? with Homebrew.args.verbose?
Library/Homebrew/download_strategy.rb
@@ -60,7 +60,7 @@ def stage ref_type: @ref_type, ref: @ref) .extract_nestedly(basename: basename, prioritise_extension: true, - verbose: ARGV.verbose? && !shutup) + verbose: Homebrew.args.verbose? && !shutup) chdir end @@ -104,7 +104,7 @@ def system_command!(*args, **options) *args, print_stdout: !shutup, print_stderr: !shutup, - verbose: ARGV.verbose? && !shutup, + verbose: Homebrew.args.verbose? && !shutup, env: env, **options, ) @@ -497,7 +497,7 @@ class NoUnzipCurlDownloadStrategy < CurlDownloadStrategy def stage UnpackStrategy::Uncompressed.new(cached_location) .extract(basename: basename, - verbose: ARGV.verbose? && !shutup) + verbose: Homebrew.args.verbose? && !shutup) end end @@ -552,7 +552,7 @@ def fetch_repo(target, url, revision = nil, ignore_externals = false) # This saves on bandwidth and will have a similar effect to verifying the # cache as it will make any changes to get the right revision. args = [] - args << "--quiet" unless ARGV.verbose? + args << "--quiet" unless Homebrew.args.verbose? if revision ohai "Checking out #{@ref}" @@ -896,7 +896,7 @@ def repo_valid? end def quiet_flag - "-Q" unless ARGV.verbose? + "-Q" unless Homebrew.args.verbose? end def clone_repo
true
Other
Homebrew
brew
acde828a45c452b54413a3cd711752343e54f3cf.json
ARGV: Replace ARGV.verbose? with Homebrew.args.verbose?
Library/Homebrew/exceptions.rb
@@ -381,7 +381,7 @@ def fetch_issues def dump puts - if ARGV.verbose? + if Homebrew.args.verbose? require "system_config" require "build_environment"
true
Other
Homebrew
brew
acde828a45c452b54413a3cd711752343e54f3cf.json
ARGV: Replace ARGV.verbose? with Homebrew.args.verbose?
Library/Homebrew/extend/pathname.rb
@@ -443,8 +443,8 @@ def counts MAXIMUM_VERBOSE_OUTPUT = 100 def verbose? - return ARGV.verbose? unless ENV["CI"] - return false unless ARGV.verbose? + return Homebrew.args.verbose? unless ENV["CI"] + return false unless Homebrew.args.verbose? if total < MAXIMUM_VERBOSE_OUTPUT true
true
Other
Homebrew
brew
acde828a45c452b54413a3cd711752343e54f3cf.json
ARGV: Replace ARGV.verbose? with Homebrew.args.verbose?
Library/Homebrew/formula.rb
@@ -506,7 +506,7 @@ def head_version_outdated?(version, fetch_head: false) return false unless head&.downloader.is_a?(VCSDownloadStrategy) downloader = head.downloader - downloader.shutup! unless ARGV.verbose? + downloader.shutup! unless Homebrew.args.verbose? downloader.commit_outdated?(version.version.commit) end @@ -1844,7 +1844,7 @@ def undeclared_runtime_dependencies # # If there is a "make", "install" available, please use it! # system "make", "install"</pre> def system(cmd, *args) - verbose = ARGV.verbose? + verbose = Homebrew.args.verbose? verbose_using_dots = !ENV["HOMEBREW_VERBOSE_USING_DOTS"].nil? # remove "boring" arguments so that the important ones are more likely to
true
Other
Homebrew
brew
acde828a45c452b54413a3cd711752343e54f3cf.json
ARGV: Replace ARGV.verbose? with Homebrew.args.verbose?
Library/Homebrew/formula_installer.rb
@@ -56,7 +56,7 @@ def initialize(formula) @include_test = ARGV.include?("--include-test") @interactive = false @git = false - @verbose = ARGV.verbose? + @verbose = Homebrew.args.verbose? @quieter = ARGV.quieter? @debug = ARGV.debug? @installed_as_dependency = false
true
Other
Homebrew
brew
acde828a45c452b54413a3cd711752343e54f3cf.json
ARGV: Replace ARGV.verbose? with Homebrew.args.verbose?
Library/Homebrew/keg.rb
@@ -573,7 +573,9 @@ def resolve_any_conflicts(dst, mode) begin keg = Keg.for(src) rescue NotAKegError - puts "Won't resolve conflicts for symlink #{dst} as it doesn't resolve into the Cellar" if ARGV.verbose? + if Homebrew.args.verbose? + puts "Won't resolve conflicts for symlink #{dst} as it doesn't resolve into the Cellar" + end return end @@ -584,7 +586,7 @@ def resolve_any_conflicts(dst, mode) def make_relative_symlink(dst, src, mode) if dst.symlink? && src == dst.resolved_path - puts "Skipping; link already exists: #{dst}" if ARGV.verbose? + puts "Skipping; link already exists: #{dst}" if Homebrew.args.verbose? return end
true
Other
Homebrew
brew
acde828a45c452b54413a3cd711752343e54f3cf.json
ARGV: Replace ARGV.verbose? with Homebrew.args.verbose?
Library/Homebrew/resource.rb
@@ -127,7 +127,7 @@ def fetch(verify_download_integrity: true) def verify_download_integrity(fn) if fn.file? - ohai "Verifying #{fn.basename} checksum" if ARGV.verbose? + ohai "Verifying #{fn.basename} checksum" if Homebrew.args.verbose? fn.verify_checksum(checksum) end rescue ChecksumMissingError
true
Other
Homebrew
brew
acde828a45c452b54413a3cd711752343e54f3cf.json
ARGV: Replace ARGV.verbose? with Homebrew.args.verbose?
Library/Homebrew/sandbox.rb
@@ -127,7 +127,7 @@ def exec(*args) end end - if @failed && ARGV.verbose? + if @failed && ENV["HOMEBREW_VERBOSE"].present? ohai "Sandbox log" puts logs $stdout.flush # without it, brew test-bot would fail to catch the log
true
Other
Homebrew
brew
acde828a45c452b54413a3cd711752343e54f3cf.json
ARGV: Replace ARGV.verbose? with Homebrew.args.verbose?
Library/Homebrew/style.rb
@@ -30,7 +30,7 @@ def check_style_impl(files, output_type, fix: false, except_cops: nil, only_cops args << "--parallel" end - args += ["--extra-details", "--display-cop-names"] if ARGV.verbose? + args += ["--extra-details", "--display-cop-names"] if Homebrew.args.verbose? if except_cops except_cops.map! { |cop| RuboCop::Cop::Cop.registry.qualified_cop_name(cop.to_s, "") }
true
Other
Homebrew
brew
acde828a45c452b54413a3cd711752343e54f3cf.json
ARGV: Replace ARGV.verbose? with Homebrew.args.verbose?
Library/Homebrew/system_command.rb
@@ -222,7 +222,7 @@ def plist end def warn_plist_garbage(garbage) - return unless ARGV.verbose? + return unless Homebrew.args.verbose? return unless garbage.match?(/\S/) opoo "Received non-XML output from #{Formatter.identifier(command.first)}:"
true
Other
Homebrew
brew
acde828a45c452b54413a3cd711752343e54f3cf.json
ARGV: Replace ARGV.verbose? with Homebrew.args.verbose?
Library/Homebrew/test/rubocops/lines_spec.rb
@@ -604,7 +604,7 @@ class Foo < Formula desc "foo" url 'https://brew.sh/foo-1.0.tgz' def install - verbose = ARGV.verbose? + verbose = Homebrew.args.verbose? end end RUBY
true
Other
Homebrew
brew
acde828a45c452b54413a3cd711752343e54f3cf.json
ARGV: Replace ARGV.verbose? with Homebrew.args.verbose?
Library/Homebrew/test/system_command_result_spec.rb
@@ -120,7 +120,7 @@ context "when verbose" do before do - allow(ARGV).to receive(:verbose?).and_return(true) + allow(Homebrew.args).to receive(:verbose?).and_return(true) end it "warns about garbage" do @@ -144,7 +144,7 @@ context "when verbose" do before do - allow(ARGV).to receive(:verbose?).and_return(true) + allow(Homebrew.args).to receive(:verbose?).and_return(true) end it "warns about garbage" do
true
Other
Homebrew
brew
acde828a45c452b54413a3cd711752343e54f3cf.json
ARGV: Replace ARGV.verbose? with Homebrew.args.verbose?
Library/Homebrew/utils.rb
@@ -35,7 +35,7 @@ def _system(cmd, *args, **options) end def system(cmd, *args, **options) - if ARGV.verbose? + if Homebrew.args.verbose? puts "#{cmd} #{args * " "}".gsub(RUBY_PATH, "ruby") .gsub($LOAD_PATH.join(File::PATH_SEPARATOR).to_s, "$LOAD_PATH") end @@ -87,7 +87,7 @@ def require?(path) end def ohai_title(title) - title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose? + title = Tty.truncate(title) if $stdout.tty? && !Homebrew.args.verbose? Formatter.headline(title, color: :blue) end @@ -104,7 +104,7 @@ def odebug(title, *sput) end def oh1(title, options = {}) - title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose? && options.fetch(:truncate, :auto) == :auto + title = Tty.truncate(title) if $stdout.tty? && !Homebrew.args.verbose? && options.fetch(:truncate, :auto) == :auto puts Formatter.headline(title, color: :green) end @@ -373,7 +373,7 @@ def capture_stderr end def nostdout - if ARGV.verbose? + if Homebrew.args.verbose? yield else begin
true
Other
Homebrew
brew
acde828a45c452b54413a3cd711752343e54f3cf.json
ARGV: Replace ARGV.verbose? with Homebrew.args.verbose?
Library/Homebrew/utils/curl.rb
@@ -34,7 +34,7 @@ def curl_args(*extra_args, show_output: false, user_agent: :default) unless show_output args << "--fail" - args << "--progress-bar" unless ARGV.verbose? + args << "--progress-bar" unless Homebrew.args.verbose? args << "--verbose" if ENV["HOMEBREW_CURL_VERBOSE"] args << "--silent" unless $stdout.tty? end
true
Other
Homebrew
brew
a1102f253c71fb48c3af566b2fe02619c0ed31eb.json
Remove checks to variable that is not set anywhere
Library/Homebrew/utils/ruby.sh
@@ -46,10 +46,7 @@ setup-ruby-path() { ruby_version_new_enough="$("$HOMEBREW_RUBY_PATH" --enable-frozen-string-literal --disable=gems,did_you_mean,rubyopt -rrubygems -e "puts Gem::Version.new(RUBY_VERSION.to_s.dup) >= Gem::Version.new('$minimum_ruby_version')")" fi - if [[ -n"$HOMEBREW_MACOS_SYSTEM_RUBY_OLD_ENOUGH" ]] - then - ruby_version_old_enough="true" - elif [[ -n "$HOMEBREW_RUBY_PATH" && -z "$HOMEBREW_FORCE_VENDOR_RUBY" ]] + if [[ -n "$HOMEBREW_RUBY_PATH" && -z "$HOMEBREW_FORCE_VENDOR_RUBY" ]] then ruby_version_old_enough="$("$HOMEBREW_RUBY_PATH" --enable-frozen-string-literal --disable=gems,did_you_mean,rubyopt -rrubygems -e "puts Gem::Version.new(RUBY_VERSION.to_s.dup) < Gem::Version.new('$maximum_ruby_version')")" fi
false
Other
Homebrew
brew
027cc685348b65b601b45898dbce8ad171579dde.json
Add condition to check if ruby version is < 2.7
Library/Homebrew/utils/ruby.sh
@@ -6,6 +6,7 @@ setup-ruby-path() { # When bumping check if HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH (in brew.sh) # also needs to be changed. local minimum_ruby_version="2.6.3" + local maximum_ruby_version="2.7.0" vendor_dir="$HOMEBREW_LIBRARY/Homebrew/vendor" vendor_ruby_current_version="$vendor_dir/portable-ruby/current" @@ -45,7 +46,15 @@ setup-ruby-path() { ruby_version_new_enough="$("$HOMEBREW_RUBY_PATH" --enable-frozen-string-literal --disable=gems,did_you_mean,rubyopt -rrubygems -e "puts Gem::Version.new(RUBY_VERSION.to_s.dup) >= Gem::Version.new('$minimum_ruby_version')")" fi - if [[ -z "$HOMEBREW_RUBY_PATH" || -n "$HOMEBREW_FORCE_VENDOR_RUBY" || "$ruby_version_new_enough" != "true" ]] + if [[ -n"$HOMEBREW_MACOS_SYSTEM_RUBY_OLD_ENOUGH" ]] + then + ruby_version_old_enough="true" + elif [[ -n "$HOMEBREW_RUBY_PATH" && -z "$HOMEBREW_FORCE_VENDOR_RUBY" ]] + then + ruby_version_old_enough="$("$HOMEBREW_RUBY_PATH" --enable-frozen-string-literal --disable=gems,did_you_mean,rubyopt -rrubygems -e "puts Gem::Version.new(RUBY_VERSION.to_s.dup) < Gem::Version.new('$maximum_ruby_version')")" + fi + + if [[ -z "$HOMEBREW_RUBY_PATH" || -n "$HOMEBREW_FORCE_VENDOR_RUBY" || "$ruby_version_new_enough" != "true" || "$ruby_version_old_enough" != "true" ]] then brew vendor-install ruby if [[ ! -x "$vendor_ruby_path" ]]
false
Other
Homebrew
brew
c65b3f3f13f91682d3b136387028cd3a4c782615.json
cmd/gist-logs: Fix bug with parsing of command-line arguments - A user reported the following error when running `brew gist-logs`, reproducible with any formula: ``` $ brew gist-logs rustup-init Error: undefined method `length' for nil:NilClass Please report this bug: https://docs.brew.sh/Troubleshooting /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/gist-logs.rb:145:in `gist_logs' /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:102:in ``` - From what I can tell, `gist_logs_args.parse` had ended up in the wrong method. The `gistify_logs` method already has `formula` (ie the formula name) passed into it. But it's the `gist_logs` method that needs to do the argument parsing. This was discovered by looking at some other recently changed ARGV => Homebrew.args code like cmd/info.
Library/Homebrew/cmd/gist-logs.rb
@@ -33,8 +33,6 @@ def gist_logs_args end def gistify_logs(f) - gist_logs_args.parse - files = load_logs(f.logs) build_time = f.logs.ctime timestamp = build_time.strftime("%Y-%m-%d_%H-%M-%S") @@ -142,6 +140,8 @@ def create_issue(repo, title, body) end def gist_logs + gist_logs_args.parse + raise FormulaUnspecifiedError if Homebrew.args.resolved_formulae.length != 1 Install.perform_preinstall_checks(all_fatal: true)
false
Other
Homebrew
brew
4babdf2a0f620a8886caeec32704fe3a0e9703a4.json
postinstall: use arguments from main command.
Library/Homebrew/postinstall.rb
@@ -7,17 +7,10 @@ require "fcntl" require "socket" require "cli/parser" - -def postinstall_args - Homebrew::CLI::Parser.new do - switch :force - switch :verbose - switch :debug - end -end +require "cmd/postinstall" begin - postinstall_args.parse + Homebrew.postinstall_args.parse error_pipe = UNIXSocket.open(ENV["HOMEBREW_ERROR_PIPE"], &:recv_io) error_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
false
Other
Homebrew
brew
eadf17881d4210a593aaad3db4ea793c13ca66e6.json
Homebrew/test.rb: Reuse `test_args` method
Library/Homebrew/dev-cmd/test.rb
@@ -8,31 +8,33 @@ module Homebrew module_function - def test_args - Homebrew::CLI::Parser.new do - usage_banner <<~EOS - `test` [<options>] <formula> - - Run the test method provided by an installed formula. - There is no standard output or return code, but generally it should notify the - user if something is wrong with the installed formula. - - *Example:* `brew install jruby && brew test jruby` - EOS - switch "--devel", - description: "Test the development version of a formula." - switch "--HEAD", - description: "Test the head version of a formula." - switch "--keep-tmp", - description: "Retain the temporary files created for the test." - switch :verbose - switch :debug - conflicts "--devel", "--HEAD" + module Test + def self.args + Homebrew::CLI::Parser.new do + usage_banner <<~EOS + `test` [<options>] <formula> + + Run the test method provided by an installed formula. + There is no standard output or return code, but generally it should notify the + user if something is wrong with the installed formula. + + *Example:* `brew install jruby && brew test jruby` + EOS + switch "--devel", + description: "Test the development version of a formula." + switch "--HEAD", + description: "Test the head version of a formula." + switch "--keep-tmp", + description: "Retain the temporary files created for the test." + switch :verbose + switch :debug + conflicts "--devel", "--HEAD" + end end end def test - test_args.parse + Test.args.parse raise FormulaUnspecifiedError if ARGV.named.empty?
true
Other
Homebrew
brew
eadf17881d4210a593aaad3db4ea793c13ca66e6.json
Homebrew/test.rb: Reuse `test_args` method
Library/Homebrew/test.rb
@@ -9,20 +9,13 @@ require "formula_assertions" require "fcntl" require "socket" -require "cli/parser" - -def test_args - Homebrew::CLI::Parser.new do - switch :force - switch :verbose - switch :debug - end -end +require "dev-cmd/test" TEST_TIMEOUT_SECONDS = 5 * 60 begin - test_args.parse + Homebrew::Test.args.parse + error_pipe = UNIXSocket.open(ENV["HOMEBREW_ERROR_PIPE"], &:recv_io) error_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
true
Other
Homebrew
brew
2f39057243dcfc71d16415bf8005d3f37e0ea41a.json
Improve handling of *_GIT_REMOTE env vars - Output a message whenever a non-default remote is set. - Ensure that `CoreTap.instance.install` uses the right remote.
Library/Homebrew/cmd/update.sh
@@ -30,6 +30,10 @@ git_init_if_necessary() { trap '{ rm -rf .git; exit 1; }' EXIT git init git config --bool core.autocrlf false + if [[ "$HOMEBREW_DEFAULT_BREW_GIT_REMOTE" != "$HOMEBREW_BREW_GIT_REMOTE" ]] + then + echo "HOMEBREW_BREW_GIT_REMOTE set: using $HOMEBREW_BREW_GIT_REMOTE for Homebrew/brew Git remote URL." + fi git config remote.origin.url "$HOMEBREW_BREW_GIT_REMOTE" git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" latest_tag="$(git ls-remote --tags --refs -q origin | tail -n1 | cut -f2)" @@ -48,6 +52,10 @@ git_init_if_necessary() { trap '{ rm -rf .git; exit 1; }' EXIT git init git config --bool core.autocrlf false + if [[ "$HOMEBREW_DEFAULT_CORE_GIT_REMOTE" != "$HOMEBREW_CORE_GIT_REMOTE" ]] + then + echo "HOMEBREW_CORE_GIT_REMOTE set: using $HOMEBREW_CORE_GIT_REMOTE for Homebrew/core Git remote URL." + fi git config remote.origin.url "$HOMEBREW_CORE_GIT_REMOTE" git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" git fetch --force --depth=1 origin refs/heads/master:refs/remotes/origin/master @@ -397,6 +405,7 @@ EOS if [[ "$HOMEBREW_DEFAULT_BREW_GIT_REMOTE" != "$HOMEBREW_BREW_GIT_REMOTE" ]] then safe_cd "$HOMEBREW_REPOSITORY" + echo "HOMEBREW_BREW_GIT_REMOTE set: using $HOMEBREW_BREW_GIT_REMOTE for Homebrew/brew Git remote." git remote set-url origin "$HOMEBREW_BREW_GIT_REMOTE" git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" latest_tag="$(git ls-remote --tags --refs -q origin | tail -n1 | cut -f2)" @@ -407,6 +416,7 @@ EOS [[ -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] then safe_cd "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" + echo "HOMEBREW_CORE_GIT_REMOTE set: using $HOMEBREW_CORE_GIT_REMOTE for Homebrew/brew Git remote." git remote set-url origin "$HOMEBREW_CORE_GIT_REMOTE" git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" git fetch --force --depth=1 origin refs/heads/master:refs/remotes/origin/master
true
Other
Homebrew
brew
2f39057243dcfc71d16415bf8005d3f37e0ea41a.json
Improve handling of *_GIT_REMOTE env vars - Output a message whenever a non-default remote is set. - Ensure that `CoreTap.instance.install` uses the right remote.
Library/Homebrew/tap.rb
@@ -648,6 +648,15 @@ def self.ensure_installed! safe_system HOMEBREW_BREW_FILE, "tap", instance.name end + def install(options = {}) + if HOMEBREW_CORE_GIT_REMOTE != default_remote + puts "HOMEBREW_CORE_GIT_REMOTE set: using #{HOMEBREW_CORE_GIT_REMOTE} " \ + "for Homebrew/core Git remote URL." + options[:clone_target] ||= HOMEBREW_CORE_GIT_REMOTE + end + super(options) + end + # @private def uninstall raise "Tap#uninstall is not available for CoreTap"
true
Other
Homebrew
brew
779304df68a5b49387a86bc3a12fc05a3201678b.json
audit: add "homebrew/core" for relevant checks
Library/Homebrew/dev-cmd/audit.rb
@@ -219,7 +219,7 @@ def initialize(formula, options = {}) @except = options[:except] # Accept precomputed style offense results, for efficiency @style_offenses = options[:style_offenses] - # Allow the formula tap to be set as `core`, for testing purposes + # Allow the formula tap to be set as homebrew/core, for testing purposes @core_tap = formula.tap&.core_tap? || options[:core_tap] @problems = [] @new_formula_problems = [] @@ -335,15 +335,15 @@ def audit_formula_name name = formula.name - problem "'#{name}' is blacklisted." if MissingFormula.blacklisted_reason(name) + problem "'#{name}' is blacklisted from homebrew/core." if MissingFormula.blacklisted_reason(name) if Formula.aliases.include? name - problem "Formula name conflicts with existing aliases." + problem "Formula name conflicts with existing aliases in homebrew/core." return end if oldname = CoreTap.instance.formula_renames[name] - problem "'#{name}' is reserved as the old name of #{oldname}" + problem "'#{name}' is reserved as the old name of #{oldname} in homebrew/core." return end @@ -380,7 +380,8 @@ def audit_deps if self.class.aliases.include?(dep.name) && (dep_f.core_formula? || !dep_f.versioned_formula?) - problem "Dependency '#{dep.name}' is an alias; use the canonical name '#{dep.to_formula.full_name}'." + problem "Dependency '#{dep.name}' from homebrew/core is an alias; " \ + "use the canonical name '#{dep.to_formula.full_name}'." end if @new_formula && @@ -414,14 +415,14 @@ def audit_deps next unless @core_tap if dep.tags.include?(:recommended) || dep.tags.include?(:optional) - problem "Formulae should not have optional or recommended dependencies" + problem "Formulae in homebrew/core should not have optional or recommended dependencies" end end next unless @core_tap if spec.requirements.map(&:recommended?).any? || spec.requirements.map(&:optional?).any? - problem "Formulae should not have optional or recommended requirements" + problem "Formulae in homebrew/core should not have optional or recommended requirements" end end end @@ -485,7 +486,7 @@ def audit_postgresql begin Formula[previous_formula_name] rescue FormulaUnavailableError - problem "Versioned #{previous_formula_name} must be created for " \ + problem "Versioned #{previous_formula_name} in homebrew/core must be created for " \ "`brew-postgresql-upgrade-database` and `pg_upgrade` to work." end end @@ -513,7 +514,7 @@ def audit_versioned_keg_only return if keg_only_whitelist.include?(formula.name) || formula.name.start_with?("gcc@") - problem "Versioned formulae should use `keg_only :versioned_formula`" + problem "Versioned formulae in homebrew/core should use `keg_only :versioned_formula`" end def audit_homepage @@ -542,7 +543,7 @@ def audit_bottle_spec return unless formula.bottle_defined? - new_formula_problem "New formulae should not have a `bottle do` block" + new_formula_problem "New formulae in homebrew/core should not have a `bottle do` block" end def audit_bottle_disabled @@ -553,7 +554,7 @@ def audit_bottle_disabled return unless @core_tap - problem "Formulae should not use `bottle :disabled`" + problem "Formulae in homebrew/core should not use `bottle :disabled`" end def audit_github_repository @@ -698,7 +699,7 @@ def audit_specs return unless @core_tap - problem "Formulae should not have a `devel` spec" if formula.devel + problem "Formulae in homebrew/core should not have a `devel` spec" if formula.devel if formula.head && @versioned_formula head_spec_message = "Formulae should not have a `HEAD` spec" @@ -951,7 +952,7 @@ def line_problems(line, _lineno) return unless @core_tap - problem "`env :std` in `core` formulae is deprecated" if line.include?("env :std") + problem "`env :std` in homebrew/core formulae is deprecated" if line.include?("env :std") end def audit_reverse_migration
true
Other
Homebrew
brew
779304df68a5b49387a86bc3a12fc05a3201678b.json
audit: add "homebrew/core" for relevant checks
Library/Homebrew/rubocops/lines.rb
@@ -163,7 +163,8 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node) return unless formula_tap == "homebrew-core" find_method_with_args(body_node, :depends_on, "mpich") do - problem "Use 'depends_on \"open-mpi\"' instead of '#{@offensive_node.source}'." + problem "Formulae in homebrew/core should use 'depends_on \"open-mpi\"' " \ + "instead of '#{@offensive_node.source}'." end end @@ -201,7 +202,7 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node) next if formula_tap != "homebrew-core" || file_path&.include?("linuxbrew") find_instance_method_call(body_node, "OS", method_name) do |check| - problem "Don't use #{check.source}; Homebrew/core only supports macOS" + problem "Don't use #{check.source}; homebrew/core only supports macOS" end end
true
Other
Homebrew
brew
779304df68a5b49387a86bc3a12fc05a3201678b.json
audit: add "homebrew/core" for relevant checks
Library/Homebrew/rubocops/options.rb
@@ -10,8 +10,8 @@ class Options < FormulaCop DEPRECATION_MSG = "macOS has been 64-bit only since 10.6 so 32-bit options are deprecated." UNI_DEPRECATION_MSG = "macOS has been 64-bit only since 10.6 so universal options are deprecated." - DEP_OPTION = "Formulae should not use `deprecated_option`" - OPTION = "Formulae should not have an `option`" + DEP_OPTION = "Formulae in homebrew/core should not use `deprecated_option`." + OPTION = "Formulae in homebrew/core should not use `option`." def audit_formula(_node, _class_node, _parent_class_node, body_node) option_call_nodes = find_every_method_call_by_name(body_node, :option)
true
Other
Homebrew
brew
779304df68a5b49387a86bc3a12fc05a3201678b.json
audit: add "homebrew/core" for relevant checks
Library/Homebrew/rubocops/text.rb
@@ -17,7 +17,7 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node) end if formula_tap == "homebrew-core" && (depends_on?("veclibfort") || depends_on?("lapack")) - problem "Formulae should use OpenBLAS as the default serial linear algebra library." + problem "Formulae in homebrew/core should use OpenBLAS as the default serial linear algebra library." end if method_called_ever?(body_node, :virtualenv_create) ||
true
Other
Homebrew
brew
779304df68a5b49387a86bc3a12fc05a3201678b.json
audit: add "homebrew/core" for relevant checks
Library/Homebrew/rubocops/urls.rb
@@ -234,8 +234,8 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node) next if BINARY_FORMULA_URLS_WHITELIST.include?(@formula_name) next if BINARY_URLS_WHITELIST.include?(url) - problem "#{url} looks like a binary package, not a source archive. " \ - "Homebrew/homebrew-core is source-only." + problem "#{url} looks like a binary package, not a source archive; " \ + "homebrew/core is source-only." end end end
true
Other
Homebrew
brew
779304df68a5b49387a86bc3a12fc05a3201678b.json
audit: add "homebrew/core" for relevant checks
Library/Homebrew/test/dev-cmd/audit_spec.rb
@@ -569,7 +569,7 @@ class FooAT11 < Formula fa.audit_versioned_keg_only expect(fa.problems.first) - .to match("Versioned formulae should use `keg_only :versioned_formula`") + .to match("Versioned formulae in homebrew/core should use `keg_only :versioned_formula`") end specify "it warns when a versioned formula has an incorrect `keg_only` reason" do @@ -584,7 +584,7 @@ class FooAT11 < Formula fa.audit_versioned_keg_only expect(fa.problems.first) - .to match("Versioned formulae should use `keg_only :versioned_formula`") + .to match("Versioned formulae in homebrew/core should use `keg_only :versioned_formula`") end specify "it does not warn when a versioned formula has `keg_only :versioned_formula`" do
true
Other
Homebrew
brew
779304df68a5b49387a86bc3a12fc05a3201678b.json
audit: add "homebrew/core" for relevant checks
Library/Homebrew/test/rubocops/lines_spec.rb
@@ -289,7 +289,7 @@ class Foo < Formula desc "foo" url 'https://brew.sh/foo-1.0.tgz' depends_on "mpich" - ^^^^^^^^^^^^^^^^^^ Use 'depends_on "open-mpi"' instead of 'depends_on "mpich"'. + ^^^^^^^^^^^^^^^^^^ Formulae in homebrew/core should use 'depends_on "open-mpi"' instead of 'depends_on "mpich"'. end RUBY @@ -353,7 +353,7 @@ class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' bottle do if OS.linux? - ^^^^^^^^^ Don\'t use OS.linux?; Homebrew/core only supports macOS + ^^^^^^^^^ Don\'t use OS.linux?; homebrew/core only supports macOS nil end sha256 "fe0679b932dd43a87fd415b609a7fbac7a069d117642ae8ebaac46ae1fb9f0b3" => :sierra
true
Other
Homebrew
brew
779304df68a5b49387a86bc3a12fc05a3201678b.json
audit: add "homebrew/core" for relevant checks
Library/Homebrew/test/rubocops/options_spec.rb
@@ -52,7 +52,7 @@ class Foo < Formula class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' deprecated_option "examples" => "with-examples" - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Formulae should not use `deprecated_option` + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Formulae in homebrew/core should not use `deprecated_option`. end RUBY end @@ -62,7 +62,7 @@ class Foo < Formula class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' option "with-examples" - ^^^^^^^^^^^^^^^^^^^^^^ Formulae should not have an `option` + ^^^^^^^^^^^^^^^^^^^^^^ Formulae in homebrew/core should not use `option`. end RUBY end
true
Other
Homebrew
brew
779304df68a5b49387a86bc3a12fc05a3201678b.json
audit: add "homebrew/core" for relevant checks
Library/Homebrew/test/rubocops/text_spec.rb
@@ -38,7 +38,7 @@ class Foo < Formula url "https://brew.sh/foo-1.0.tgz" homepage "https://brew.sh" depends_on "veclibfort" - ^^^^^^^^^^^^^^^^^^^^^^^ Formulae should use OpenBLAS as the default serial linear algebra library. + ^^^^^^^^^^^^^^^^^^^^^^^ Formulae in homebrew/core should use OpenBLAS as the default serial linear algebra library. end RUBY end @@ -49,7 +49,7 @@ class Foo < Formula url "https://brew.sh/foo-1.0.tgz" homepage "https://brew.sh" depends_on "lapack" - ^^^^^^^^^^^^^^^^^^^ Formulae should use OpenBLAS as the default serial linear algebra library. + ^^^^^^^^^^^^^^^^^^^ Formulae in homebrew/core should use OpenBLAS as the default serial linear algebra library. end RUBY end
true
Other
Homebrew
brew
779304df68a5b49387a86bc3a12fc05a3201678b.json
audit: add "homebrew/core" for relevant checks
Library/Homebrew/test/rubocops/urls_spec.rb
@@ -145,13 +145,13 @@ }, { "url" => "https://brew.sh/example-darwin.x86_64.tar.gz", "msg" => "https://brew.sh/example-darwin.x86_64.tar.gz looks like a binary package, " \ - "not a source archive. Homebrew/homebrew-core is source-only.", + "not a source archive; homebrew/core is source-only.", "col" => 2, "formula_tap" => "homebrew-core", }, { "url" => "https://brew.sh/example-darwin.amd64.tar.gz", "msg" => "https://brew.sh/example-darwin.amd64.tar.gz looks like a binary package, " \ - "not a source archive. Homebrew/homebrew-core is source-only.", + "not a source archive; homebrew/core is source-only.", "col" => 2, "formula_tap" => "homebrew-core", }]
true
Other
Homebrew
brew
4efc1276b3d6594338b34bc53701f74b9d4214b7.json
dev-cmd/audit: make git audit only --new-formula only. Useful in e.g. https://github.com/Homebrew/homebrew-core/pull/46550 to avoid repeatedly triggering a failing audit.
Library/Homebrew/dev-cmd/audit.rb
@@ -407,7 +407,7 @@ def audit_deps problem "Dependency #{dep} does not define option #{opt.name.inspect}" end - problem "Don't use git as a dependency (it's always available)" if dep.name == "git" + problem "Don't use git as a dependency (it's always available)" if @new_formula && dep.name == "git" problem "Dependency '#{dep.name}' is marked as :run. Remove :run; it is a no-op." if dep.tags.include?(:run)
false
Other
Homebrew
brew
03028d57cec069ff9f783245ef814ec1b7ca268e.json
Dockerfile: install tzdata apt package
Dockerfile
@@ -20,6 +20,7 @@ RUN apt-get update \ patch \ sudo \ uuid-runtime \ + tzdata \ && rm -rf /var/lib/apt/lists/* RUN localedef -i en_US -f UTF-8 en_US.UTF-8 \
false
Other
Homebrew
brew
674259d691ef2380595539d0387030892e215917.json
extend/ARGV: remove unused HOMEBREW_BUILD_BOTTLE.
Library/Homebrew/extend/ARGV.rb
@@ -98,7 +98,7 @@ def build_universal? end def build_bottle? - include?("--build-bottle") || !ENV["HOMEBREW_BUILD_BOTTLE"].nil? + include?("--build-bottle") end def bottle_arch
false
Other
Homebrew
brew
c92a3d3f84ff9dc1a2c566e9d5fd5a21cf2e3bee.json
virtualenv_install_with_resources: add python@3.8 handling
Library/Homebrew/language/python.rb
@@ -153,7 +153,8 @@ def needs_python?(python) def virtualenv_install_with_resources(options = {}) python = options[:using] if python.nil? - wanted = %w[python python@2 python2 python3 python@3 pypy pypy3].select { |py| needs_python?(py) } + pythons = %w[python python@2 python2 python3 python@3 python@3.8 pypy pypy3] + wanted = pythons.select { |py| needs_python?(py) } raise FormulaAmbiguousPythonError, self if wanted.size > 1 python = wanted.first || "python2.7"
false
Other
Homebrew
brew
4e3a846439da12c0327df8ba57cb0c71f9123137.json
Add vale linting as a CI step - So that people know when the docs they've written violate our style guides.
.github/workflows/tests.yml
@@ -130,6 +130,12 @@ jobs: export PATH="/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin" brew readall --aliases + - name: Run vale for docs linting + run: | + export PATH="/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin" + brew install vale + vale $(brew --repo)/docs/ + - name: Build Docker image run: | docker pull homebrew/brew
false
Other
Homebrew
brew
3771a607204f3670155bbb29c2ccd497110f4797.json
docs: Fix typo in Homebrew/linuxbrew-core repo name
docs/Homebrew-linuxbrew-core-Maintainer-Guide.md
@@ -1,4 +1,4 @@ -# Homebrew linuxbrew-core Maintainer Guide +# Homebrew/linuxbrew-core Maintainer Guide ## Merging formulae updates from Homebrew/homebrew-core
false
Other
Homebrew
brew
6a200cb88adaf5dc3850569b7121f79956bfc1fd.json
docs: Fix double-spacing after full stop issues
docs/Formula-Cookbook.md
@@ -732,9 +732,9 @@ Homebrew provides two formula DSL methods for launchd plist files: Homebrew has multiple levels of environment variable filtering which affects variables available to formulae. -Firstly, the overall environment in which Homebrew runs is filtered to avoid environment contamination breaking from-source builds (<https://github.com/Homebrew/brew/issues/932>). In particular, this process filters all but the given whitelisted variables, but allows environment variables prefixed with `HOMEBREW_`. The specific implementation can be seen in [`bin/brew`](https://github.com/Homebrew/brew/blob/master/bin/brew). +Firstly, the overall environment in which Homebrew runs is filtered to avoid environment contamination breaking from-source builds (<https://github.com/Homebrew/brew/issues/932>). In particular, this process filters all but the given whitelisted variables, but allows environment variables prefixed with `HOMEBREW_`. The specific implementation can be seen in [`bin/brew`](https://github.com/Homebrew/brew/blob/master/bin/brew). -The second level of filtering removes sensitive environment variables (such as credentials like keys, passwords or tokens) to avoid malicious subprocesses obtaining them (<https://github.com/Homebrew/brew/pull/2524>). This has the effect of preventing any such variables from reaching a formula's Ruby code as they are filtered before it is called. The specific implementation can be seen in the [`ENV.clear_sensitive_environment!` method](https://github.com/Homebrew/brew/blob/master/Library/Homebrew/extend/ENV.rb). +The second level of filtering removes sensitive environment variables (such as credentials like keys, passwords or tokens) to avoid malicious subprocesses obtaining them (<https://github.com/Homebrew/brew/pull/2524>). This has the effect of preventing any such variables from reaching a formula's Ruby code as they are filtered before it is called. The specific implementation can be seen in the [`ENV.clear_sensitive_environment!` method](https://github.com/Homebrew/brew/blob/master/Library/Homebrew/extend/ENV.rb). In summary, environment variables used by a formula need to conform to these filtering rules in order to be available.
false
Other
Homebrew
brew
de622a2a2135308f588dec49221324182c02c455.json
Exclude .vale.ini from .gitignore - Without this, vale won't correctly detect where the styles are.
.gitignore
@@ -154,6 +154,7 @@ !/.editorconfig !/.gitignore !/.yardopts +!/.vale.ini !/CHANGELOG.md !/CONTRIBUTING.md !/Dockerfile
true
Other
Homebrew
brew
de622a2a2135308f588dec49221324182c02c455.json
Exclude .vale.ini from .gitignore - Without this, vale won't correctly detect where the styles are.
.vale.ini
@@ -0,0 +1,4 @@ +StylesPath = ./docs/vale-styles + +[*.md] +BasedOnStyles = Homebrew
true
Other
Homebrew
brew
2a5344868533856f94e015cfde1ab7497728baa0.json
Add Vale linting for our docs - I noticed that another open source project had taken the Homebrew style guide and made it into [Vale linting rules](https://github.com/testthedocs/vale-styles/tree/master/Homebrew). This copies them into here, so that we can make use of them. Thanks! - What use is a style guide if our own docs don't at least try to adhere to it? This aims to make the rules more visible to all contributors. - In order for these to do anything, you'll have to `brew install vale` and run `vale` in the root of this repo. It will look for Markdown files. - A next step would be adding this as a pre-commit hook, or... - The GitHub Action would have been really good, but [it doesn't support forks](https://github.com/errata-ai/vale-action#limitations).
docs/_config.yml
@@ -7,6 +7,7 @@ exclude: - bin - CNAME - Gemfile* + - vale-styles - vendor plugins:
true
Other
Homebrew
brew
2a5344868533856f94e015cfde1ab7497728baa0.json
Add Vale linting for our docs - I noticed that another open source project had taken the Homebrew style guide and made it into [Vale linting rules](https://github.com/testthedocs/vale-styles/tree/master/Homebrew). This copies them into here, so that we can make use of them. Thanks! - What use is a style guide if our own docs don't at least try to adhere to it? This aims to make the rules more visible to all contributors. - In order for these to do anything, you'll have to `brew install vale` and run `vale` in the root of this repo. It will look for Markdown files. - A next step would be adding this as a pre-commit hook, or... - The GitHub Action would have been really good, but [it doesn't support forks](https://github.com/errata-ai/vale-action#limitations).
docs/vale-styles/Homebrew/Abbreviations.yml
@@ -0,0 +1,12 @@ +--- +extends: substitution +message: Use '%s' +ignorecase: false +link: 'https://github.com/Homebrew/brew/blob/master/docs/Prose-Style-Guidelines.md#style-and-usage' +level: error +nonword: true +swap: + '\beg\b': e.g. + '\bie\b': i.e. + 'e\.g\.,': e.g. + 'i\.e\.,': i.e.
true
Other
Homebrew
brew
2a5344868533856f94e015cfde1ab7497728baa0.json
Add Vale linting for our docs - I noticed that another open source project had taken the Homebrew style guide and made it into [Vale linting rules](https://github.com/testthedocs/vale-styles/tree/master/Homebrew). This copies them into here, so that we can make use of them. Thanks! - What use is a style guide if our own docs don't at least try to adhere to it? This aims to make the rules more visible to all contributors. - In order for these to do anything, you'll have to `brew install vale` and run `vale` in the root of this repo. It will look for Markdown files. - A next step would be adding this as a pre-commit hook, or... - The GitHub Action would have been really good, but [it doesn't support forks](https://github.com/errata-ai/vale-action#limitations).
docs/vale-styles/Homebrew/OxfordComma.yml
@@ -0,0 +1,8 @@ +--- +extends: existence +message: 'No Oxford commas!' +link: 'https://github.com/Homebrew/brew/blob/master/docs/Prose-Style-Guidelines.md#typographical-conventions' +scope: sentence +level: warning +tokens: + - '(?:[^,]+,){1,}\s\w+,\sand'
true
Other
Homebrew
brew
2a5344868533856f94e015cfde1ab7497728baa0.json
Add Vale linting for our docs - I noticed that another open source project had taken the Homebrew style guide and made it into [Vale linting rules](https://github.com/testthedocs/vale-styles/tree/master/Homebrew). This copies them into here, so that we can make use of them. Thanks! - What use is a style guide if our own docs don't at least try to adhere to it? This aims to make the rules more visible to all contributors. - In order for these to do anything, you'll have to `brew install vale` and run `vale` in the root of this repo. It will look for Markdown files. - A next step would be adding this as a pre-commit hook, or... - The GitHub Action would have been really good, but [it doesn't support forks](https://github.com/errata-ai/vale-action#limitations).
docs/vale-styles/Homebrew/Pronouns.yml
@@ -0,0 +1,15 @@ +--- +extends: existence +message: Avoid gender-specific language when not necessary. +link: 'https://github.com/Homebrew/brew/blob/master/docs/Prose-Style-Guidelines.md#personal-pronouns' +level: warning +ignorecase: true +tokens: + - him + - her + - she + - he + - his + - hers + - himself + - herself
true
Other
Homebrew
brew
2a5344868533856f94e015cfde1ab7497728baa0.json
Add Vale linting for our docs - I noticed that another open source project had taken the Homebrew style guide and made it into [Vale linting rules](https://github.com/testthedocs/vale-styles/tree/master/Homebrew). This copies them into here, so that we can make use of them. Thanks! - What use is a style guide if our own docs don't at least try to adhere to it? This aims to make the rules more visible to all contributors. - In order for these to do anything, you'll have to `brew install vale` and run `vale` in the root of this repo. It will look for Markdown files. - A next step would be adding this as a pre-commit hook, or... - The GitHub Action would have been really good, but [it doesn't support forks](https://github.com/errata-ai/vale-action#limitations).
docs/vale-styles/Homebrew/README.md
@@ -0,0 +1 @@ +Based on Homebrew's [Prose Style Guidelines](http://docs.brew.sh/Prose-Style-Guidelines.html).
true
Other
Homebrew
brew
2a5344868533856f94e015cfde1ab7497728baa0.json
Add Vale linting for our docs - I noticed that another open source project had taken the Homebrew style guide and made it into [Vale linting rules](https://github.com/testthedocs/vale-styles/tree/master/Homebrew). This copies them into here, so that we can make use of them. Thanks! - What use is a style guide if our own docs don't at least try to adhere to it? This aims to make the rules more visible to all contributors. - In order for these to do anything, you'll have to `brew install vale` and run `vale` in the root of this repo. It will look for Markdown files. - A next step would be adding this as a pre-commit hook, or... - The GitHub Action would have been really good, but [it doesn't support forks](https://github.com/errata-ai/vale-action#limitations).
docs/vale-styles/Homebrew/Spacing.yml
@@ -0,0 +1,9 @@ +--- +extends: existence +message: "'%s' should have one space." +link: 'https://github.com/Homebrew/brew/blob/master/docs/Prose-Style-Guidelines.md#typographical-conventions' +level: error +nonword: true +tokens: + - '[a-z][.?!][A-Z]' + - '[.?!] {2,}[A-Z]'
true
Other
Homebrew
brew
2a5344868533856f94e015cfde1ab7497728baa0.json
Add Vale linting for our docs - I noticed that another open source project had taken the Homebrew style guide and made it into [Vale linting rules](https://github.com/testthedocs/vale-styles/tree/master/Homebrew). This copies them into here, so that we can make use of them. Thanks! - What use is a style guide if our own docs don't at least try to adhere to it? This aims to make the rules more visible to all contributors. - In order for these to do anything, you'll have to `brew install vale` and run `vale` in the root of this repo. It will look for Markdown files. - A next step would be adding this as a pre-commit hook, or... - The GitHub Action would have been really good, but [it doesn't support forks](https://github.com/errata-ai/vale-action#limitations).
docs/vale-styles/Homebrew/Terms.yml
@@ -0,0 +1,9 @@ +--- +extends: substitution +message: Use '%s' instead of '%s'. +link: 'https://github.com/Homebrew/brew/blob/master/docs/Prose-Style-Guidelines.md#terminology-words-and-word-styling' +level: error +swap: + Pull Request: pull request + repo: repository + Rubocop: RuboCop
true
Other
Homebrew
brew
2a5344868533856f94e015cfde1ab7497728baa0.json
Add Vale linting for our docs - I noticed that another open source project had taken the Homebrew style guide and made it into [Vale linting rules](https://github.com/testthedocs/vale-styles/tree/master/Homebrew). This copies them into here, so that we can make use of them. Thanks! - What use is a style guide if our own docs don't at least try to adhere to it? This aims to make the rules more visible to all contributors. - In order for these to do anything, you'll have to `brew install vale` and run `vale` in the root of this repo. It will look for Markdown files. - A next step would be adding this as a pre-commit hook, or... - The GitHub Action would have been really good, but [it doesn't support forks](https://github.com/errata-ai/vale-action#limitations).
docs/vale-styles/Homebrew/Titles.yml
@@ -0,0 +1,6 @@ +--- +extends: capitalization +message: "'%s' should be in sentence case" +level: warning +scope: heading +match: $sentence
true
Other
Homebrew
brew
2a5344868533856f94e015cfde1ab7497728baa0.json
Add Vale linting for our docs - I noticed that another open source project had taken the Homebrew style guide and made it into [Vale linting rules](https://github.com/testthedocs/vale-styles/tree/master/Homebrew). This copies them into here, so that we can make use of them. Thanks! - What use is a style guide if our own docs don't at least try to adhere to it? This aims to make the rules more visible to all contributors. - In order for these to do anything, you'll have to `brew install vale` and run `vale` in the root of this repo. It will look for Markdown files. - A next step would be adding this as a pre-commit hook, or... - The GitHub Action would have been really good, but [it doesn't support forks](https://github.com/errata-ai/vale-action#limitations).
docs/vale-styles/Homebrew/Trademarks.yml
@@ -0,0 +1,12 @@ +--- +extends: existence +message: 'No "TM", ™, SM, ©, ®, or other explicit indicators of rights ownership or trademarks' +link: 'https://github.com/Homebrew/brew/blob/master/docs/Prose-Style-Guidelines.md#typographical-conventions' +level: error +nonword: true +tokens: + - \bTM\b + - ™ + - \bSM\b + - © + - ®
true
Other
Homebrew
brew
90e830c19e1b37215b19af10c7d131f4c209c10d.json
cmd: add raises for invalid input
Library/Homebrew/cmd/info.rb
@@ -78,9 +78,12 @@ def info if args.json raise UsageError, "Invalid JSON version: #{args.json}" unless ["v1", true].include? args.json + raise UsageError, "This command's option requires a formula argument" if ARGV.named.empty? print_json elsif args.github? + raise UsageError, "This command's option requires a formula argument" if ARGV.named.empty? + exec_browser(*Homebrew.args.formulae.map { |f| github_info(f) }) else print_info
true
Other
Homebrew
brew
90e830c19e1b37215b19af10c7d131f4c209c10d.json
cmd: add raises for invalid input
Library/Homebrew/cmd/postinstall.rb
@@ -23,6 +23,8 @@ def postinstall_args def postinstall postinstall_args.parse + raise KegUnspecifiedError if args.remaining.empty? + ARGV.resolved_formulae.each do |f| ohai "Postinstalling #{f}" fi = FormulaInstaller.new(f)
true
Other
Homebrew
brew
90e830c19e1b37215b19af10c7d131f4c209c10d.json
cmd: add raises for invalid input
Library/Homebrew/cmd/reinstall.rb
@@ -47,6 +47,8 @@ def reinstall_args def reinstall reinstall_args.parse + raise FormulaUnspecifiedError if args.remaining.empty? + FormulaInstaller.prevent_build_flags unless DevelopmentTools.installed? Install.perform_preinstall_checks
true
Other
Homebrew
brew
90e830c19e1b37215b19af10c7d131f4c209c10d.json
cmd: add raises for invalid input
Library/Homebrew/cmd/switch.rb
@@ -14,46 +14,32 @@ def switch_args Symlink all of the specified <version> of <formula>'s installation into Homebrew's prefix. EOS - switch_option :verbose - switch_option :debug + switch :verbose + switch :debug end end def switch switch_args.parse - name = args.remaining.first - - usage = "Usage: brew switch <formula> <version>" - unless name - onoe usage - exit 1 - end + raise FormulaUnspecifiedError if args.remaining.empty? + name = args.remaining.first rack = Formulary.to_rack(name) - unless rack.directory? - onoe "#{name} not found in the Cellar." - exit 2 - end + odie "#{name} not found in the Cellar." unless rack.directory? versions = rack.subdirs .map { |d| Keg.new(d).version } .sort .join(", ") version = args.remaining.second + raise UsageError, "Specify one of #{name}'s installed versions: #{versions}" unless version - if !version || args.remaining.length > 2 - onoe usage - puts "#{name} installed versions: #{versions}" - exit 1 - end - - unless (rack/version).directory? - onoe "#{name} does not have a version \"#{version}\" in the Cellar." - puts "#{name} installed versions: #{versions}" - exit 3 - end + odie <<~EOS unless (rack/version).directory? + #{name} does not have a version \"#{version}\" in the Cellar. + #{name}'s installed versions: #{versions} + EOS # Unlink all existing versions rack.subdirs.each do |v|
true
Other
Homebrew
brew
90e830c19e1b37215b19af10c7d131f4c209c10d.json
cmd: add raises for invalid input
Library/Homebrew/dev-cmd/bottle.rb
@@ -86,6 +86,7 @@ def bottle bottle_args.parse return merge if args.merge? + raise KegUnspecifiedError if args.remaining.empty? ensure_relocation_formulae_installed! unless args.skip_relocation? ARGV.resolved_formulae.each do |f| @@ -426,6 +427,7 @@ def bottle_formula(f) def merge write = args.write? + raise UsageError, "--merge requires a JSON file path argument" if ARGV.named.empty? bottles_hash = ARGV.named.reduce({}) do |hash, json_file| hash.deep_merge(JSON.parse(IO.read(json_file)))
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/cmd/analytics.rb
@@ -42,7 +42,7 @@ def analytics when "regenerate-uuid" Utils::Analytics.regenerate_uuid! else - raise UsageError + raise UsageError, "Unknown subcommand." end end end
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/cmd/command.rb
@@ -20,12 +20,11 @@ def command_args def command command_args.parse - abort "This command requires a command argument" if args.remaining.empty? - cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(args.remaining.first, args.remaining.first) + raise UsageError, "This command requires a command argument" if args.remaining.empty? + cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(args.remaining.first, args.remaining.first) path = Commands.path(cmd) - cmd_paths = PATH.new(ENV["PATH"]).append(Tap.cmd_directories) unless path path ||= which("brew-#{cmd}", cmd_paths) path ||= which("brew-#{cmd}.rb", cmd_paths)
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/cmd/diy.rb
@@ -47,7 +47,6 @@ def diy def detect_version(path) version = path.version.to_s - raise "Couldn't determine version, set it with --version=<version>" if version.empty? version
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/cmd/info.rb
@@ -61,22 +61,23 @@ def info_args def info info_args.parse + if args.days.present? - raise UsageError, "days must be one of #{VALID_DAYS.join(", ")}" unless VALID_DAYS.include?(args.days) + raise UsageError, "--days must be one of #{VALID_DAYS.join(", ")}" unless VALID_DAYS.include?(args.days) end if args.category.present? if ARGV.named.present? && !VALID_FORMULA_CATEGORIES.include?(args.category) - raise UsageError, "category must be one of #{VALID_FORMULA_CATEGORIES.join(", ")} when querying formulae" + raise UsageError, "--category must be one of #{VALID_FORMULA_CATEGORIES.join(", ")} when querying formulae" end unless VALID_CATEGORIES.include?(args.category) - raise UsageError, "category must be one of #{VALID_CATEGORIES.join(", ")}" + raise UsageError, "--category must be one of #{VALID_CATEGORIES.join(", ")}" end end if args.json - raise UsageError, "invalid JSON version: #{args.json}" unless ["v1", true].include? args.json + raise UsageError, "Invalid JSON version: #{args.json}" unless ["v1", true].include? args.json print_json elsif args.github?
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/cmd/install.rb
@@ -101,6 +101,7 @@ def install end install_args.parse + raise FormulaUnspecifiedError if args.remaining.empty? if args.ignore_dependencies?
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/cmd/link.rb
@@ -48,7 +48,10 @@ def link else keg.name end - puts "To relink: brew unlink #{keg.name} && brew link #{name_and_flag}" + puts <<~EOS + To relink: + brew unlink #{keg.name} && brew link #{name_and_flag} + EOS next end
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/cmd/missing.rb
@@ -27,6 +27,7 @@ def missing_args def missing missing_args.parse + return unless HOMEBREW_CELLAR.exist? ff = if ARGV.named.empty?
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/cmd/outdated.rb
@@ -41,7 +41,7 @@ def outdated ARGV.resolved_formulae end if args.json - raise UsageError, "invalid JSON version: #{args.json}" unless ["v1", true].include? args.json + raise UsageError, "Invalid JSON version: #{args.json}" unless ["v1", true].include? args.json outdated = print_outdated_json(formulae) else
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/cmd/sh.rb
@@ -27,6 +27,7 @@ def sh_args def sh sh_args.parse + ENV.activate_extensions! if superenv?
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/cmd/tap-info.rb
@@ -36,7 +36,7 @@ def tap_info end if args.json - raise UsageError, "invalid JSON version: #{args.json}" unless ["v1", true].include? args.json + raise UsageError, "Invalid JSON version: #{args.json}" unless ["v1", true].include? args.json print_tap_json(taps.sort_by(&:to_s)) else
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/cmd/uninstall.rb
@@ -79,15 +79,15 @@ def uninstall if rack.directory? versions = rack.subdirs.map(&:basename) puts "#{keg.name} #{versions.to_sentence} #{"is".pluralize(versions.count)} still installed." - puts "Remove all versions with `brew uninstall --force #{keg.name}`." + puts "Run `brew uninstall --force #{keg.name}` to remove all versions." end end end end end rescue MultipleVersionsInstalledError => e ofail e - puts "Use `brew uninstall --force #{e.name}` to remove all versions." + puts "Run `brew uninstall --force #{e.name}` to remove all versions." ensure # If we delete Cellar/newname, then Cellar/oldname symlink # can become broken and we have to remove it.
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/cmd/untap.rb
@@ -19,11 +19,11 @@ def untap_args def untap untap_args.parse - raise "Usage is `brew untap <tap-name>`" if args.remaining.empty? + raise UsageError, "This command requires a tap argument from `brew tap`'s list" if args.remaining.empty? ARGV.named.each do |tapname| tap = Tap.fetch(tapname) - raise "untapping #{tap} is not allowed" if tap.core_tap? + odie "Untapping #{tap} is not allowed" if tap.core_tap? tap.uninstall end
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/cmd/update.sh
@@ -314,7 +314,7 @@ homebrew-update() { *) odie <<EOS This command updates brew itself, and does not take formula names. -Use 'brew upgrade $@' instead. +Use \`brew upgrade $@\` instead. EOS ;; esac @@ -511,7 +511,7 @@ EOS if [[ "$UPSTREAM_SHA_HTTP_CODE" = "404" ]] then TAP="${DIR#$HOMEBREW_LIBRARY/Taps/}" - echo "$TAP does not exist! Run 'brew untap $TAP'" >>"$update_failed_file" + echo "$TAP does not exist! Run \`brew untap $TAP\` to remove it." >>"$update_failed_file" else echo "Fetching $DIR failed!" >>"$update_failed_file" fi
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/dev-cmd/bottle.rb
@@ -219,7 +219,7 @@ def bottle_formula(f) return end - return ofail "Formula not installed with '--build-bottle': #{f.full_name}" unless Utils::Bottles.built_as? f + return ofail "Formula was not installed with --build-bottle: #{f.full_name}" unless Utils::Bottles.built_as? f return ofail "Formula has no stable version: #{f.full_name}" unless f.stable
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/dev-cmd/bump-formula-pr.rb
@@ -504,6 +504,6 @@ def run_audit(formula, alias_rename, backup_file) formula.path.atomic_write(backup_file) FileUtils.mv alias_rename.last, alias_rename.first if alias_rename.present? - odie "brew audit failed!" + odie "`brew audit` failed!" end end
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/dev-cmd/extract.rb
@@ -98,7 +98,7 @@ def extract extract_args.parse # Expect exactly two named arguments: formula and tap - raise UsageError if args.remaining.length != 2 + raise UsageError, "This command requires formula and tap arguments" if args.remaining.length != 2 if args.remaining.first !~ HOMEBREW_TAP_FORMULA_REGEX name = args.remaining.first.downcase
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/dev-cmd/mirror.rb
@@ -21,7 +21,7 @@ def mirror_args def mirror mirror_args.parse - odie "This command requires at least one formula argument!" if ARGV.named.empty? + raise FormulaUnspecifiedError if args.remaining.empty? bintray_user = ENV["HOMEBREW_BINTRAY_USER"] bintray_key = ENV["HOMEBREW_BINTRAY_KEY"]
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/dev-cmd/pull.rb
@@ -70,7 +70,9 @@ def pull pull_args.parse - odie "This command requires at least one argument containing a URL or pull request number" if ARGV.named.empty? + if ARGV.named.empty? + raise UsageError, "This command requires at least one argument containing a URL or pull request number" + end # Passthrough Git environment variables for e.g. git am ENV["GIT_COMMITTER_NAME"] = ENV["HOMEBREW_GIT_NAME"] if ENV["HOMEBREW_GIT_NAME"] @@ -107,7 +109,7 @@ def pull end _, testing_job = *testing_match url = "https://github.com/Homebrew/homebrew-#{tap.repo}/compare/master...BrewTestBot:testing-#{testing_job}" - odie "Testing URLs require `--bottle`!" unless args.bottle? + odie "--bottle is required for testing job URLs!" unless args.bottle? elsif (api_match = arg.match HOMEBREW_PULL_API_REGEX) _, user, repo, issue = *api_match url = "https://github.com/#{user}/#{repo}/pull/#{issue}" @@ -277,7 +279,7 @@ def check_bumps(patch_changes) elsif patch_changes[:formulae].length > 1 odie "Can only bump one changed formula; bumped #{patch_changes[:formulae]}" elsif !patch_changes[:others].empty? - odie "Can not bump if non-formula files are changed" + odie "Cannot bump if non-formula files are changed" end end
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/dev-cmd/tap-new.rb
@@ -21,7 +21,7 @@ def tap_new_args def tap_new tap_new_args.parse - raise "A tap argument is required" if ARGV.named.empty? + raise UsageError, "This command requires a tap argument" if ARGV.named.empty? tap = Tap.fetch(ARGV.named.first) titleized_user = tap.user.dup
true
Other
Homebrew
brew
2f7c3afeb8b6cb76b35860ac195e3b35d18132f6.json
cmd: improve wording of messages, spacing
Library/Homebrew/dev-cmd/update-test.rb
@@ -88,7 +88,7 @@ def update_test chdir "update-test" do curdir = Pathname.new(Dir.pwd) - oh1 "Setup test environment..." + oh1 "Preparing test environment..." # copy Homebrew installation safe_system "git", "clone", "#{HOMEBREW_REPOSITORY}/.git", ".", "--branch", "master", "--single-branch"
true
Other
Homebrew
brew
f0270a585cc37e5b84d70404bf434c6f69c7672d.json
desc/audit: remove messages obviated by new arg parser
Library/Homebrew/cmd/desc.rb
@@ -40,11 +40,7 @@ def desc search_type << :either if args.search search_type << :name if args.name search_type << :desc if args.description - if search_type.size > 1 - odie "Pick one, and only one, of -s/--search, -n/--name, or -d/--description." - elsif search_type.present? && ARGV.named.empty? - odie "You must provide a search term." - end + odie "You must provide a search term." if search_type.present? && ARGV.named.empty? results = if search_type.empty? raise FormulaUnspecifiedError if ARGV.named.empty?
true
Other
Homebrew
brew
f0270a585cc37e5b84d70404bf434c6f69c7672d.json
desc/audit: remove messages obviated by new arg parser
Library/Homebrew/dev-cmd/audit.rb
@@ -57,7 +57,8 @@ def audit_args switch :verbose switch :debug conflicts "--only", "--except" - conflicts "--only-cops", "--except-cops" + conflicts "--only-cops", "--except-cops", "--strict" + conflicts "--only-cops", "--except-cops", "--only" end end @@ -88,13 +89,6 @@ def audit only_cops = args.only_cops except_cops = args.except_cops - - if only_cops && except_cops - odie "--only-cops and --except-cops cannot be used simultaneously!" - elsif (only_cops || except_cops) && (strict || args.only) - odie "--only-cops/--except-cops and --strict/--only cannot be used simultaneously!" - end - options = { fix: args.fix? } if only_cops @@ -995,7 +989,6 @@ def problem_if_output(output) def audit only_audits = @only except_audits = @except - odie "--only and --except cannot be used simultaneously!" if only_audits && except_audits methods.map(&:to_s).grep(/^audit_/).each do |audit_method_name| name = audit_method_name.gsub(/^audit_/, "")
true
Other
Homebrew
brew
28e62b52d1be4cff4c9d668779b6e7d361656c2a.json
cli_args: Remove cyclic dependency on ARGV
Library/Homebrew/cli/args.rb
@@ -5,13 +5,14 @@ module Homebrew module CLI class Args < OpenStruct - attr_accessor :processed_options + attr_accessor :processed_options, :args_parsed # undefine tap to allow --tap argument undef tap def initialize(argv:) super @argv = argv + @args_parsed = false @processed_options = [] end @@ -132,7 +133,12 @@ def kegs def downcased_unique_named # Only lowercase names, not paths, bottle filenames or URLs - remaining.map do |arg| + arguments = if args_parsed + remaining + else + cmdline_args.reject { |arg| arg.start_with?("-") } + end + arguments.map do |arg| if arg.include?("/") || arg.end_with?(".tar.gz") || File.exist?(arg) arg else @@ -141,10 +147,18 @@ def downcased_unique_named end.uniq end + def head + (args_parsed && HEAD?) || cmdline_args.include?("--HEAD") + end + + def devel + (args_parsed && devel?) || cmdline_args.include?("--devel") + end + def spec(default = :stable) - if HEAD? + if head :head - elsif devel? + elsif devel :devel else default
true
Other
Homebrew
brew
28e62b52d1be4cff4c9d668779b6e7d361656c2a.json
cli_args: Remove cyclic dependency on ARGV
Library/Homebrew/cli/parser.rb
@@ -13,7 +13,7 @@ class Parser attr_reader :processed_options, :hide_from_man_page def self.parse(args = ARGV, &block) - new(&block).parse(args) + new(args, &block).parse(args) end def self.global_options @@ -25,10 +25,11 @@ def self.global_options } end - def initialize(&block) + def initialize(args = ARGV, &block) @parser = OptionParser.new @args = Homebrew::CLI::Args.new(argv: ARGV_WITHOUT_MONKEY_PATCHING) @args[:remaining] = [] + @args[:cmdline_args] = args.dup @constraints = [] @conflicts = [] @switch_sources = {} @@ -139,7 +140,7 @@ def parse(cmdline_args = ARGV) end check_constraint_violations @args[:remaining] = remaining_args - @args_parsed = true + @args.args_parsed = @args_parsed = true @args.processed_options = @processed_options Homebrew.args = @args cmdline_args.freeze
true
Other
Homebrew
brew
3f348286f9cffb1534a3e81382406f3632044d1a.json
cmd/leaves: handle missing formula. Use `runtime_formula_dependencies` which does this for us. Fixes #6827.
Library/Homebrew/cmd/leaves.rb
@@ -22,16 +22,8 @@ def leaves leaves_args.parse installed = Formula.installed.sort - - deps_of_installed = installed.flat_map do |f| - f.runtime_dependencies.map do |dep| - dep.to_formula.full_name - rescue FormulaUnavailableError - dep.name - end - end - - leaves = installed.map(&:full_name) - deps_of_installed + deps_of_installed = installed.flat_map(&:runtime_formula_dependencies) + leaves = installed.map(&:full_name) - deps_of_installed.map(&:full_name) leaves.each(&method(:puts)) end end
false
Other
Homebrew
brew
bdf493b67354327c67303883f96ae08788632af7.json
change export two constants timing
Library/Homebrew/brew.sh
@@ -251,8 +251,6 @@ export HOMEBREW_MACOS_VERSION_NUMERIC export HOMEBREW_USER_AGENT export HOMEBREW_USER_AGENT_CURL export HOMEBREW_BOTTLE_DEFAULT_DOMAIN -export HOMEBREW_BREW_REMOTE -export HOMEBREW_DEFAULT_CORE_REMOTE if [[ -n "$HOMEBREW_MACOS" && -x "/usr/bin/xcode-select" ]] then @@ -389,6 +387,9 @@ else HOMEBREW_DEFAULT_CORE_REMOTE="https://github.com/Homebrew/linuxbrew-core" fi +export HOMEBREW_BREW_REMOTE +export HOMEBREW_DEFAULT_CORE_REMOTE + if [[ -f "$HOMEBREW_LIBRARY/Homebrew/cmd/$HOMEBREW_COMMAND.sh" ]] then HOMEBREW_BASH_COMMAND="$HOMEBREW_LIBRARY/Homebrew/cmd/$HOMEBREW_COMMAND.sh"
false
Other
Homebrew
brew
497a160cda986510eefbbe324b15fe0d8f3c3942.json
cask version MAJOR_MINOR_PATCH_REGEX: allow any word character instead of only digits
Library/Homebrew/cask/dsl/version.rb
@@ -11,7 +11,7 @@ class Version < ::String DIVIDER_REGEX = /(#{DIVIDERS.keys.map { |v| Regexp.quote(v) }.join('|')})/.freeze - MAJOR_MINOR_PATCH_REGEX = /^(\d+)(?:\.(\d+)(?:\.(\d+))?)?/.freeze + MAJOR_MINOR_PATCH_REGEX = /^([^.,:]+)(?:\.([^.,:]+)(?:\.([^.,:]+))?)?/.freeze INVALID_CHARACTERS = /[^0-9a-zA-Z\.\,\:\-\_]/.freeze
true
Other
Homebrew
brew
497a160cda986510eefbbe324b15fe0d8f3c3942.json
cask version MAJOR_MINOR_PATCH_REGEX: allow any word character instead of only digits
Library/Homebrew/test/cask/dsl/version_spec.rb
@@ -85,50 +85,50 @@ describe "string manipulation helpers" do describe "#major" do include_examples "version expectations hash", :major, - "1" => "1", - "1.2" => "1", - "1.2.3" => "1", - "1.2.3_4-5" => "1" + "1" => "1", + "1.2" => "1", + "1.2.3" => "1", + "1.2.3-4,5:6" => "1" end describe "#minor" do include_examples "version expectations hash", :minor, - "1" => "", - "1.2" => "2", - "1.2.3" => "2", - "1.2.3_4-5" => "2" + "1" => "", + "1.2" => "2", + "1.2.3" => "2", + "1.2.3-4,5:6" => "2" end describe "#patch" do include_examples "version expectations hash", :patch, - "1" => "", - "1.2" => "", - "1.2.3" => "3", - "1.2.3_4-5" => "3" + "1" => "", + "1.2" => "", + "1.2.3" => "3", + "1.2.3-4,5:6" => "3-4" end describe "#major_minor" do include_examples "version expectations hash", :major_minor, - "1" => "1", - "1.2" => "1.2", - "1.2.3" => "1.2", - "1.2.3_4-5" => "1.2" + "1" => "1", + "1.2" => "1.2", + "1.2.3" => "1.2", + "1.2.3-4,5:6" => "1.2" end describe "#major_minor_patch" do include_examples "version expectations hash", :major_minor_patch, - "1" => "1", - "1.2" => "1.2", - "1.2.3" => "1.2.3", - "1.2.3_4-5" => "1.2.3" + "1" => "1", + "1.2" => "1.2", + "1.2.3" => "1.2.3", + "1.2.3-4,5:6" => "1.2.3-4" end describe "#minor_patch" do include_examples "version expectations hash", :minor_patch, - "1" => "", - "1.2" => "2", - "1.2.3" => "2.3", - "1.2.3_4-5" => "2.3" + "1" => "", + "1.2" => "2", + "1.2.3" => "2.3", + "1.2.3-4,5:6" => "2.3-4" end describe "#before_comma" do
true
Other
Homebrew
brew
a26390be05c5351d0b1cf75557a03c99aed5055f.json
Fix bug with printing pinned dependencies. Brew prints this error: ``` Error: undefined method `join' for nil:NilClass ``` because, in this code: ```ruby puts pinned_dependents.map do |f| "#{f.full_specified_name} #{f.pkg_version}" end.join(", ") ``` the block is passed to `puts` and not to `map`. `.join(",")` is called on the output of `puts`. (I think the regression was introduced in this commit: e12a7b0808353ea81d63774be1edaff81710d7a6)
Library/Homebrew/cmd/upgrade.rb
@@ -239,9 +239,9 @@ def check_dependents(formulae_to_install) if pinned_dependents.present? plural = "dependent".pluralize(pinned_dependents.count) ohai "Not upgrading #{pinned_dependents.count} pinned #{plural}:" - puts pinned_dependents.map do |f| + puts(pinned_dependents.map do |f| "#{f.full_specified_name} #{f.pkg_version}" - end.join(", ") + end.join(", ")) end # Print the upgradable dependents. @@ -292,9 +292,9 @@ def check_dependents(formulae_to_install) count = pinned_broken_dependents.count plural = "dependent".pluralize(pinned_broken_dependents.count) onoe "Not reinstalling #{count} broken and outdated, but pinned #{plural}:" - $stderr.puts pinned_broken_dependents.map do |f| + $stderr.puts(pinned_broken_dependents.map do |f| "#{f.full_specified_name} #{f.pkg_version}" - end.join(", ") + end.join(", ")) end # Print the broken dependents.
false
Other
Homebrew
brew
e6e0d1128c5a10d485852963fc6e1381aaa9baf0.json
create new envoronments
Library/Homebrew/brew.sh
@@ -251,6 +251,8 @@ export HOMEBREW_MACOS_VERSION_NUMERIC export HOMEBREW_USER_AGENT export HOMEBREW_USER_AGENT_CURL export HOMEBREW_BOTTLE_DEFAULT_DOMAIN +export HOMEBREW_BREW_REMOTE +export HOMEBREW_DEFAULT_CORE_REMOTE if [[ -n "$HOMEBREW_MACOS" && -x "/usr/bin/xcode-select" ]] then @@ -374,6 +376,19 @@ then export HOMEBREW_BOTTLE_DOMAIN="$HOMEBREW_BOTTLE_DEFAULT_DOMAIN" fi +HOMEBREW_DEFAULT_BREW_REMOTE="https://github.com/Homebrew/brew.git" +if [[ -z "$HOMEBREW_BREW_REMOTE" ]] +then + HOMEBREW_BREW_REMOTE="$HOMEBREW_DEFAULT_BREW_REMOTE" +fi + +if [[ -n "$HOMEBREW_MACOS" ]] || [[ -n "$HOMEBREW_FORCE_HOMEBREW_ON_LINUX" ]] +then + HOMEBREW_DEFAULT_CORE_REMOTE="https://github.com/Homebrew/homebrew-core" +else + HOMEBREW_DEFAULT_CORE_REMOTE="https://github.com/Homebrew/linuxbrew-core" +fi + if [[ -f "$HOMEBREW_LIBRARY/Homebrew/cmd/$HOMEBREW_COMMAND.sh" ]] then HOMEBREW_BASH_COMMAND="$HOMEBREW_LIBRARY/Homebrew/cmd/$HOMEBREW_COMMAND.sh"
true
Other
Homebrew
brew
e6e0d1128c5a10d485852963fc6e1381aaa9baf0.json
create new envoronments
Library/Homebrew/cmd/update.sh
@@ -23,22 +23,14 @@ git() { } git_init_if_necessary() { - BREW_OFFICIAL_REMOTE="https://github.com/Homebrew/brew" - if [[ -n "$HOMEBREW_MACOS" ]] || [[ -n "$HOMEBREW_FORCE_HOMEBREW_ON_LINUX" ]] - then - CORE_OFFICIAL_REMOTE="https://github.com/Homebrew/homebrew-core" - else - CORE_OFFICIAL_REMOTE="https://github.com/Homebrew/linuxbrew-core" - fi - safe_cd "$HOMEBREW_REPOSITORY" if [[ ! -d ".git" ]] then set -e trap '{ rm -rf .git; exit 1; }' EXIT git init git config --bool core.autocrlf false - git config remote.origin.url "$BREW_OFFICIAL_REMOTE" + git config remote.origin.url "$HOMEBREW_BREW_REMOTE" git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" latest_tag="$(git ls-remote --tags --refs -q origin | tail -n1 | cut -f2)" git fetch --force origin --shallow-since="$latest_tag" @@ -56,7 +48,7 @@ git_init_if_necessary() { trap '{ rm -rf .git; exit 1; }' EXIT git init git config --bool core.autocrlf false - git config remote.origin.url "$CORE_OFFICIAL_REMOTE" + git config remote.origin.url "$HOMEBREW_CORE_REMOTE" git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" git fetch --force --depth=1 origin refs/heads/master:refs/remotes/origin/master git reset --hard origin/master @@ -402,15 +394,33 @@ EOS git_init_if_necessary + if [[ "$HOMEBREW_DEFAULT_BREW_REMOTE" != "$HOMEBREW_BREW_REMOTE" ]] + then + safe_cd "$HOMEBREW_REPOSITORY" + git remote set-url origin "$HOMEBREW_BREW_REMOTE" + git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" + latest_tag="$(git ls-remote --tags --refs -q origin | tail -n1 | cut -f2)" + git fetch --force origin --shallow-since="$latest_tag" + fi + + if [[ "$HOMEBREW_DEFAULT_CORE_REMOTE" != "$HOMEBREW_CORE_REMOTE" ]] && + [[ -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] + then + safe_cd "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" + git remote set-url origin "$HOMEBREW_CORE_REMOTE" + git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" + git fetch --force --depth=1 origin refs/heads/master:refs/remotes/origin/master + fi + safe_cd "$HOMEBREW_REPOSITORY" # if an older system had a newer curl installed, change each repo's remote URL from GIT to HTTPS if [[ -n "$HOMEBREW_SYSTEM_CURL_TOO_OLD" && -x "$HOMEBREW_PREFIX/opt/curl/bin/curl" && "$(git config remote.origin.url)" =~ ^git:// ]] then - git config remote.origin.url "$BREW_OFFICIAL_REMOTE" - git config -f "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core/.git/config" remote.origin.url "$CORE_OFFICIAL_REMOTE" + git config remote.origin.url "$HOMEBREW_BREW_REMOTE" + git config -f "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core/.git/config" remote.origin.url "$HOMEBREW_CORE_REMOTE" fi # kill all of subprocess on interrupt
true
Other
Homebrew
brew
e6e0d1128c5a10d485852963fc6e1381aaa9baf0.json
create new envoronments
Library/Homebrew/diagnostic.rb
@@ -113,7 +113,7 @@ def examine_git_origin(repository_path, desired_origin) return if !Utils.git_available? || !repository_path.git? current_origin = repository_path.git_origin - + user_origins = [HOMEBREW_BREW_REMOTE, HOMEBREW_CORE_REMOTE] if current_origin.nil? <<~EOS Missing #{desired_origin} git origin remote. @@ -122,7 +122,8 @@ def examine_git_origin(repository_path, desired_origin) properly. You can solve this by adding the remote: git -C "#{repository_path}" remote add origin #{Formatter.url("https://github.com/#{desired_origin}.git")} EOS - elsif !current_origin.match?(%r{#{desired_origin}(\.git|/)?$}i) + elsif !current_origin.match?(%r{#{desired_origin}(\.git|/)?$}i) && \ + !user_origins.include?(current_origin) <<~EOS Suspicious #{desired_origin} git origin remote found. The current git origin is:
true
Other
Homebrew
brew
e6e0d1128c5a10d485852963fc6e1381aaa9baf0.json
create new envoronments
Library/Homebrew/global.rb
@@ -53,6 +53,9 @@ HOMEBREW_BOTTLE_DEFAULT_DOMAIN = ENV["HOMEBREW_BOTTLE_DEFAULT_DOMAIN"] HOMEBREW_BOTTLE_DOMAIN = ENV["HOMEBREW_BOTTLE_DOMAIN"] +HOMEBREW_BREW_REMOTE = ENV["HOMEBREW_BREW_REMOTE"] +HOMEBREW_CORE_REMOTE = ENV["HOMEBREW_CORE_REMOTE"] + HOMEBREW_DEFAULT_PREFIX = "/usr/local" LINUXBREW_DEFAULT_PREFIX = "/home/linuxbrew/.linuxbrew"
true
Other
Homebrew
brew
c1b00297e0556197a21155a44876e3422e8f4b1e.json
cask/cmd/style_spec: add rubocop test. This verifies the cask configuration hasn't been broken.
Library/Homebrew/test/cask/cmd/style_spec.rb
@@ -10,6 +10,36 @@ it_behaves_like "a command that handles invalid options" + describe ".rubocop" do + subject { described_class.rubocop(cask_path) } + + around do |example| + FileUtils.ln_s HOMEBREW_LIBRARY_PATH, HOMEBREW_LIBRARY/"Homebrew" + FileUtils.ln_s HOMEBREW_LIBRARY_PATH.parent/".rubocop_cask.yml", HOMEBREW_LIBRARY/".rubocop_cask.yml" + FileUtils.ln_s HOMEBREW_LIBRARY_PATH.parent/".rubocop_shared.yml", HOMEBREW_LIBRARY/".rubocop_shared.yml" + + example.run + ensure + FileUtils.rm_f HOMEBREW_LIBRARY/"Homebrew" + FileUtils.rm_f HOMEBREW_LIBRARY/".rubocop_cask.yml" + FileUtils.rm_f HOMEBREW_LIBRARY/".rubocop_shared.yml" + end + + before do + allow(Homebrew).to receive(:install_bundler_gems!) + end + + context "with a valid Cask" do + let(:cask_path) do + Pathname.new("#{HOMEBREW_LIBRARY}/Homebrew/test/support/fixtures/cask/Casks/version-latest.rb") + end + + it "returns true" do + expect(subject.success?).to be true + end + end + end + describe "#cask_paths" do subject { cli.cask_paths }
false
Other
Homebrew
brew
2101de77cf4e629c1cffcf9a3fc6dad2fc379259.json
.rubocop_cask: fix RuboCop names. Broken since a RuboCop update.
Library/.rubocop_cask.yml
@@ -26,10 +26,10 @@ Layout/HashAlignment: EnforcedHashRocketStyle: table EnforcedColonStyle: table -Layout/IndentFirstArrayElement: +Layout/FirstArrayElementIndentation: EnforcedStyle: align_brackets -Layout/IndentFirstHashElement: +Layout/FirstHashElementIndentation: EnforcedStyle: align_braces # Casks often contain long URLs and file paths.
false
Other
Homebrew
brew
9dc2997b9ab4157e70251b46a5d63d5a23d669bd.json
Add section for brew config & doctor output
.github/ISSUE_TEMPLATE/bug.md
@@ -36,3 +36,9 @@ about: "If you're sure it's reproducible and not just your machine: submit an is ## Step-by-step reproduction instructions (by running `brew` commands) <!-- replace me --> + +## Output of `brew config` and `brew doctor` commands + +<pre> +<!-- replace me --> +</pre>
false
Other
Homebrew
brew
90ec6bd500b676b7d68c0981a9cd6589707b0a33.json
Update document about Alternative Installation Symbolic link creation does not depend on current directory
docs/Homebrew-on-Linux.md
@@ -83,7 +83,7 @@ Extract or `git clone` Homebrew wherever you want. Use `/home/linuxbrew/.linuxbr ```sh git clone https://github.com/Homebrew/brew ~/.linuxbrew/Homebrew mkdir ~/.linuxbrew/bin -ln -s ../Homebrew/bin/brew ~/.linuxbrew/bin +ln -s ~/.linuxbrew/Homebrew/bin/brew ~/.linuxbrew/bin eval $(~/.linuxbrew/bin/brew shellenv) ```
false
Other
Homebrew
brew
178a4e55c2ccc75773c2bf22d48158f9ec6432eb.json
Remove STANDARD_COMPILERS & references to it
Library/Homebrew/os/mac.rb
@@ -168,62 +168,6 @@ def preferred_arch end end - STANDARD_COMPILERS = { - "6.0" => { clang: "6.0", clang_build: 600 }, - "6.0.1" => { clang: "6.0", clang_build: 600 }, - "6.1" => { clang: "6.0", clang_build: 600 }, - "6.1.1" => { clang: "6.0", clang_build: 600 }, - "6.2" => { clang: "6.0", clang_build: 600 }, - "6.3" => { clang: "6.1", clang_build: 602 }, - "6.3.1" => { clang: "6.1", clang_build: 602 }, - "6.3.2" => { clang: "6.1", clang_build: 602 }, - "6.4" => { clang: "6.1", clang_build: 602 }, - "7.0" => { clang: "7.0", clang_build: 700 }, - "7.0.1" => { clang: "7.0", clang_build: 700 }, - "7.1" => { clang: "7.0", clang_build: 700 }, - "7.1.1" => { clang: "7.0", clang_build: 700 }, - "7.2" => { clang: "7.0", clang_build: 700 }, - "7.2.1" => { clang: "7.0", clang_build: 700 }, - "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 }, - "8.1" => { clang: "8.0", clang_build: 800 }, - "8.2" => { clang: "8.0", clang_build: 800 }, - "8.2.1" => { clang: "8.0", clang_build: 800 }, - "8.3" => { clang: "8.1", clang_build: 802 }, - "8.3.1" => { clang: "8.1", clang_build: 802 }, - "8.3.2" => { clang: "8.1", clang_build: 802 }, - "8.3.3" => { clang: "8.1", clang_build: 802 }, - "9.0" => { clang: "9.0", clang_build: 900 }, - "9.0.1" => { clang: "9.0", clang_build: 900 }, - "9.1" => { clang: "9.0", clang_build: 900 }, - "9.2" => { clang: "9.0", clang_build: 900 }, - "9.3" => { clang: "9.1", clang_build: 902 }, - "9.4" => { clang: "9.1", clang_build: 902 }, - "10.0" => { clang: "10.0", clang_build: 1000 }, - "10.1" => { clang: "10.0", clang_build: 1000 }, - "10.2" => { clang: "10.0", clang_build: 1001 }, - "10.2.1" => { clang: "10.0", clang_build: 1001 }, - "11.0" => { clang: "11.0", clang_build: 1100 }, - }.freeze - - def compilers_standard? - STANDARD_COMPILERS.fetch(Xcode.version.to_s).all? do |method, build| - send(:"#{method}_version") == build - end - rescue IndexError - onoe <<~EOS - Homebrew doesn't know what compiler versions ship with your version - of Xcode (#{Xcode.version}). Please `brew update` and if that doesn't - help, file an issue with the output of `brew --config`: - #{Formatter.url("https://github.com/Homebrew/brew/issues")} - - Note that we only track stable, released versions of Xcode. - - Thanks! - EOS - end - def app_with_bundle_id(*ids) path = mdfind(*ids) .reject { |p| p.include?("/Backups.backupdb/") }
true
Other
Homebrew
brew
178a4e55c2ccc75773c2bf22d48158f9ec6432eb.json
Remove STANDARD_COMPILERS & references to it
docs/Xcode.md
@@ -4,10 +4,6 @@ Homebrew supports and recommends the latest Xcode and/or Command Line Tools available for your platform (see `OS::Mac::Xcode.latest_version` and `OS::Mac::CLT.latest_version` in [`Library/Homebrew/os/mac/xcode.rb`](https://github.com/Homebrew/brew/blob/master/Library/Homebrew/os/mac/xcode.rb)). -## Xcode compiler versions - -See `OS::Mac::STANDARD_COMPILERS` in [`Library/Homebrew/os/mac.rb`](https://github.com/Homebrew/brew/blob/master/Library/Homebrew/os/mac.rb). - ## Updating for new Xcode releases When a new Xcode release is made, the following things need to be updated: @@ -16,5 +12,3 @@ updated: * `OS::Mac::Xcode.latest_version` * `OS::Mac::CLT.latest_version` * `OS::Mac::Xcode.detect_version_from_clang_version` -* In [`Library/Homebrew/os/mac.rb`](https://github.com/Homebrew/brew/blob/master/Library/Homebrew/os/mac.rb) - * `OS::Mac::STANDARD_COMPILERS`
true
Other
Homebrew
brew
5ba5a2795eb7d8316410b8b851804c2f274b8fbe.json
Fix signature for forked_repo_info
Library/Homebrew/dev-cmd/bump-formula-pr.rb
@@ -341,7 +341,7 @@ def bump_formula_pr remote_url = Utils.popen_read("git remote get-url --push origin").chomp username = formula.tap.user else - remote_url, username = forked_repo_info(tap_full_name) + remote_url, username = forked_repo_info(formula, tap_full_name, backup_file) end safe_system "git", "fetch", "--unshallow", "origin" if shallow @@ -380,15 +380,15 @@ def bump_formula_pr end end - def forked_repo_info(tap_full_name) + def forked_repo_info(formula, tap_full_name, backup_file) response = GitHub.create_fork(tap_full_name) rescue GitHub::AuthenticationFailedError, *GitHub.api_errors => e formula.path.atomic_write(backup_file) odie "Unable to fork: #{e.message}!" else # GitHub API responds immediately but fork takes a few seconds to be ready. sleep 1 until GitHub.check_fork_exists(tap_full_name) - remote_url = if system("git", "config", "--local", "--get-regexp", "remote\..*\.url", "git@github.com:.*") + remote_url = if system("git", "config", "--local", "--get-regexp", "remote\..*\.url", "git@github.com:.*") response.fetch("ssh_url") else response.fetch("clone_url")
false
Other
Homebrew
brew
e704bf7184bb8ab87acbb61dfabce3772bd326a0.json
audit: add libepoxy 1.5.4 to whitelist
Library/Homebrew/dev-cmd/audit.rb
@@ -756,6 +756,7 @@ def audit_specs gtk-mac-integration 2.1.3 gtk-doc 1.31 gcab 1.3 + libepoxy 1.5.4 ].each_slice(2).to_a.map do |formula, version| [formula, version.split(".")[0..1].join(".")] end
false
Other
Homebrew
brew
3a9f585ebbd1893a034575b49f64a200c5385365.json
Move more code to utils/analytics.
Library/Homebrew/cmd/analytics.rb
@@ -24,36 +24,23 @@ def analytics_args def analytics analytics_args.parse - config_file = HOMEBREW_REPOSITORY/".git/config" raise UsageError if args.remaining.size > 1 case args.remaining.first when nil, "state" - analyticsdisabled = - Utils.popen_read("git config --file=#{config_file} --get homebrew.analyticsdisabled").chomp - uuid = - Utils.popen_read("git config --file=#{config_file} --get homebrew.analyticsuuid").chomp - if ENV["HOMEBREW_NO_ANALYTICS"] - puts "Analytics is disabled (by HOMEBREW_NO_ANALYTICS)." - elsif analyticsdisabled == "true" - puts "Analytics is disabled." + if Utils::Analytics.disabled? + puts "Analytics are disabled." else - puts "Analytics is enabled." - puts "UUID: #{uuid}" if uuid.present? + puts "Analytics are enabled." + puts "UUID: #{Utils::Analytics.uuid}" if Utils::Analytics.uuid.present? end when "on" - safe_system "git", "config", "--file=#{config_file}", - "--replace-all", "homebrew.analyticsdisabled", "false" - safe_system "git", "config", "--file=#{config_file}", - "--replace-all", "homebrew.analyticsmessage", "true" + Utils::Analytics.enable! when "off" - safe_system "git", "config", "--file=#{config_file}", - "--replace-all", "homebrew.analyticsdisabled", "true" - system "git", "config", "--file=#{config_file}", "--unset-all", "homebrew.analyticsuuid" + Utils::Analytics.disable! when "regenerate-uuid" - # it will be regenerated in next run. - system "git", "config", "--file=#{config_file}", "--unset-all", "homebrew.analyticsuuid" + Utils::Analytics.regenerate_uuid! else raise UsageError end
true
Other
Homebrew
brew
3a9f585ebbd1893a034575b49f64a200c5385365.json
Move more code to utils/analytics.
Library/Homebrew/cmd/info.rb
@@ -89,7 +89,7 @@ def info def print_info if ARGV.named.empty? if args.analytics? - output_analytics + Utils::Analytics.output elsif HOMEBREW_CELLAR.exist? count = Formula.racks.length puts "#{count} #{"keg".pluralize(count)}, #{HOMEBREW_CELLAR.dup.abv}" @@ -104,13 +104,13 @@ def print_info Formulary.find_with_priority(f) end if args.analytics? - output_formula_analytics(formula) + Utils::Analytics.formula_output(formula) else info_formula(formula) end rescue FormulaUnavailableError => e if args.analytics? - output_analytics(filter: f) + Utils::Analytics.output(filter: f) next end ofail e.message @@ -234,169 +234,7 @@ def info_formula(f) caveats = Caveats.new(f) ohai "Caveats", caveats.to_s unless caveats.empty? - output_formula_analytics(f) - end - - def formulae_api_json(endpoint) - return if ENV["HOMEBREW_NO_ANALYTICS"] || ENV["HOMEBREW_NO_GITHUB_API"] - - output, = curl_output("--max-time", "5", - "https://formulae.brew.sh/api/#{endpoint}") - return if output.blank? - - JSON.parse(output) - rescue JSON::ParserError - nil - end - - def analytics_table(category, days, results, os_version: false, cask_install: false) - oh1 "#{category} (#{days} days)" - total_count = results.values.inject("+") - formatted_total_count = format_count(total_count) - formatted_total_percent = format_percent(100) - - index_header = "Index" - count_header = "Count" - percent_header = "Percent" - name_with_options_header = if os_version - "macOS Version" - elsif cask_install - "Token" - else - "Name (with options)" - end - - total_index_footer = "Total" - max_index_width = results.length.to_s.length - index_width = [ - index_header.length, - total_index_footer.length, - max_index_width, - ].max - count_width = [ - count_header.length, - formatted_total_count.length, - ].max - percent_width = [ - percent_header.length, - formatted_total_percent.length, - ].max - name_with_options_width = Tty.width - - index_width - - count_width - - percent_width - - 10 # spacing and lines - - formatted_index_header = - format "%#{index_width}s", index_header - formatted_name_with_options_header = - format "%-#{name_with_options_width}s", - name_with_options_header[0..name_with_options_width-1] - formatted_count_header = - format "%#{count_width}s", count_header - formatted_percent_header = - format "%#{percent_width}s", percent_header - puts "#{formatted_index_header} | #{formatted_name_with_options_header} | "\ - "#{formatted_count_header} | #{formatted_percent_header}" - - columns_line = "#{"-"*index_width}:|-#{"-"*name_with_options_width}-|-"\ - "#{"-"*count_width}:|-#{"-"*percent_width}:" - puts columns_line - - index = 0 - results.each do |name_with_options, count| - index += 1 - formatted_index = format "%0#{max_index_width}d", index - formatted_index = format "%-#{index_width}s", formatted_index - formatted_name_with_options = - format "%-#{name_with_options_width}s", - name_with_options[0..name_with_options_width-1] - formatted_count = format "%#{count_width}s", format_count(count) - formatted_percent = if total_count.zero? - format "%#{percent_width}s", format_percent(0) - else - format "%#{percent_width}s", - format_percent((count.to_i * 100) / total_count.to_f) - end - puts "#{formatted_index} | #{formatted_name_with_options} | " \ - "#{formatted_count} | #{formatted_percent}%" - next if index > 10 - end - return unless results.length > 1 - - formatted_total_footer = - format "%-#{index_width}s", total_index_footer - formatted_blank_footer = - format "%-#{name_with_options_width}s", "" - formatted_total_count_footer = - format "%#{count_width}s", formatted_total_count - formatted_total_percent_footer = - format "%#{percent_width}s", formatted_total_percent - puts "#{formatted_total_footer} | #{formatted_blank_footer} | "\ - "#{formatted_total_count_footer} | #{formatted_total_percent_footer}%" - end - - def output_analytics(filter: nil) - days = args.days || "30" - category = args.category || "install" - json = formulae_api_json("analytics/#{category}/#{days}d.json") - return if json.blank? || json["items"].blank? - - os_version = category == "os-version" - cask_install = category == "cask-install" - results = {} - json["items"].each do |item| - key = if os_version - item["os_version"] - elsif cask_install - item["cask"] - else - item["formula"] - end - if filter.present? - next if key != filter && !key.start_with?("#{filter} ") - end - results[key] = item["count"].tr(",", "").to_i - end - - if filter.present? && results.blank? - onoe "No results matching `#{filter}` found!" - return - end - - analytics_table(category, days, results, os_version: os_version, cask_install: cask_install) - end - - def output_formula_analytics(f) - json = formulae_api_json("#{formula_path}/#{f}.json") - return if json.blank? || json["analytics"].blank? - - full_analytics = args.analytics? || args.verbose? - - ohai "Analytics" - json["analytics"].each do |category, value| - category = category.tr("_", "-") - analytics = [] - - value.each do |days, results| - days = days.to_i - if full_analytics - if args.days.present? - next if args.days&.to_i != days - end - if args.category.present? - next if args.category != category - end - - analytics_table(category, days, results) - else - total_count = results.values.inject("+") - analytics << "#{number_readable(total_count)} (#{days} days)" - end - end - - puts "#{category}: #{analytics.join(", ")}" unless full_analytics - end + Utils::Analytics.formula_output(f) end def decorate_dependencies(dependencies) @@ -423,24 +261,4 @@ def dep_display_s(dep) "#{dep.name} #{dep.option_tags.map { |o| "--#{o}" }.join(" ")}" end - - def format_count(count) - count.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse - end - - def format_percent(percent) - format("%<percent>.2f", percent: percent) - end - - def formula_path - "formula" - end - alias_method :generic_formula_path, :formula_path - - def analytics_path - "analytics" - end - alias_method :generic_analytics_path, :analytics_path - - require "extend/os/cmd/info" end
true
Other
Homebrew
brew
3a9f585ebbd1893a034575b49f64a200c5385365.json
Move more code to utils/analytics.
Library/Homebrew/cmd/update-report.rb
@@ -38,38 +38,27 @@ def update_report_args def update_report update_report_args.parse - HOMEBREW_REPOSITORY.cd do - analytics_message_displayed = - Utils.popen_read("git", "config", "--get", "homebrew.analyticsmessage").chomp == "true" - cask_analytics_message_displayed = - Utils.popen_read("git", "config", "--get", "homebrew.caskanalyticsmessage").chomp == "true" - analytics_disabled = - Utils.popen_read("git", "config", "--get", "homebrew.analyticsdisabled").chomp == "true" - if !analytics_message_displayed && - !cask_analytics_message_displayed && - !analytics_disabled && - !ENV["HOMEBREW_NO_ANALYTICS"] && - !ENV["HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT"] - - ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1" - # Use the shell's audible bell. - print "\a" - - # Use an extra newline and bold to avoid this being missed. - ohai "Homebrew has enabled anonymous aggregate formulae and cask analytics." - puts <<~EOS - #{Tty.bold}Read the analytics documentation (and how to opt-out) here: - #{Formatter.url("https://docs.brew.sh/Analytics")}#{Tty.reset} + if !Utils::Analytics.messages_displayed? && + !Utils::Analytics.disabled? && + !Utils::Analytics.no_message_output? - EOS + ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1" + # Use the shell's audible bell. + print "\a" - # Consider the message possibly missed if not a TTY. - if $stdout.tty? - safe_system "git", "config", "--replace-all", "homebrew.analyticsmessage", "true" - safe_system "git", "config", "--replace-all", "homebrew.caskanalyticsmessage", "true" - end - end + # Use an extra newline and bold to avoid this being missed. + ohai "Homebrew has enabled anonymous aggregate formulae and cask analytics." + puts <<~EOS + #{Tty.bold}Read the analytics documentation (and how to opt-out) here: + #{Formatter.url("https://docs.brew.sh/Analytics")}#{Tty.reset} + EOS + + # Consider the messages possibly missed if not a TTY. + Utils::Analytics.messages_displayed! if $stdout.tty? + end + + HOMEBREW_REPOSITORY.cd do donation_message_displayed = Utils.popen_read("git", "config", "--get", "homebrew.donationmessage").chomp == "true" unless donation_message_displayed
true