add Tap#default_remote
* without `default_remote`, `CoreTap#install` won't be able to tell whether user has passed to custom remote to it. * simplify some part of logics
This commit is contained in:
		
							parent
							
								
									71b6e0aa18
								
							
						
					
					
						commit
						9a6d5a4fee
					
				@ -95,6 +95,11 @@ class Tap
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # The default remote path to this {Tap}.
 | 
			
		||||
  def default_remote
 | 
			
		||||
    "https://github.com/#{user}/homebrew-#{repo}"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # True if this {Tap} is a git repository.
 | 
			
		||||
  def git?
 | 
			
		||||
    (path/".git").exist?
 | 
			
		||||
@ -185,7 +190,7 @@ class Tap
 | 
			
		||||
 | 
			
		||||
    full_clone = options.fetch(:full_clone, false)
 | 
			
		||||
    quiet = options.fetch(:quiet, false)
 | 
			
		||||
    requested_remote = options[:clone_target] || "https://github.com/#{user}/homebrew-#{repo}"
 | 
			
		||||
    requested_remote = options[:clone_target] || default_remote
 | 
			
		||||
 | 
			
		||||
    if installed?
 | 
			
		||||
      raise TapAlreadyTappedError, name unless full_clone
 | 
			
		||||
@ -293,7 +298,7 @@ class Tap
 | 
			
		||||
  # True if the {#remote} of {Tap} is customized.
 | 
			
		||||
  def custom_remote?
 | 
			
		||||
    return true unless remote
 | 
			
		||||
    remote.casecmp("https://github.com/#{user}/homebrew-#{repo}") != 0
 | 
			
		||||
    remote.casecmp(default_remote) != 0
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # path to the directory of all {Formula} files for this {Tap}.
 | 
			
		||||
@ -500,9 +505,13 @@ end
 | 
			
		||||
# A specialized {Tap} class for the core formulae
 | 
			
		||||
class CoreTap < Tap
 | 
			
		||||
  if OS.mac?
 | 
			
		||||
    OFFICIAL_REMOTE = "https://github.com/Homebrew/homebrew-core"
 | 
			
		||||
    def default_remote
 | 
			
		||||
      "https://github.com/Homebrew/homebrew-core"
 | 
			
		||||
    end
 | 
			
		||||
  else
 | 
			
		||||
    OFFICIAL_REMOTE = "https://github.com/Linuxbrew/homebrew-core"
 | 
			
		||||
    def default_remote
 | 
			
		||||
      "https://github.com/Linuxbrew/homebrew-core"
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # @private
 | 
			
		||||
@ -521,11 +530,6 @@ class CoreTap < Tap
 | 
			
		||||
    safe_system HOMEBREW_BREW_FILE, *args
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def install(options = {})
 | 
			
		||||
    options[:clone_target] ||= OFFICIAL_REMOTE
 | 
			
		||||
    super options
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # @private
 | 
			
		||||
  def uninstall
 | 
			
		||||
    raise "Tap#uninstall is not available for CoreTap"
 | 
			
		||||
@ -546,11 +550,6 @@ class CoreTap < Tap
 | 
			
		||||
    false
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # @private
 | 
			
		||||
  def custom_remote?
 | 
			
		||||
    remote != OFFICIAL_REMOTE
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # @private
 | 
			
		||||
  def core_tap?
 | 
			
		||||
    true
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user