diff options
| author | Mike McQuaid | 2013-10-22 11:58:33 +0100 | 
|---|---|---|
| committer | Mike McQuaid | 2013-10-22 11:58:40 +0100 | 
| commit | 98b28f5ac3bf63efc82c915e3055940d08716d0f (patch) | |
| tree | e7e5076a519c5d6cdec80ba381f22b898ae98138 /Library | |
| parent | de871a4daf4947593c87ea2958e842741d9757ad (diff) | |
| download | brew-98b28f5ac3bf63efc82c915e3055940d08716d0f.tar.bz2 | |
Different regex for user/tap/formula and user/tap.
Closes Homebrew/homebrew#23430.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cmd/install.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/search.rb | 8 | ||||
| -rw-r--r-- | Library/Homebrew/exceptions.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/global.rb | 5 | 
4 files changed, 10 insertions, 7 deletions
diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index a8bd6454f..b24783aac 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -16,7 +16,7 @@ module Homebrew extend self          msg = blacklisted? name          raise "No available formula for #{name}\n#{msg}" if msg        end -      if not File.exist? name and name =~ HOMEBREW_TAP_REGEX then +      if not File.exist? name and name =~ HOMEBREW_TAP_FORMULA_REGEX then          require 'cmd/tap'          begin            install_tap $1, $2 diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb index 204a178ae..b2febbdba 100644 --- a/Library/Homebrew/cmd/search.rb +++ b/Library/Homebrew/cmd/search.rb @@ -4,6 +4,12 @@ require 'utils'  require 'utils/json'  module Homebrew extend self + +  # A regular expession to capture the username (one or more char but no `/`, +  # which has to be escaped like `\/`), repository, followed by an optional `/` +  # and an optional query. +  TAP_QUERY_REGEX = /^([^\/]+)\/([^\/]+)\/?(.+)?$/ +    def search      if ARGV.include? '--macports'        exec_browser "http://www.macports.org/ports.php?by=name&substr=#{ARGV.next}" @@ -19,7 +25,7 @@ module Homebrew extend self        exec_browser "http://packages.ubuntu.com/search?keywords=#{ARGV.next}&searchon=names&suite=all§ion=all"      elsif (query = ARGV.first).nil?        puts_columns Formula.names -    elsif ARGV.first =~ HOMEBREW_TAP_REGEX +    elsif ARGV.first =~ TAP_QUERY_REGEX        # So look for user/repo/query or list all formulae by the tap        # we downcase to avoid case-insensitive filesystem issues.        user, repo, query = $1.downcase, $2.downcase, $3 diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 9764879bd..92b1a4177 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -44,7 +44,7 @@ class FormulaUnavailableError < RuntimeError    end    def to_s -    if name =~ HOMEBREW_TAP_REGEX then <<-EOS.undent +    if name =~ HOMEBREW_TAP_FORMULA_REGEX then <<-EOS.undent        No available formula for #$3 #{dependent_s}        Please tap it and then try again: brew tap #$1/#$2        EOS diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 2345997c0..caa6ccb37 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -83,10 +83,7 @@ HOMEBREW_USER_AGENT = "Homebrew #{HOMEBREW_VERSION} (Ruby #{RUBY_VERSION}-#{RUBY  HOMEBREW_CURL_ARGS = '-f#LA' -# A regular expession to capture the username (one or more char but no `/`, -# which has to be escaped like `\/`), repository, followed by an optional `/` -# and an optional query. -HOMEBREW_TAP_REGEX = /^([^\/]+)\/([^\/]+)\/?(.+)?$/ +HOMEBREW_TAP_FORMULA_REGEX = %r{(\w+)/(\w+)/([^/]+)}  module Homebrew extend self    include FileUtils  | 
