mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
rename CoreFormulaRepository to CoreTap
Core tap will be separated from core code in the near future. It makes sense to rename it to CoreTap.
This commit is contained in:
parent
2b32cfe7b0
commit
28f3dae8cd
@ -47,7 +47,7 @@ def bottle_resolve_formula_names(bottle_file)
|
|||||||
name = receipt_file_path.split("/").first
|
name = receipt_file_path.split("/").first
|
||||||
tap = Tab.from_file_content(receipt_file, "#{bottle_file}/#{receipt_file_path}").tap
|
tap = Tab.from_file_content(receipt_file, "#{bottle_file}/#{receipt_file_path}").tap
|
||||||
|
|
||||||
if tap.nil? || tap.core_formula_repository?
|
if tap.nil? || tap.core_tap?
|
||||||
full_name = name
|
full_name = name
|
||||||
else
|
else
|
||||||
full_name = "#{tap}/#{name}"
|
full_name = "#{tap}/#{name}"
|
||||||
@ -66,7 +66,7 @@ class Bintray
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.repository(tap = nil)
|
def self.repository(tap = nil)
|
||||||
if tap.nil? || tap.core_formula_repository?
|
if tap.nil? || tap.core_tap?
|
||||||
"bottles"
|
"bottles"
|
||||||
else
|
else
|
||||||
"bottles-#{tap.repo}"
|
"bottles-#{tap.repo}"
|
||||||
|
@ -247,7 +247,7 @@ class FormulaAuditor
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if oldname = CoreFormulaRepository.instance.formula_renames[name]
|
if oldname = CoreTap.instance.formula_renames[name]
|
||||||
problem "'#{name}' is reserved as the old name of #{oldname}"
|
problem "'#{name}' is reserved as the old name of #{oldname}"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -3,7 +3,6 @@ require "diagnostic"
|
|||||||
require "cmd/search"
|
require "cmd/search"
|
||||||
require "formula_installer"
|
require "formula_installer"
|
||||||
require "tap"
|
require "tap"
|
||||||
require "core_formula_repository"
|
|
||||||
require "hardware"
|
require "hardware"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
|
@ -23,7 +23,6 @@ require "utils"
|
|||||||
require "utils/json"
|
require "utils/json"
|
||||||
require "formula"
|
require "formula"
|
||||||
require "tap"
|
require "tap"
|
||||||
require "core_formula_repository"
|
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
def pull
|
def pull
|
||||||
@ -41,11 +40,11 @@ module Homebrew
|
|||||||
if arg.to_i > 0
|
if arg.to_i > 0
|
||||||
issue = arg
|
issue = arg
|
||||||
url = "https://github.com/Homebrew/homebrew/pull/#{arg}"
|
url = "https://github.com/Homebrew/homebrew/pull/#{arg}"
|
||||||
tap = CoreFormulaRepository.instance
|
tap = CoreTap.instance
|
||||||
elsif (testing_match = arg.match %r{brew.sh/job/Homebrew.*Testing/(\d+)/})
|
elsif (testing_match = arg.match %r{brew.sh/job/Homebrew.*Testing/(\d+)/})
|
||||||
_, testing_job = *testing_match
|
_, testing_job = *testing_match
|
||||||
url = "https://github.com/Homebrew/homebrew/compare/master...BrewTestBot:testing-#{testing_job}"
|
url = "https://github.com/Homebrew/homebrew/compare/master...BrewTestBot:testing-#{testing_job}"
|
||||||
tap = CoreFormulaRepository.instance
|
tap = CoreTap.instance
|
||||||
odie "Testing URLs require `--bottle`!" unless ARGV.include?("--bottle")
|
odie "Testing URLs require `--bottle`!" unless ARGV.include?("--bottle")
|
||||||
elsif (api_match = arg.match HOMEBREW_PULL_API_REGEX)
|
elsif (api_match = arg.match HOMEBREW_PULL_API_REGEX)
|
||||||
_, user, repo, issue = *api_match
|
_, user, repo, issue = *api_match
|
||||||
@ -167,7 +166,7 @@ module Homebrew
|
|||||||
url
|
url
|
||||||
else
|
else
|
||||||
bottle_branch = "pull-bottle-#{issue}"
|
bottle_branch = "pull-bottle-#{issue}"
|
||||||
if tap.core_formula_repository?
|
if tap.core_tap?
|
||||||
"https://github.com/BrewTestBot/homebrew/compare/homebrew:master...pr-#{issue}"
|
"https://github.com/BrewTestBot/homebrew/compare/homebrew:master...pr-#{issue}"
|
||||||
else
|
else
|
||||||
"https://github.com/BrewTestBot/homebrew-#{tap.repo}/compare/homebrew:master...pr-#{issue}"
|
"https://github.com/BrewTestBot/homebrew-#{tap.repo}/compare/homebrew:master...pr-#{issue}"
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
require "formula"
|
require "formula"
|
||||||
require "tap"
|
require "tap"
|
||||||
require "core_formula_repository"
|
|
||||||
require "thread"
|
require "thread"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
@ -39,7 +38,7 @@ module Homebrew
|
|||||||
if ARGV.named.empty?
|
if ARGV.named.empty?
|
||||||
formulae = Formula.files
|
formulae = Formula.files
|
||||||
alias_dirs = Tap.map(&:alias_dir)
|
alias_dirs = Tap.map(&:alias_dir)
|
||||||
alias_dirs.unshift CoreFormulaRepository.instance.alias_dir
|
alias_dirs.unshift CoreTap.instance.alias_dir
|
||||||
else
|
else
|
||||||
tap = Tap.fetch(ARGV.named.first)
|
tap = Tap.fetch(ARGV.named.first)
|
||||||
raise TapUnavailableError, tap.name unless tap.installed?
|
raise TapUnavailableError, tap.name unless tap.installed?
|
||||||
|
@ -10,7 +10,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
raise "Homebrew/homebrew is not allowed" if taps.any?(&:core_formula_repository?)
|
raise "Homebrew/homebrew is not allowed" if taps.any?(&:core_tap?)
|
||||||
|
|
||||||
if ARGV.json == "v1"
|
if ARGV.json == "v1"
|
||||||
print_tap_json(taps)
|
print_tap_json(taps)
|
||||||
|
@ -4,7 +4,7 @@ module Homebrew
|
|||||||
def tap_pin
|
def tap_pin
|
||||||
ARGV.named.each do |name|
|
ARGV.named.each do |name|
|
||||||
tap = Tap.fetch(name)
|
tap = Tap.fetch(name)
|
||||||
raise "Homebrew/homebrew is not allowed" if tap.core_formula_repository?
|
raise "Homebrew/homebrew is not allowed" if tap.core_tap?
|
||||||
tap.pin
|
tap.pin
|
||||||
ohai "Pinned #{tap.name}"
|
ohai "Pinned #{tap.name}"
|
||||||
end
|
end
|
||||||
|
@ -4,7 +4,7 @@ module Homebrew
|
|||||||
def tap_unpin
|
def tap_unpin
|
||||||
ARGV.named.each do |name|
|
ARGV.named.each do |name|
|
||||||
tap = Tap.fetch(name)
|
tap = Tap.fetch(name)
|
||||||
raise "Homebrew/homebrew is not allowed" if tap.core_formula_repository?
|
raise "Homebrew/homebrew is not allowed" if tap.core_tap?
|
||||||
tap.unpin
|
tap.unpin
|
||||||
ohai "Unpinned #{tap.name}"
|
ohai "Unpinned #{tap.name}"
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
require "tap"
|
require "tap"
|
||||||
require "core_formula_repository"
|
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
def tap
|
def tap
|
||||||
|
@ -31,7 +31,6 @@ require "rexml/document"
|
|||||||
require "rexml/xmldecl"
|
require "rexml/xmldecl"
|
||||||
require "rexml/cdata"
|
require "rexml/cdata"
|
||||||
require "tap"
|
require "tap"
|
||||||
require "core_formula_repository"
|
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
BYTES_IN_1_MEGABYTE = 1024*1024
|
BYTES_IN_1_MEGABYTE = 1024*1024
|
||||||
@ -62,7 +61,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
CoreFormulaRepository.instance
|
CoreTap.instance
|
||||||
end
|
end
|
||||||
|
|
||||||
class Step
|
class Step
|
||||||
@ -209,7 +208,7 @@ module Homebrew
|
|||||||
@added_formulae = []
|
@added_formulae = []
|
||||||
@modified_formula = []
|
@modified_formula = []
|
||||||
@steps = []
|
@steps = []
|
||||||
@tap = options.fetch(:tap, CoreFormulaRepository.instance)
|
@tap = options.fetch(:tap, CoreTap.instance)
|
||||||
@repository = @tap.path
|
@repository = @tap.path
|
||||||
@skip_homebrew = options.fetch(:skip_homebrew, false)
|
@skip_homebrew = options.fetch(:skip_homebrew, false)
|
||||||
|
|
||||||
@ -609,7 +608,7 @@ module Homebrew
|
|||||||
@category = __method__
|
@category = __method__
|
||||||
return if @skip_homebrew
|
return if @skip_homebrew
|
||||||
test "brew", "tests"
|
test "brew", "tests"
|
||||||
if @tap.core_formula_repository?
|
if @tap.core_tap?
|
||||||
tests_args = ["--no-compat"]
|
tests_args = ["--no-compat"]
|
||||||
readall_args = ["--aliases"]
|
readall_args = ["--aliases"]
|
||||||
if RUBY_VERSION.split(".").first.to_i >= 2
|
if RUBY_VERSION.split(".").first.to_i >= 2
|
||||||
@ -767,7 +766,7 @@ module Homebrew
|
|||||||
safe_system "brew", "update"
|
safe_system "brew", "update"
|
||||||
|
|
||||||
if pr
|
if pr
|
||||||
pull_pr = if tap.core_formula_repository?
|
pull_pr = if tap.core_tap?
|
||||||
pr
|
pr
|
||||||
else
|
else
|
||||||
"https://github.com/#{tap.user}/homebrew-#{tap.repo}/pull/#{pr}"
|
"https://github.com/#{tap.user}/homebrew-#{tap.repo}/pull/#{pr}"
|
||||||
@ -779,7 +778,7 @@ module Homebrew
|
|||||||
bottle_args << "--keep-old" if ARGV.include? "--keep-old"
|
bottle_args << "--keep-old" if ARGV.include? "--keep-old"
|
||||||
system "brew", "bottle", *bottle_args
|
system "brew", "bottle", *bottle_args
|
||||||
|
|
||||||
remote_repo = tap.core_formula_repository? ? "homebrew" : "homebrew-#{tap.repo}"
|
remote_repo = tap.core_tap? ? "homebrew" : "homebrew-#{tap.repo}"
|
||||||
remote = "git@github.com:BrewTestBot/#{remote_repo}.git"
|
remote = "git@github.com:BrewTestBot/#{remote_repo}.git"
|
||||||
tag = pr ? "pr-#{pr}" : "testing-#{number}"
|
tag = pr ? "pr-#{pr}" : "testing-#{number}"
|
||||||
safe_system "git", "push", "--force", remote, "master:master", ":refs/tags/#{tag}"
|
safe_system "git", "push", "--force", remote, "master:master", ":refs/tags/#{tag}"
|
||||||
|
@ -6,7 +6,7 @@ module Homebrew
|
|||||||
|
|
||||||
ARGV.named.each do |tapname|
|
ARGV.named.each do |tapname|
|
||||||
tap = Tap.fetch(tapname)
|
tap = Tap.fetch(tapname)
|
||||||
raise "Homebrew/homebrew is not allowed" if tap.core_formula_repository?
|
raise "Homebrew/homebrew is not allowed" if tap.core_tap?
|
||||||
tap.uninstall
|
tap.uninstall
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -12,7 +12,7 @@ module Homebrew
|
|||||||
hub = ReporterHub.new
|
hub = ReporterHub.new
|
||||||
|
|
||||||
begin
|
begin
|
||||||
master_reporter = Reporter.new(CoreFormulaRepository.instance)
|
master_reporter = Reporter.new(CoreTap.instance)
|
||||||
rescue Reporter::ReporterRevisionUnsetError => e
|
rescue Reporter::ReporterRevisionUnsetError => e
|
||||||
raise e if ARGV.homebrew_developer?
|
raise e if ARGV.homebrew_developer?
|
||||||
odie "update-report should not be called directly!"
|
odie "update-report should not be called directly!"
|
||||||
@ -125,7 +125,7 @@ class Reporter
|
|||||||
new_name = tap.formula_renames[old_name]
|
new_name = tap.formula_renames[old_name]
|
||||||
next unless new_name
|
next unless new_name
|
||||||
|
|
||||||
if tap.core_formula_repository?
|
if tap.core_tap?
|
||||||
new_full_name = new_name
|
new_full_name = new_name
|
||||||
else
|
else
|
||||||
new_full_name = "#{tap}/#{new_name}"
|
new_full_name = "#{tap}/#{new_name}"
|
||||||
|
@ -1,86 +0,0 @@
|
|||||||
require "tap"
|
|
||||||
require "tap_migrations"
|
|
||||||
require "formula_renames"
|
|
||||||
|
|
||||||
# A specialized {Tap} class to mimic the core formula file system, which shares many
|
|
||||||
# similarities with normal {Tap}.
|
|
||||||
# TODO Separate core formulae with core codes. See discussion below for future plan:
|
|
||||||
# https://github.com/Homebrew/homebrew/pull/46735#discussion_r46820565
|
|
||||||
class CoreFormulaRepository < Tap
|
|
||||||
# @private
|
|
||||||
def initialize
|
|
||||||
@user = "Homebrew"
|
|
||||||
@repo = "homebrew"
|
|
||||||
@name = "Homebrew/homebrew"
|
|
||||||
@path = HOMEBREW_REPOSITORY
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.instance
|
|
||||||
@instance ||= CoreFormulaRepository.new
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
|
||||||
def uninstall
|
|
||||||
raise "Tap#uninstall is not available for CoreFormulaRepository"
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
|
||||||
def pin
|
|
||||||
raise "Tap#pin is not available for CoreFormulaRepository"
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
|
||||||
def unpin
|
|
||||||
raise "Tap#unpin is not available for CoreFormulaRepository"
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
|
||||||
def pinned?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
|
||||||
def command_files
|
|
||||||
[]
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
|
||||||
def custom_remote?
|
|
||||||
remote != "https://github.com/#{user}/#{repo}.git"
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
|
||||||
def core_formula_repository?
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
|
||||||
def formula_dir
|
|
||||||
HOMEBREW_LIBRARY/"Formula"
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
|
||||||
def alias_dir
|
|
||||||
HOMEBREW_LIBRARY/"Aliases"
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
|
||||||
def formula_renames
|
|
||||||
FORMULA_RENAMES
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
|
||||||
def tap_migrations
|
|
||||||
TAP_MIGRATIONS
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
|
||||||
def formula_file_to_name(file)
|
|
||||||
file.basename(".rb").to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
|
||||||
def alias_file_to_name(file)
|
|
||||||
file.basename.to_s
|
|
||||||
end
|
|
||||||
end
|
|
@ -10,7 +10,6 @@ require "software_spec"
|
|||||||
require "install_renamed"
|
require "install_renamed"
|
||||||
require "pkg_version"
|
require "pkg_version"
|
||||||
require "tap"
|
require "tap"
|
||||||
require "core_formula_repository"
|
|
||||||
require "keg"
|
require "keg"
|
||||||
require "migrator"
|
require "migrator"
|
||||||
|
|
||||||
@ -142,7 +141,7 @@ class Formula
|
|||||||
@revision = self.class.revision || 0
|
@revision = self.class.revision || 0
|
||||||
|
|
||||||
if path == Formulary.core_path(name)
|
if path == Formulary.core_path(name)
|
||||||
@tap = CoreFormulaRepository.instance
|
@tap = CoreTap.instance
|
||||||
@full_name = name
|
@full_name = name
|
||||||
elsif path.to_s =~ HOMEBREW_TAP_PATH_REGEX
|
elsif path.to_s =~ HOMEBREW_TAP_PATH_REGEX
|
||||||
@tap = Tap.fetch($1, $2)
|
@tap = Tap.fetch($1, $2)
|
||||||
@ -1062,13 +1061,13 @@ class Formula
|
|||||||
# an array of all core {Formula} names
|
# an array of all core {Formula} names
|
||||||
# @private
|
# @private
|
||||||
def self.core_names
|
def self.core_names
|
||||||
CoreFormulaRepository.instance.formula_names
|
CoreTap.instance.formula_names
|
||||||
end
|
end
|
||||||
|
|
||||||
# an array of all core {Formula} files
|
# an array of all core {Formula} files
|
||||||
# @private
|
# @private
|
||||||
def self.core_files
|
def self.core_files
|
||||||
CoreFormulaRepository.instance.formula_files
|
CoreTap.instance.formula_files
|
||||||
end
|
end
|
||||||
|
|
||||||
# an array of all tap {Formula} names
|
# an array of all tap {Formula} names
|
||||||
@ -1141,13 +1140,13 @@ class Formula
|
|||||||
# an array of all alias files of core {Formula}
|
# an array of all alias files of core {Formula}
|
||||||
# @private
|
# @private
|
||||||
def self.core_alias_files
|
def self.core_alias_files
|
||||||
CoreFormulaRepository.instance.alias_files
|
CoreTap.instance.alias_files
|
||||||
end
|
end
|
||||||
|
|
||||||
# an array of all core aliases
|
# an array of all core aliases
|
||||||
# @private
|
# @private
|
||||||
def self.core_aliases
|
def self.core_aliases
|
||||||
CoreFormulaRepository.instance.aliases
|
CoreTap.instance.aliases
|
||||||
end
|
end
|
||||||
|
|
||||||
# an array of all tap aliases
|
# an array of all tap aliases
|
||||||
@ -1171,13 +1170,13 @@ class Formula
|
|||||||
# a table mapping core alias to formula name
|
# a table mapping core alias to formula name
|
||||||
# @private
|
# @private
|
||||||
def self.core_alias_table
|
def self.core_alias_table
|
||||||
CoreFormulaRepository.instance.alias_table
|
CoreTap.instance.alias_table
|
||||||
end
|
end
|
||||||
|
|
||||||
# a table mapping core formula name to aliases
|
# a table mapping core formula name to aliases
|
||||||
# @private
|
# @private
|
||||||
def self.core_alias_reverse_table
|
def self.core_alias_reverse_table
|
||||||
CoreFormulaRepository.instance.alias_reverse_table
|
CoreTap.instance.alias_reverse_table
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.[](name)
|
def self.[](name)
|
||||||
@ -1187,13 +1186,13 @@ class Formula
|
|||||||
# True if this formula is provided by Homebrew itself
|
# True if this formula is provided by Homebrew itself
|
||||||
# @private
|
# @private
|
||||||
def core_formula?
|
def core_formula?
|
||||||
tap && tap.core_formula_repository?
|
tap && tap.core_tap?
|
||||||
end
|
end
|
||||||
|
|
||||||
# True if this formula is provided by external Tap
|
# True if this formula is provided by external Tap
|
||||||
# @private
|
# @private
|
||||||
def tap?
|
def tap?
|
||||||
tap && !tap.core_formula_repository?
|
tap && !tap.core_tap?
|
||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
require "digest/md5"
|
require "digest/md5"
|
||||||
require "tap"
|
require "tap"
|
||||||
require "core_formula_repository"
|
|
||||||
|
|
||||||
# The Formulary is responsible for creating instances of Formula.
|
# The Formulary is responsible for creating instances of Formula.
|
||||||
# It is not meant to be used directy from formulae.
|
# It is not meant to be used directy from formulae.
|
||||||
@ -278,7 +277,7 @@ class Formulary
|
|||||||
return FormulaLoader.new(ref, formula_with_that_name)
|
return FormulaLoader.new(ref, formula_with_that_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
possible_alias = CoreFormulaRepository.instance.alias_dir/ref
|
possible_alias = CoreTap.instance.alias_dir/ref
|
||||||
if possible_alias.file?
|
if possible_alias.file?
|
||||||
return AliasLoader.new(possible_alias)
|
return AliasLoader.new(possible_alias)
|
||||||
end
|
end
|
||||||
@ -292,7 +291,7 @@ class Formulary
|
|||||||
return FormulaLoader.new(name, path)
|
return FormulaLoader.new(name, path)
|
||||||
end
|
end
|
||||||
|
|
||||||
if newref = CoreFormulaRepository.instance.formula_renames[ref]
|
if newref = CoreTap.instance.formula_renames[ref]
|
||||||
formula_with_that_oldname = core_path(newref)
|
formula_with_that_oldname = core_path(newref)
|
||||||
if formula_with_that_oldname.file?
|
if formula_with_that_oldname.file?
|
||||||
return FormulaLoader.new(newref, formula_with_that_oldname)
|
return FormulaLoader.new(newref, formula_with_that_oldname)
|
||||||
@ -321,7 +320,7 @@ class Formulary
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.core_path(name)
|
def self.core_path(name)
|
||||||
CoreFormulaRepository.instance.formula_dir/"#{name.downcase}.rb"
|
CoreTap.instance.formula_dir/"#{name.downcase}.rb"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.tap_paths(name, taps = Dir["#{HOMEBREW_LIBRARY}/Taps/*/*/"])
|
def self.tap_paths(name, taps = Dir["#{HOMEBREW_LIBRARY}/Taps/*/*/"])
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
require "extend/string"
|
require "extend/string"
|
||||||
|
require "tap_migrations"
|
||||||
|
require "formula_renames"
|
||||||
|
|
||||||
# a {Tap} is used to extend the formulae provided by Homebrew core.
|
# a {Tap} is used to extend the formulae provided by Homebrew core.
|
||||||
# Usually, it's synced with a remote git repository. And it's likely
|
# Usually, it's synced with a remote git repository. And it's likely
|
||||||
@ -31,8 +33,7 @@ class Tap
|
|||||||
repo = repo.strip_prefix "homebrew-"
|
repo = repo.strip_prefix "homebrew-"
|
||||||
|
|
||||||
if user == "Homebrew" && repo == "homebrew"
|
if user == "Homebrew" && repo == "homebrew"
|
||||||
require "core_formula_repository"
|
return CoreTap.instance
|
||||||
return CoreFormulaRepository.instance
|
|
||||||
end
|
end
|
||||||
|
|
||||||
cache_key = "#{user}/#{repo}".downcase
|
cache_key = "#{user}/#{repo}".downcase
|
||||||
@ -159,7 +160,7 @@ class Tap
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def core_formula_repository?
|
def core_tap?
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -444,3 +445,86 @@ class Tap
|
|||||||
"#{name}/#{file.basename}"
|
"#{name}/#{file.basename}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# A specialized {Tap} class to mimic the core formula file system, which shares many
|
||||||
|
# similarities with normal {Tap}.
|
||||||
|
# TODO Separate core formulae with core codes. See discussion below for future plan:
|
||||||
|
# https://github.com/Homebrew/homebrew/pull/46735#discussion_r46820565
|
||||||
|
class CoreTap < Tap
|
||||||
|
# @private
|
||||||
|
def initialize
|
||||||
|
@user = "Homebrew"
|
||||||
|
@repo = "homebrew"
|
||||||
|
@name = "Homebrew/homebrew"
|
||||||
|
@path = HOMEBREW_REPOSITORY
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.instance
|
||||||
|
@instance ||= CoreTap.new
|
||||||
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
def uninstall
|
||||||
|
raise "Tap#uninstall is not available for CoreTap"
|
||||||
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
def pin
|
||||||
|
raise "Tap#pin is not available for CoreTap"
|
||||||
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
def unpin
|
||||||
|
raise "Tap#unpin is not available for CoreTap"
|
||||||
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
def pinned?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
def command_files
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
def custom_remote?
|
||||||
|
remote != "https://github.com/#{user}/#{repo}.git"
|
||||||
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
def core_tap?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
def formula_dir
|
||||||
|
HOMEBREW_LIBRARY/"Formula"
|
||||||
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
def alias_dir
|
||||||
|
HOMEBREW_LIBRARY/"Aliases"
|
||||||
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
def formula_renames
|
||||||
|
FORMULA_RENAMES
|
||||||
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
def tap_migrations
|
||||||
|
TAP_MIGRATIONS
|
||||||
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
def formula_file_to_name(file)
|
||||||
|
file.basename(".rb").to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
def alias_file_to_name(file)
|
||||||
|
file.basename.to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -16,7 +16,7 @@ end
|
|||||||
class FormularyFactoryTest < Homebrew::TestCase
|
class FormularyFactoryTest < Homebrew::TestCase
|
||||||
def setup
|
def setup
|
||||||
@name = "testball_bottle"
|
@name = "testball_bottle"
|
||||||
@path = CoreFormulaRepository.new.formula_dir/"#{@name}.rb"
|
@path = CoreTap.new.formula_dir/"#{@name}.rb"
|
||||||
@bottle_dir = Pathname.new("#{File.expand_path("..", __FILE__)}/bottles")
|
@bottle_dir = Pathname.new("#{File.expand_path("..", __FILE__)}/bottles")
|
||||||
@bottle = @bottle_dir/"testball_bottle-0.1.#{bottle_tag}.bottle.tar.gz"
|
@bottle = @bottle_dir/"testball_bottle-0.1.#{bottle_tag}.bottle.tar.gz"
|
||||||
@path.write <<-EOS.undent
|
@path.write <<-EOS.undent
|
||||||
@ -72,7 +72,7 @@ class FormularyFactoryTest < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_factory_from_alias
|
def test_factory_from_alias
|
||||||
alias_dir = CoreFormulaRepository.instance.alias_dir
|
alias_dir = CoreTap.instance.alias_dir
|
||||||
alias_dir.mkpath
|
alias_dir.mkpath
|
||||||
FileUtils.ln_s @path, alias_dir/"foo"
|
FileUtils.ln_s @path, alias_dir/"foo"
|
||||||
assert_kind_of Formula, Formulary.factory("foo")
|
assert_kind_of Formula, Formulary.factory("foo")
|
||||||
@ -144,7 +144,7 @@ end
|
|||||||
class FormularyTapPriorityTest < Homebrew::TestCase
|
class FormularyTapPriorityTest < Homebrew::TestCase
|
||||||
def setup
|
def setup
|
||||||
@name = "foo"
|
@name = "foo"
|
||||||
@core_path = CoreFormulaRepository.new.formula_dir/"#{@name}.rb"
|
@core_path = CoreTap.new.formula_dir/"#{@name}.rb"
|
||||||
@tap = Tap.new "homebrew", "foo"
|
@tap = Tap.new "homebrew", "foo"
|
||||||
@tap_path = @tap.path/"#{@name}.rb"
|
@tap_path = @tap.path/"#{@name}.rb"
|
||||||
code = <<-EOS.undent
|
code = <<-EOS.undent
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
require "bundler"
|
require "bundler"
|
||||||
require "testing_env"
|
require "testing_env"
|
||||||
require "core_formula_repository"
|
|
||||||
require "fileutils"
|
require "fileutils"
|
||||||
require "pathname"
|
require "pathname"
|
||||||
|
|
||||||
@ -146,7 +145,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
cmd("install", "--build-bottle", testball)
|
cmd("install", "--build-bottle", testball)
|
||||||
assert_match "Formula not from core or any taps",
|
assert_match "Formula not from core or any taps",
|
||||||
cmd_fail("bottle", "--no-revision", testball)
|
cmd_fail("bottle", "--no-revision", testball)
|
||||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
formula_file = CoreTap.new.formula_dir/"testball.rb"
|
||||||
formula_file.write <<-EOS.undent
|
formula_file.write <<-EOS.undent
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
url "https://example.com/testball-0.1.tar.gz"
|
url "https://example.com/testball-0.1.tar.gz"
|
||||||
@ -181,7 +180,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_readall
|
def test_readall
|
||||||
repo = CoreFormulaRepository.new
|
repo = CoreTap.new
|
||||||
formula_file = repo.formula_dir/"foo.rb"
|
formula_file = repo.formula_dir/"foo.rb"
|
||||||
formula_file.write <<-EOS.undent
|
formula_file.write <<-EOS.undent
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
@ -228,7 +227,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_missing
|
def test_missing
|
||||||
repo = CoreFormulaRepository.new
|
repo = CoreTap.new
|
||||||
foo_file = repo.formula_dir/"foo.rb"
|
foo_file = repo.formula_dir/"foo.rb"
|
||||||
foo_file.write <<-EOS.undent
|
foo_file.write <<-EOS.undent
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
@ -271,7 +270,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_cat
|
def test_cat
|
||||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
formula_file = CoreTap.new.formula_dir/"testball.rb"
|
||||||
content = <<-EOS.undent
|
content = <<-EOS.undent
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
url "https://example.com/testball-0.1.tar.gz"
|
url "https://example.com/testball-0.1.tar.gz"
|
||||||
@ -285,7 +284,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_desc
|
def test_desc
|
||||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
formula_file = CoreTap.new.formula_dir/"testball.rb"
|
||||||
formula_file.write <<-EOS.undent
|
formula_file.write <<-EOS.undent
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
desc "Some test"
|
desc "Some test"
|
||||||
@ -300,7 +299,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
|
|
||||||
def test_edit
|
def test_edit
|
||||||
(HOMEBREW_REPOSITORY/".git").mkpath
|
(HOMEBREW_REPOSITORY/".git").mkpath
|
||||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
formula_file = CoreTap.new.formula_dir/"testball.rb"
|
||||||
formula_file.write <<-EOS.undent
|
formula_file.write <<-EOS.undent
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
url "https://example.com/testball-0.1.tar.gz"
|
url "https://example.com/testball-0.1.tar.gz"
|
||||||
@ -321,7 +320,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_info
|
def test_info
|
||||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
formula_file = CoreTap.new.formula_dir/"testball.rb"
|
||||||
formula_file.write <<-EOS.undent
|
formula_file.write <<-EOS.undent
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
url "https://example.com/testball-0.1.tar.gz"
|
url "https://example.com/testball-0.1.tar.gz"
|
||||||
@ -345,7 +344,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_unpack
|
def test_unpack
|
||||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
formula_file = CoreTap.new.formula_dir/"testball.rb"
|
||||||
formula_file.write <<-EOS.undent
|
formula_file.write <<-EOS.undent
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
||||||
@ -363,7 +362,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_options
|
def test_options
|
||||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
formula_file = CoreTap.new.formula_dir/"testball.rb"
|
||||||
formula_file.write <<-EOS.undent
|
formula_file.write <<-EOS.undent
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
||||||
@ -379,7 +378,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_outdated
|
def test_outdated
|
||||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
formula_file = CoreTap.new.formula_dir/"testball.rb"
|
||||||
formula_file.write <<-EOS.undent
|
formula_file.write <<-EOS.undent
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
||||||
@ -394,7 +393,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_upgrade
|
def test_upgrade
|
||||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
formula_file = CoreTap.new.formula_dir/"testball.rb"
|
||||||
formula_file.write <<-EOS.undent
|
formula_file.write <<-EOS.undent
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
||||||
@ -422,7 +421,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
apps_dir = Pathname.new(home).join("Applications")
|
apps_dir = Pathname.new(home).join("Applications")
|
||||||
apps_dir.mkpath
|
apps_dir.mkpath
|
||||||
|
|
||||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
formula_file = CoreTap.new.formula_dir/"testball.rb"
|
||||||
formula_file.write <<-EOS.undent
|
formula_file.write <<-EOS.undent
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
url "https://example.com/testball-0.1.tar.gz"
|
url "https://example.com/testball-0.1.tar.gz"
|
||||||
@ -444,7 +443,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
apps_dir = Pathname.new(home).join("Applications")
|
apps_dir = Pathname.new(home).join("Applications")
|
||||||
apps_dir.mkpath
|
apps_dir.mkpath
|
||||||
|
|
||||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
formula_file = CoreTap.new.formula_dir/"testball.rb"
|
||||||
formula_file.write <<-EOS.undent
|
formula_file.write <<-EOS.undent
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
url "https://example.com/testball-0.1.tar.gz"
|
url "https://example.com/testball-0.1.tar.gz"
|
||||||
@ -465,7 +464,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_pin_unpin
|
def test_pin_unpin
|
||||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
formula_file = CoreTap.new.formula_dir/"testball.rb"
|
||||||
formula_file.write <<-EOS.undent
|
formula_file.write <<-EOS.undent
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
||||||
@ -494,7 +493,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_reinstall
|
def test_reinstall
|
||||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
formula_file = CoreTap.new.formula_dir/"testball.rb"
|
||||||
formula_file.write <<-EOS.undent
|
formula_file.write <<-EOS.undent
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
||||||
@ -545,7 +544,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
url = "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
url = "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
||||||
cmd("create", url, {"HOMEBREW_EDITOR" => "/bin/cat"})
|
cmd("create", url, {"HOMEBREW_EDITOR" => "/bin/cat"})
|
||||||
|
|
||||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
formula_file = CoreTap.new.formula_dir/"testball.rb"
|
||||||
assert formula_file.exist?, "The formula source should have been created"
|
assert formula_file.exist?, "The formula source should have been created"
|
||||||
assert_match %(sha256 "#{TESTBALL_SHA256}"), formula_file.read
|
assert_match %(sha256 "#{TESTBALL_SHA256}"), formula_file.read
|
||||||
ensure
|
ensure
|
||||||
@ -554,7 +553,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_fetch
|
def test_fetch
|
||||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
formula_file = CoreTap.new.formula_dir/"testball.rb"
|
||||||
formula_file.write <<-EOS.undent
|
formula_file.write <<-EOS.undent
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
||||||
@ -571,7 +570,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_deps
|
def test_deps
|
||||||
formula_dir = CoreFormulaRepository.new.formula_dir
|
formula_dir = CoreTap.new.formula_dir
|
||||||
formula_file1 = formula_dir/"testball1.rb"
|
formula_file1 = formula_dir/"testball1.rb"
|
||||||
formula_file2 = formula_dir/"testball2.rb"
|
formula_file2 = formula_dir/"testball2.rb"
|
||||||
formula_file3 = formula_dir/"testball3.rb"
|
formula_file3 = formula_dir/"testball3.rb"
|
||||||
@ -604,7 +603,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_uses
|
def test_uses
|
||||||
formula_dir = CoreFormulaRepository.new.formula_dir
|
formula_dir = CoreTap.new.formula_dir
|
||||||
formula_file1 = formula_dir/"testball1.rb"
|
formula_file1 = formula_dir/"testball1.rb"
|
||||||
formula_file2 = formula_dir/"testball2.rb"
|
formula_file2 = formula_dir/"testball2.rb"
|
||||||
formula_file3 = formula_dir/"testball3.rb"
|
formula_file3 = formula_dir/"testball3.rb"
|
||||||
@ -648,7 +647,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_leaves
|
def test_leaves
|
||||||
formula_dir = CoreFormulaRepository.new.formula_dir
|
formula_dir = CoreTap.new.formula_dir
|
||||||
formula_file1 = formula_dir/"testball1.rb"
|
formula_file1 = formula_dir/"testball1.rb"
|
||||||
formula_file2 = formula_dir/"testball2.rb"
|
formula_file2 = formula_dir/"testball2.rb"
|
||||||
formula_file1.write <<-EOS.undent
|
formula_file1.write <<-EOS.undent
|
||||||
|
@ -59,7 +59,7 @@ class TapTest < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_fetch
|
def test_fetch
|
||||||
assert_kind_of CoreFormulaRepository, Tap.fetch("Homebrew", "homebrew")
|
assert_kind_of CoreTap, Tap.fetch("Homebrew", "homebrew")
|
||||||
tap = Tap.fetch("Homebrew", "foo")
|
tap = Tap.fetch("Homebrew", "foo")
|
||||||
assert_kind_of Tap, tap
|
assert_kind_of Tap, tap
|
||||||
assert_equal "homebrew/foo", tap.name
|
assert_equal "homebrew/foo", tap.name
|
||||||
@ -78,7 +78,7 @@ class TapTest < Homebrew::TestCase
|
|||||||
assert_equal @path, @tap.path
|
assert_equal @path, @tap.path
|
||||||
assert_predicate @tap, :installed?
|
assert_predicate @tap, :installed?
|
||||||
assert_predicate @tap, :official?
|
assert_predicate @tap, :official?
|
||||||
refute_predicate @tap, :core_formula_repository?
|
refute_predicate @tap, :core_tap?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_issues_url
|
def test_issues_url
|
||||||
@ -204,11 +204,11 @@ class TapTest < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class CoreFormulaRepositoryTest < Homebrew::TestCase
|
class CoreTapTest < Homebrew::TestCase
|
||||||
include FileUtils
|
include FileUtils
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@repo = CoreFormulaRepository.new
|
@repo = CoreTap.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_attributes
|
def test_attributes
|
||||||
@ -219,7 +219,7 @@ class CoreFormulaRepositoryTest < Homebrew::TestCase
|
|||||||
assert_predicate @repo, :installed?
|
assert_predicate @repo, :installed?
|
||||||
refute_predicate @repo, :pinned?
|
refute_predicate @repo, :pinned?
|
||||||
assert_predicate @repo, :official?
|
assert_predicate @repo, :official?
|
||||||
assert_predicate @repo, :core_formula_repository?
|
assert_predicate @repo, :core_tap?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_forbidden_operations
|
def test_forbidden_operations
|
||||||
|
@ -24,7 +24,7 @@ class ReportTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@tap = CoreFormulaRepository.new
|
@tap = CoreTap.new
|
||||||
@reporter = ReporterMock.new(@tap, "12345678", "abcdef12")
|
@reporter = ReporterMock.new(@tap, "12345678", "abcdef12")
|
||||||
@hub = ReporterHub.new
|
@hub = ReporterHub.new
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user