Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up compat. #4186

Merged
merged 2 commits into from
May 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions Library/Homebrew/compat/ENV/shared.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
module SharedEnvExtension
def j1
odisabled "ENV.j1", "ENV.deparallelize"
end
module Compat
def j1
odisabled "ENV.j1", "ENV.deparallelize"
end

def java_cache
odisabled "ENV.java_cache"
def java_cache
odisabled "ENV.java_cache"
end
end

prepend Compat
end
10 changes: 7 additions & 3 deletions Library/Homebrew/compat/dependable.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module Dependable
def run?
odeprecated "Dependable#run?"
tags.include? :run
module Compat
def run?
odeprecated "Dependable#run?"
tags.include? :run
end
end

prepend Compat
end
34 changes: 19 additions & 15 deletions Library/Homebrew/compat/extend/string.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
class String
def undent
odisabled "<<-EOS.undent", "<<~EOS"
self
module Compat
def undent
odisabled "<<-EOS.undent", "<<~EOS"
self
end
alias unindent undent

# eg:
# if foo then <<-EOS.undent_________________________________________________________72
# Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
# eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
# minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
# ex ea commodo consequat. Duis aute irure dolor in reprehenderit in
# voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
# sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
# mollit anim id est laborum.
# EOS
alias undent_________________________________________________________72 undent
end
alias unindent undent

# eg:
# if foo then <<-EOS.undent_________________________________________________________72
# Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
# eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
# minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
# ex ea commodo consequat. Duis aute irure dolor in reprehenderit in
# voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
# sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
# mollit anim id est laborum.
# EOS
alias undent_________________________________________________________72 undent
prepend Compat
end
8 changes: 6 additions & 2 deletions Library/Homebrew/compat/formula.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
class Formula
def rake(*)
odisabled "FileUtils#rake", "system \"rake\""
module Compat
def rake(*)
odisabled "FileUtils#rake", "system \"rake\""
end
end

prepend Compat
end
35 changes: 19 additions & 16 deletions Library/Homebrew/compat/gpg.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@

module Gpg
module_function
class << self
module Compat
def executable
odisabled "Gpg.executable", 'which "gpg"'
end

def executable
odisabled "Gpg.executable", 'which "gpg"'
end
def available?
odisabled "Gpg.available?", 'which "gpg"'
end

def available?
odisabled "Gpg.available?", 'which "gpg"'
end
def create_test_key(*)
odisabled "Gpg.create_test_key"
end

def create_test_key(_)
odisabled "Gpg.create_test_key"
end
def cleanup_test_processes!
odisabled "Gpg.cleanup_test_processes!"
end

def cleanup_test_processes!
odisabled "Gpg.cleanup_test_processes!"
end
def test(*)
odisabled "Gpg.test"
end
end

def test(_)
odisabled "Gpg.test"
prepend Compat
end
end
20 changes: 10 additions & 10 deletions Library/Homebrew/compat/hbc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@

module Hbc
class << self
prepend(
Module.new do
def init
Cache.delete_legacy_cache
module Compat
def init
Cache.delete_legacy_cache

Caskroom.migrate_caskroom_from_repo_to_prefix
Caskroom.migrate_legacy_caskroom
Caskroom.migrate_caskroom_from_repo_to_prefix
Caskroom.migrate_legacy_caskroom

super
end
end,
)
super
end
end

prepend Compat
end
end
16 changes: 10 additions & 6 deletions Library/Homebrew/compat/hbc/cache.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
module Hbc
module Cache
module_function
class << self
module Compat
def delete_legacy_cache
legacy_cache = HOMEBREW_CACHE.join("Casks")
return unless legacy_cache.exist?

def delete_legacy_cache
legacy_cache = HOMEBREW_CACHE.join("Casks")
return unless legacy_cache.exist?
ohai "Deleting legacy cache at #{legacy_cache}"
FileUtils.remove_entry_secure(legacy_cache)
end
end

ohai "Deleting legacy cache at #{legacy_cache}"
FileUtils.remove_entry_secure(legacy_cache)
prepend Compat
end
end
end
28 changes: 14 additions & 14 deletions Library/Homebrew/compat/hbc/cask_loader.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
module CaskLoaderCompatibilityLayer
private

def cask(header_token, **options, &block)
if header_token.is_a?(Hash) && header_token.key?(:v1)
odeprecated %q("cask :v1 => 'token'"), %q("cask 'token'")
header_token = header_token[:v1]
end

super(header_token, **options, &block)
end
end

module Hbc
module CaskLoader
class FromContentLoader; end

class FromPathLoader < FromContentLoader
prepend CaskLoaderCompatibilityLayer
module Compat
private

def cask(header_token, **options, &block)
if header_token.is_a?(Hash) && header_token.key?(:v1)
odeprecated %q("cask :v1 => 'token'"), %q("cask 'token'")
header_token = header_token[:v1]
end

super(header_token, **options, &block)
end
end

prepend Compat
end
end
end
70 changes: 37 additions & 33 deletions Library/Homebrew/compat/hbc/caskroom.rb
Original file line number Diff line number Diff line change
@@ -1,45 +1,49 @@
module Hbc
module Caskroom
module_function
class << self
module Compat
def migrate_legacy_caskroom
return if Hbc.caskroom.exist?

