From c6f21f1dc1f91f4996a0d471f9aefa0e9a3a8a28 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 3 May 2018 14:24:37 +0100 Subject: [PATCH] bump-formula-pr: rename @args. This shadows the Homebrew variable so let's rename it for now so that `--force` works again. --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 48 ++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 60c3d387c09d8..f68126b773111 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -48,7 +48,7 @@ module Homebrew module_function def bump_formula_pr - @args = Homebrew::CLI::Parser.parse do + @bump_args = Homebrew::CLI::Parser.parse do switch "--devel" switch "-n", "--dry-run" switch "--write" @@ -96,7 +96,7 @@ def bump_formula_pr checked_for_duplicates = true end - new_url = @args.url + new_url = @bump_args.url if new_url && !formula # Split the new URL on / and find any formulae that have the same URL # except for the last component, but don't try to match any more than the @@ -107,7 +107,7 @@ def bump_formula_pr components_to_match = [new_url_split.count - 1, maximum_url_components_to_match].min base_url = new_url_split.first(components_to_match).join("/") base_url = /#{Regexp.escape(base_url)}/ - is_devel = @args.devel? + is_devel = @bump_args.devel? guesses = [] Formula.each do |f| if is_devel && f.devel && f.devel.url && f.devel.url.match(base_url) @@ -126,7 +126,7 @@ def bump_formula_pr check_for_duplicate_pull_requests(formula) unless checked_for_duplicates - requested_spec, formula_spec = if @args.devel? + requested_spec, formula_spec = if @bump_args.devel? devel_message = " (devel)" [:devel, formula.devel] else @@ -138,11 +138,11 @@ def bump_formula_pr [checksum.hash_type, checksum.hexdigest] end - new_hash = @args[hash_type] if hash_type - new_tag = @args.tag - new_revision = @args.revision - new_mirror = @args.mirror - forced_version = @args.version + new_hash = @bump_args[hash_type] if hash_type + new_tag = @bump_args.tag + new_revision = @bump_args.revision + new_mirror = @bump_args.mirror + forced_version = @bump_args.version new_url_hash = if new_url && new_hash true elsif new_tag && new_revision @@ -179,7 +179,7 @@ def bump_formula_pr end end - if @args.dry_run? + if @bump_args.dry_run? ohai "brew update" else safe_system "brew", "update" @@ -208,7 +208,7 @@ def bump_formula_pr ] end - backup_file = File.read(formula.path) unless @args.dry_run? + backup_file = File.read(formula.path) unless @bump_args.dry_run? if new_mirror replacement_pairs << [/^( +)(url \"#{Regexp.escape(new_url)}\"\n)/m, "\\1\\2\\1mirror \"#{new_mirror}\"\n"] @@ -238,31 +238,31 @@ def bump_formula_pr new_formula_version = formula_version(formula, requested_spec, new_contents) if new_formula_version < old_formula_version - formula.path.atomic_write(backup_file) unless @args.dry_run? + formula.path.atomic_write(backup_file) unless @bump_args.dry_run? odie <<~EOS You probably need to bump this formula manually since changing the version from #{old_formula_version} to #{new_formula_version} would be a downgrade. EOS elsif new_formula_version == old_formula_version - formula.path.atomic_write(backup_file) unless @args.dry_run? + formula.path.atomic_write(backup_file) unless @bump_args.dry_run? odie <<~EOS You probably need to bump this formula manually since the new version and old version are both #{new_formula_version}. EOS end - if @args.dry_run? - if @args.strict? + if @bump_args.dry_run? + if @bump_args.strict? ohai "brew audit --strict #{formula.path.basename}" - elsif @args.audit? + elsif @bump_args.audit? ohai "brew audit #{formula.path.basename}" end else failed_audit = false - if @args.strict? + if @bump_args.strict? system HOMEBREW_BREW_FILE, "audit", "--strict", formula.path failed_audit = !$CHILD_STATUS.success? - elsif @args.audit? + elsif @bump_args.audit? system HOMEBREW_BREW_FILE, "audit", formula.path failed_audit = !$CHILD_STATUS.success? end @@ -277,7 +277,7 @@ def bump_formula_pr git_dir = Utils.popen_read("git rev-parse --git-dir").chomp shallow = !git_dir.empty? && File.exist?("#{git_dir}/shallow") - if @args.dry_run? + if @bump_args.dry_run? ohai "fork repository with GitHub API" ohai "git fetch --unshallow origin" if shallow ohai "git checkout --no-track -b #{branch} origin/master" @@ -292,7 +292,7 @@ def bump_formula_pr # GitHub API responds immediately but fork takes a few seconds to be ready. sleep 3 rescue *gh_api_errors => e - formula.path.atomic_write(backup_file) unless @args.dry_run? + formula.path.atomic_write(backup_file) unless @bump_args.dry_run? odie "Unable to fork: #{e.message}!" end @@ -309,7 +309,7 @@ def bump_formula_pr pr_message = <<~EOS Created with `brew bump-formula-pr`. EOS - user_message = @args.message + user_message = @bump_args.message if user_message pr_message += "\n" + <<~EOS --- @@ -322,7 +322,7 @@ def bump_formula_pr begin url = GitHub.create_pull_request(formula.tap.full_name, pr_title, "#{username}:#{branch}", "master", pr_message)["html_url"] - if @args.no_browse? + if @bump_args.no_browse? puts url else exec_browser url @@ -335,7 +335,7 @@ def bump_formula_pr end def inreplace_pairs(path, replacement_pairs) - if @args.dry_run? + if @bump_args.dry_run? contents = path.open("r") { |f| Formulary.ensure_utf8_encoding(f).read } contents.extend(StringInreplaceExtension) replacement_pairs.each do |old, new| @@ -347,7 +347,7 @@ def inreplace_pairs(path, replacement_pairs) unless contents.errors.empty? raise Utils::InreplaceError, path => contents.errors end - path.atomic_write(contents) if @args.write? + path.atomic_write(contents) if @bump_args.write? contents else Utils::Inreplace.inreplace(path) do |s|