From 1c10a6260fb4f4036d68b4c34acc6135b26b93d6 Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Sun, 25 Dec 2016 18:54:08 -0500 Subject: Hint at new location of migrated formulae Partial implementation of https://github.com/Homebrew/brew-evolution/pull/15, along with the ability to search for deleted formulae in git history (inspired by #1996) which is not described in the proposal. See also: #1371. --- Library/Homebrew/cmd/info.rb | 22 +++++++++++++++++++--- Library/Homebrew/cmd/install.rb | 13 +++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) (limited to 'Library/Homebrew/cmd') diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index b7de0005c..2d5e34ce2 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -23,6 +23,7 @@ require "formula" require "keg" require "tab" require "json" +require "historic" module Homebrew module_function @@ -54,10 +55,25 @@ module Homebrew else info_formula Formulary.find_with_priority(f) end - rescue FormulaUnavailableError + rescue FormulaUnavailableError => e # No formula with this name, try a blacklist lookup - raise unless (blacklist = blacklisted?(f)) - puts blacklist + if (blacklist = blacklisted?(f)) + ofail "#{e.message}\n#{blacklist}" + else + ofail e.message + + # No point in searching if the specified tap isn't tapped yet + next if e.instance_of?(TapFormulaUnavailableError) && !e.tap.installed? + + migrations = search_for_migrated_formula(f) + next unless migrations.empty? + ohai "Searching among deleted formulae..." + begin + search_for_deleted_formula(f) + rescue + nil + end + end end end end diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index c825e2796..8a99bd397 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -62,6 +62,7 @@ require "formula_installer" require "tap" require "hardware" require "development_tools" +require "historic" module Homebrew module_function @@ -212,6 +213,18 @@ module Homebrew ofail "What's updog?" else ofail e.message + + migrations = search_for_migrated_formula(e.name) + return unless migrations.empty? + + ohai "Searching among deleted formulae..." + begin + search_for_deleted_formula(e.name) + return + rescue + nil + end + query = query_regexp(e.name) ohai "Searching for similarly named formulae..." -- cgit v1.2.3 From 8cedd62750403d7f0c66cbeb714f6da50f50384f Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 18 Mar 2017 17:04:44 +0200 Subject: search: tweak specific formula match formatting. --- Library/Homebrew/cmd/search.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Library/Homebrew/cmd') diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb index e834a00b5..4c8bbc77c 100644 --- a/Library/Homebrew/cmd/search.rb +++ b/Library/Homebrew/cmd/search.rb @@ -70,8 +70,7 @@ module Homebrew if msg = blacklisted?(query) if count > 0 puts - puts "If you meant #{query.inspect} precisely:" - puts + puts "If you meant #{query.inspect} specifically:" end puts msg elsif count.zero? -- cgit v1.2.3 From 623c95b3f8660d5c77936483ec9b9a4db16aff00 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 18 Mar 2017 16:57:40 +0200 Subject: cmd/log: improve output messaging. This wasn’t adapted to the new, multiple repository world. --- Library/Homebrew/cmd/log.rb | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'Library/Homebrew/cmd') diff --git a/Library/Homebrew/cmd/log.rb b/Library/Homebrew/cmd/log.rb index 22a3ee11d..9323c762d 100644 --- a/Library/Homebrew/cmd/log.rb +++ b/Library/Homebrew/cmd/log.rb @@ -9,20 +9,32 @@ module Homebrew def log if ARGV.named.empty? - cd HOMEBREW_REPOSITORY - git_log + git_log HOMEBREW_REPOSITORY else path = Formulary.path(ARGV.named.first) - cd path.dirname # supports taps - git_log path + tap = Tap.from_path(path) + git_log path.dirname, path, tap end end - def git_log(path = nil) - if File.exist? "#{`git rev-parse --show-toplevel`.chomp}/.git/shallow" + def git_log(cd_dir, path = nil, tap = nil) + cd cd_dir + repo = Utils.popen_read("git rev-parse --show-toplevel").chomp + if tap + name = tap.to_s + git_cd = "$(brew --repo #{tap})" + elsif cd_dir == HOMEBREW_REPOSITORY + name = "Homebrew/brew" + git_cd = "$(brew --repo)" + else + name, git_cd = cd_dir + end + + if File.exist? "#{repo}/.git/shallow" opoo <<-EOS.undent - The git repository is a shallow clone therefore the filtering may be incorrect. - Use `git fetch --unshallow` to get the full repository. + #{name} is a shallow clone so only partial output will be shown. + To get a full clone run: + git -C "#{git_cd}" fetch --unshallow EOS end args = ARGV.options_only -- cgit v1.2.3 From 80e95b684e7485b5c5b7f7209dd95b0bdc9e3406 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 18 Mar 2017 17:02:08 +0200 Subject: blacklist: move to missing_formula class instead. This will allow extending this class so it can be used by more than just blacklisting. --- Library/Homebrew/cmd/info.rb | 8 ++++---- Library/Homebrew/cmd/install.rb | 6 +++--- Library/Homebrew/cmd/search.rb | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'Library/Homebrew/cmd') diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index 2d5e34ce2..5c96e5c50 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -16,7 +16,7 @@ #: See the docs for examples of using the JSON output: #: -require "blacklist" +require "missing_formula" require "caveats" require "options" require "formula" @@ -56,9 +56,9 @@ module Homebrew info_formula Formulary.find_with_priority(f) end rescue FormulaUnavailableError => e - # No formula with this name, try a blacklist lookup - if (blacklist = blacklisted?(f)) - ofail "#{e.message}\n#{blacklist}" + # No formula with this name, try a missing formula lookup + if (missing_formula = Homebrew::MissingFormula.missing_formula(f)) + ofail "#{e.message}\n#{missing_formula}" else ofail e.message diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 8a99bd397..a0f95887b 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -55,7 +55,7 @@ #: If `--git` is passed, Homebrew will create a Git repository, useful for #: creating patches to the software. -require "blacklist" +require "missing_formula" require "diagnostic" require "cmd/search" require "formula_installer" @@ -207,8 +207,8 @@ module Homebrew # formula was found, but there's a problem with its implementation). ofail e.message rescue FormulaUnavailableError => e - if (blacklist = blacklisted?(e.name)) - ofail "#{e.message}\n#{blacklist}" + if (missing_formula = Homebrew::MissingFormula.missing_formula(e.name)) + ofail "#{e.message}\n#{missing_formula}" elsif e.name == "updog" ofail "What's updog?" else diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb index 4c8bbc77c..6887805d6 100644 --- a/Library/Homebrew/cmd/search.rb +++ b/Library/Homebrew/cmd/search.rb @@ -14,7 +14,7 @@ #: Search for in the given package manager's list. require "formula" -require "blacklist" +require "missing_formula" require "utils" require "thread" require "official_taps" @@ -67,7 +67,7 @@ module Homebrew if $stdout.tty? count = local_results.length + tap_results.length - if msg = blacklisted?(query) + if msg = Homebrew::MissingFormula.missing_formula(query) if count > 0 puts puts "If you meant #{query.inspect} specifically:" -- cgit v1.2.3 From f59eb358c29c5f40601a99e3f1bf7e8e891f10ba Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 20 Mar 2017 20:37:12 +0100 Subject: missing_formula: subsume historic logic. These methods belong together so combine them in a single class to provide a simpler API. --- Library/Homebrew/cmd/info.rb | 17 ++--------------- Library/Homebrew/cmd/install.rb | 16 ++-------------- Library/Homebrew/cmd/search.rb | 4 ++-- 3 files changed, 6 insertions(+), 31 deletions(-) (limited to 'Library/Homebrew/cmd') diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index 5c96e5c50..7e1815556 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -23,7 +23,6 @@ require "formula" require "keg" require "tab" require "json" -require "historic" module Homebrew module_function @@ -57,22 +56,10 @@ module Homebrew end rescue FormulaUnavailableError => e # No formula with this name, try a missing formula lookup - if (missing_formula = Homebrew::MissingFormula.missing_formula(f)) - ofail "#{e.message}\n#{missing_formula}" + if (reason = Homebrew::MissingFormula.reason(f)) + ofail "#{e.message}\n#{reason}" else ofail e.message - - # No point in searching if the specified tap isn't tapped yet - next if e.instance_of?(TapFormulaUnavailableError) && !e.tap.installed? - - migrations = search_for_migrated_formula(f) - next unless migrations.empty? - ohai "Searching among deleted formulae..." - begin - search_for_deleted_formula(f) - rescue - nil - end end end end diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index a0f95887b..bd7897171 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -62,7 +62,6 @@ require "formula_installer" require "tap" require "hardware" require "development_tools" -require "historic" module Homebrew module_function @@ -207,24 +206,13 @@ module Homebrew # formula was found, but there's a problem with its implementation). ofail e.message rescue FormulaUnavailableError => e - if (missing_formula = Homebrew::MissingFormula.missing_formula(e.name)) - ofail "#{e.message}\n#{missing_formula}" + if (reason = Homebrew::MissingFormula.reason(e.name)) + ofail "#{e.message}\n#{reason}" elsif e.name == "updog" ofail "What's updog?" else ofail e.message - migrations = search_for_migrated_formula(e.name) - return unless migrations.empty? - - ohai "Searching among deleted formulae..." - begin - search_for_deleted_formula(e.name) - return - rescue - nil - end - query = query_regexp(e.name) ohai "Searching for similarly named formulae..." diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb index 6887805d6..db5898872 100644 --- a/Library/Homebrew/cmd/search.rb +++ b/Library/Homebrew/cmd/search.rb @@ -67,12 +67,12 @@ module Homebrew if $stdout.tty? count = local_results.length + tap_results.length - if msg = Homebrew::MissingFormula.missing_formula(query) + if reason = Homebrew::MissingFormula.reason(query) if count > 0 puts puts "If you meant #{query.inspect} specifically:" end - puts msg + puts reason elsif count.zero? puts "No formula found for #{query.inspect}." begin -- cgit v1.2.3