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
|
||||||
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.
|
# True if this {Tap} is a git repository.
|
||||||
def git?
|
def git?
|
||||||
(path/".git").exist?
|
(path/".git").exist?
|
||||||
@ -185,7 +190,7 @@ class Tap
|
|||||||
|
|
||||||
full_clone = options.fetch(:full_clone, false)
|
full_clone = options.fetch(:full_clone, false)
|
||||||
quiet = options.fetch(:quiet, 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?
|
if installed?
|
||||||
raise TapAlreadyTappedError, name unless full_clone
|
raise TapAlreadyTappedError, name unless full_clone
|
||||||
@ -293,7 +298,7 @@ class Tap
|
|||||||
# True if the {#remote} of {Tap} is customized.
|
# True if the {#remote} of {Tap} is customized.
|
||||||
def custom_remote?
|
def custom_remote?
|
||||||
return true unless remote
|
return true unless remote
|
||||||
remote.casecmp("https://github.com/#{user}/homebrew-#{repo}") != 0
|
remote.casecmp(default_remote) != 0
|
||||||
end
|
end
|
||||||
|
|
||||||
# path to the directory of all {Formula} files for this {Tap}.
|
# path to the directory of all {Formula} files for this {Tap}.
|
||||||
@ -500,9 +505,13 @@ end
|
|||||||
# A specialized {Tap} class for the core formulae
|
# A specialized {Tap} class for the core formulae
|
||||||
class CoreTap < Tap
|
class CoreTap < Tap
|
||||||
if OS.mac?
|
if OS.mac?
|
||||||
OFFICIAL_REMOTE = "https://github.com/Homebrew/homebrew-core"
|
def default_remote
|
||||||
|
"https://github.com/Homebrew/homebrew-core"
|
||||||
|
end
|
||||||
else
|
else
|
||||||
OFFICIAL_REMOTE = "https://github.com/Linuxbrew/homebrew-core"
|
def default_remote
|
||||||
|
"https://github.com/Linuxbrew/homebrew-core"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
@ -521,11 +530,6 @@ class CoreTap < Tap
|
|||||||
safe_system HOMEBREW_BREW_FILE, *args
|
safe_system HOMEBREW_BREW_FILE, *args
|
||||||
end
|
end
|
||||||
|
|
||||||
def install(options = {})
|
|
||||||
options[:clone_target] ||= OFFICIAL_REMOTE
|
|
||||||
super options
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def uninstall
|
def uninstall
|
||||||
raise "Tap#uninstall is not available for CoreTap"
|
raise "Tap#uninstall is not available for CoreTap"
|
||||||
@ -546,11 +550,6 @@ class CoreTap < Tap
|
|||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
|
||||||
def custom_remote?
|
|
||||||
remote != OFFICIAL_REMOTE
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def core_tap?
|
def core_tap?
|
||||||
true
|
true
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user