mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
move CoreFormulaRepository into separate file
For users whose local brew is at around 2015-06-11 to 2015-08-06, running `brew update` will emit following error: Error: uninitialized constant Formulary::CoreFormulaRepository This is caused by the same bug described in Homebrew/homebrew#42553. This commit workarounds this issue and restores `brew update` compatibility for users mentioned above. Also cleanup legacy `require "cmd/tap"`.
This commit is contained in:
parent
f72d4f1722
commit
0f84b976ba
@ -1,8 +1,9 @@
|
|||||||
require "blacklist"
|
require "blacklist"
|
||||||
require "cmd/doctor"
|
require "cmd/doctor"
|
||||||
require "cmd/search"
|
require "cmd/search"
|
||||||
require "cmd/tap"
|
|
||||||
require "formula_installer"
|
require "formula_installer"
|
||||||
|
require "tap"
|
||||||
|
require "core_formula_repository"
|
||||||
require "hardware"
|
require "hardware"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
require "utils"
|
require "utils"
|
||||||
require "formula"
|
require "formula"
|
||||||
require "cmd/tap"
|
require "tap"
|
||||||
|
require "core_formula_repository"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
def pull_url(url)
|
def pull_url(url)
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
# or to determine if any current formulae have Ruby issues
|
# or to determine if any current formulae have Ruby issues
|
||||||
|
|
||||||
require "formula"
|
require "formula"
|
||||||
require "cmd/tap"
|
require "tap"
|
||||||
|
require "core_formula_repository"
|
||||||
require "thread"
|
require "thread"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
require "tap"
|
require "tap"
|
||||||
|
require "core_formula_repository"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
def tap
|
def tap
|
||||||
|
@ -29,7 +29,8 @@ require "date"
|
|||||||
require "rexml/document"
|
require "rexml/document"
|
||||||
require "rexml/xmldecl"
|
require "rexml/xmldecl"
|
||||||
require "rexml/cdata"
|
require "rexml/cdata"
|
||||||
require "cmd/tap"
|
require "tap"
|
||||||
|
require "core_formula_repository"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
BYTES_IN_1_MEGABYTE = 1024*1024
|
BYTES_IN_1_MEGABYTE = 1024*1024
|
||||||
|
80
Library/Homebrew/core_formula_repository.rb
Normal file
80
Library/Homebrew/core_formula_repository.rb
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
require "tap"
|
||||||
|
|
||||||
|
# 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
|
||||||
|
require "formula_renames"
|
||||||
|
FORMULA_RENAMES
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def formula_file_to_name(file)
|
||||||
|
file.basename(".rb").to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
def alias_file_to_name(file)
|
||||||
|
file.basename.to_s
|
||||||
|
end
|
||||||
|
end
|
@ -10,6 +10,7 @@ require "software_spec"
|
|||||||
require "install_renamed"
|
require "install_renamed"
|
||||||
require "pkg_version"
|
require "pkg_version"
|
||||||
require "tap"
|
require "tap"
|
||||||
|
require "core_formula_repository"
|
||||||
require "formula_renames"
|
require "formula_renames"
|
||||||
require "keg"
|
require "keg"
|
||||||
require "migrator"
|
require "migrator"
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
require "digest/md5"
|
require "digest/md5"
|
||||||
require "formula_renames"
|
require "formula_renames"
|
||||||
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.
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
require "utils/json"
|
|
||||||
require "descriptions"
|
|
||||||
|
|
||||||
# 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
|
||||||
# a Github repository with the name of `user/homebrew-repo`. In such
|
# a Github repository with the name of `user/homebrew-repo`. In such
|
||||||
@ -32,6 +29,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 CoreFormulaRepository.instance
|
return CoreFormulaRepository.instance
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -119,6 +117,7 @@ class Tap
|
|||||||
# @option options [String] :clone_targe If passed, it will be used as the clone remote.
|
# @option options [String] :clone_targe If passed, it will be used as the clone remote.
|
||||||
# @option options [Boolean] :full_clone If set as true, full clone will be used.
|
# @option options [Boolean] :full_clone If set as true, full clone will be used.
|
||||||
def install(options = {})
|
def install(options = {})
|
||||||
|
require "descriptions"
|
||||||
raise TapAlreadyTappedError, name if installed?
|
raise TapAlreadyTappedError, name if installed?
|
||||||
|
|
||||||
# ensure git is installed
|
# ensure git is installed
|
||||||
@ -180,6 +179,7 @@ class Tap
|
|||||||
|
|
||||||
# uninstall this {Tap}.
|
# uninstall this {Tap}.
|
||||||
def uninstall
|
def uninstall
|
||||||
|
require "descriptions"
|
||||||
raise TapUnavailableError, name unless installed?
|
raise TapUnavailableError, name unless installed?
|
||||||
|
|
||||||
puts "Untapping #{name}... (#{path.abv})"
|
puts "Untapping #{name}... (#{path.abv})"
|
||||||
@ -326,6 +326,8 @@ class Tap
|
|||||||
|
|
||||||
# Hash with tap formula renames
|
# Hash with tap formula renames
|
||||||
def formula_renames
|
def formula_renames
|
||||||
|
require "utils/json"
|
||||||
|
|
||||||
@formula_renames ||= if (rename_file = path/"formula_renames.json").file?
|
@formula_renames ||= if (rename_file = path/"formula_renames.json").file?
|
||||||
Utils::JSON.load(rename_file.read)
|
Utils::JSON.load(rename_file.read)
|
||||||
else
|
else
|
||||||
@ -363,82 +365,3 @@ 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 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
|
|
||||||
require "formula_renames"
|
|
||||||
FORMULA_RENAMES
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def formula_file_to_name(file)
|
|
||||||
file.basename(".rb").to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
def alias_file_to_name(file)
|
|
||||||
file.basename.to_s
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user