diff options
| author | Xu Cheng | 2015-12-19 19:10:22 +0800 |
|---|---|---|
| committer | Xu Cheng | 2015-12-19 22:05:30 +0800 |
| commit | 0f84b976bab94d66af1f8eb658b5ca824f8d49d4 (patch) | |
| tree | 88c69232faf9d12f559b87249addad517df19fa9 /Library | |
| parent | f72d4f17221e2c313e7076ac0b7b79c0a76018dd (diff) | |
| download | brew-0f84b976bab94d66af1f8eb658b5ca824f8d49d4.tar.bz2 | |
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"`.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cmd/install.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/pull.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/readall.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/tap.rb | 1 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/test-bot.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/core_formula_repository.rb | 80 | ||||
| -rw-r--r-- | Library/Homebrew/formula.rb | 1 | ||||
| -rw-r--r-- | Library/Homebrew/formulary.rb | 1 | ||||
| -rw-r--r-- | Library/Homebrew/tap.rb | 87 |
9 files changed, 96 insertions, 86 deletions
diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 4eb6f1660..dbd8f5c04 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -1,8 +1,9 @@ require "blacklist" require "cmd/doctor" require "cmd/search" -require "cmd/tap" require "formula_installer" +require "tap" +require "core_formula_repository" require "hardware" module Homebrew diff --git a/Library/Homebrew/cmd/pull.rb b/Library/Homebrew/cmd/pull.rb index bcfcb7d11..1454f9938 100644 --- a/Library/Homebrew/cmd/pull.rb +++ b/Library/Homebrew/cmd/pull.rb @@ -3,7 +3,8 @@ require "utils" require "formula" -require "cmd/tap" +require "tap" +require "core_formula_repository" module Homebrew def pull_url(url) diff --git a/Library/Homebrew/cmd/readall.rb b/Library/Homebrew/cmd/readall.rb index 4d74a6f41..7775c2923 100644 --- a/Library/Homebrew/cmd/readall.rb +++ b/Library/Homebrew/cmd/readall.rb @@ -4,7 +4,8 @@ # or to determine if any current formulae have Ruby issues require "formula" -require "cmd/tap" +require "tap" +require "core_formula_repository" require "thread" module Homebrew diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb index a7fd3f500..5c1ff089c 100644 --- a/Library/Homebrew/cmd/tap.rb +++ b/Library/Homebrew/cmd/tap.rb @@ -1,4 +1,5 @@ require "tap" +require "core_formula_repository" module Homebrew def tap diff --git a/Library/Homebrew/cmd/test-bot.rb b/Library/Homebrew/cmd/test-bot.rb index b6b167f3f..b297c71d8 100644 --- a/Library/Homebrew/cmd/test-bot.rb +++ b/Library/Homebrew/cmd/test-bot.rb @@ -29,7 +29,8 @@ require "date" require "rexml/document" require "rexml/xmldecl" require "rexml/cdata" -require "cmd/tap" +require "tap" +require "core_formula_repository" module Homebrew BYTES_IN_1_MEGABYTE = 1024*1024 diff --git a/Library/Homebrew/core_formula_repository.rb b/Library/Homebrew/core_formula_repository.rb new file mode 100644 index 000000000..0c9994327 --- /dev/null +++ b/Library/Homebrew/core_formula_repository.rb @@ -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 diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index d7e5ffc49..68c836f2b 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -10,6 +10,7 @@ require "software_spec" require "install_renamed" require "pkg_version" require "tap" +require "core_formula_repository" require "formula_renames" require "keg" require "migrator" diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index e71656224..56f221f33 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -1,6 +1,7 @@ require "digest/md5" require "formula_renames" require "tap" +require "core_formula_repository" # The Formulary is responsible for creating instances of Formula. # It is not meant to be used directy from formulae. diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 03b702569..59a4429a1 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -1,6 +1,3 @@ -require "utils/json" -require "descriptions" - # 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 # a Github repository with the name of `user/homebrew-repo`. In such @@ -32,6 +29,7 @@ class Tap repo = repo.strip_prefix "homebrew-" if user == "Homebrew" && repo == "homebrew" + require "core_formula_repository" return CoreFormulaRepository.instance end @@ -119,6 +117,7 @@ class Tap # @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. def install(options = {}) + require "descriptions" raise TapAlreadyTappedError, name if installed? # ensure git is installed @@ -180,6 +179,7 @@ class Tap # uninstall this {Tap}. def uninstall + require "descriptions" raise TapUnavailableError, name unless installed? puts "Untapping #{name}... (#{path.abv})" @@ -326,6 +326,8 @@ class Tap # Hash with tap formula renames def formula_renames + require "utils/json" + @formula_renames ||= if (rename_file = path/"formula_renames.json").file? Utils::JSON.load(rename_file.read) else @@ -363,82 +365,3 @@ class Tap "#{name}/#{file.basename}" 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 |