def migrate_legacy_caskroom
return if Hbc.caskroom.exist?
legacy_caskroom = Pathname.new("/opt/homebrew-cask/Caskroom")
return if Hbc.caskroom == legacy_caskroom
return unless legacy_caskroom.exist?
return if legacy_caskroom.symlink?

legacy_caskroom = Pathname.new("/opt/homebrew-cask/Caskroom")
return if Hbc.caskroom == legacy_caskroom
return unless legacy_caskroom.exist?
return if legacy_caskroom.symlink?
ohai "Migrating Caskroom from #{legacy_caskroom} to #{Hbc.caskroom}."
if Hbc.caskroom.parent.writable?
FileUtils.mv legacy_caskroom, Hbc.caskroom
else
opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom."
SystemCommand.run("/bin/mv", args: [legacy_caskroom, Hbc.caskroom.parent], sudo: true)
end

ohai "Migrating Caskroom from #{legacy_caskroom} to #{Hbc.caskroom}."
if Hbc.caskroom.parent.writable?
FileUtils.mv legacy_caskroom, Hbc.caskroom
else
opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom."
SystemCommand.run("/bin/mv", args: [legacy_caskroom, Hbc.caskroom.parent], sudo: true)
end
ohai "Creating symlink from #{Hbc.caskroom} to #{legacy_caskroom}."
if legacy_caskroom.parent.writable?
FileUtils.ln_s Hbc.caskroom, legacy_caskroom
else
opoo "#{legacy_caskroom.parent} is not writable, sudo is needed to link the Caskroom."
SystemCommand.run("/bin/ln", args: ["-s", Hbc.caskroom, legacy_caskroom], sudo: true)
end
end

ohai "Creating symlink from #{Hbc.caskroom} to #{legacy_caskroom}."
if legacy_caskroom.parent.writable?
FileUtils.ln_s Hbc.caskroom, legacy_caskroom
else
opoo "#{legacy_caskroom.parent} is not writable, sudo is needed to link the Caskroom."
SystemCommand.run("/bin/ln", args: ["-s", Hbc.caskroom, legacy_caskroom], sudo: true)
end
end
def migrate_caskroom_from_repo_to_prefix
repo_caskroom = HOMEBREW_REPOSITORY.join("Caskroom")
return if Hbc.caskroom.exist?
return unless repo_caskroom.directory?

def migrate_caskroom_from_repo_to_prefix
repo_caskroom = HOMEBREW_REPOSITORY.join("Caskroom")
return if Hbc.caskroom.exist?
return unless repo_caskroom.directory?
ohai "Moving Caskroom from HOMEBREW_REPOSITORY to HOMEBREW_PREFIX"

ohai "Moving Caskroom from HOMEBREW_REPOSITORY to HOMEBREW_PREFIX"

if Hbc.caskroom.parent.writable?
FileUtils.mv repo_caskroom, Hbc.caskroom
else
opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom."
SystemCommand.run("/bin/mv", args: [repo_caskroom, Hbc.caskroom.parent], sudo: true)
if Hbc.caskroom.parent.writable?
FileUtils.mv repo_caskroom, Hbc.caskroom
else
opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom."
SystemCommand.run("/bin/mv", args: [repo_caskroom, Hbc.caskroom.parent], sudo: true)
end
end
end

prepend Compat
end
end
end
24 changes: 10 additions & 14 deletions Library/Homebrew/compat/hbc/cli/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@

module Hbc
class CLI
class Update < AbstractCommand
def self.run(*_ignored)
odeprecated "`brew cask update`", "`brew update`", disable_on: Time.utc(2017, 7, 1)
result = SystemCommand.run(HOMEBREW_BREW_FILE, args: ["update"],
print_stderr: true,
print_stdout: true)
exit result.exit_status
end

def self.visible
false
end
module Compat
class Update < AbstractCommand
def self.run(*_ignored)
odisabled "`brew cask update`", "`brew update`"
end

def self.help
"a synonym for 'brew update'"
def self.visible
false
end
end
end

prepend Compat
end
end
8 changes: 6 additions & 2 deletions Library/Homebrew/compat/hbc/dsl.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
module Hbc
class DSL
def license(*)
odeprecated "Hbc::DSL#license"
module Compat
def license(*)
odeprecated "Hbc::DSL#license"
end
end

prepend Compat
end
end
10 changes: 7 additions & 3 deletions Library/Homebrew/compat/os/mac.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
module OS
module Mac
class << self
def release
odeprecated "MacOS.release", "MacOS.version"
version
module Compat
def release
odeprecated "MacOS.release", "MacOS.version"
version
end
end

prepend Compat
end
end
end
4 changes: 2 additions & 2 deletions Library/Homebrew/test/cask/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
end
end

it "provides a help message for all commands" do
described_class.command_classes.each do |command_class|
it "provides a help message for all visible commands" do
described_class.command_classes.select(&:visible).each do |command_class|
expect(command_class.help).to match(/\w+/), command_class.name
end
end
Expand Down