Merge pull request #4174 from reitermarkus/cask-tap-migration
Add compatibility layer for handling Cask Tap migration.
This commit is contained in:
commit
5c3ec3e7ca
@ -60,7 +60,8 @@ module Hbc
|
||||
return if @cask.sourcefile_path.nil?
|
||||
|
||||
tap = @cask.tap
|
||||
return if tap.nil? || tap.user != "caskroom"
|
||||
return if tap.nil?
|
||||
return unless ["Homebrew", "caskroom"].include?(tap.user)
|
||||
|
||||
return unless cask.artifacts.any? { |k| k.is_a?(Hbc::Artifact::Pkg) && k.stanza_options.key?(:allow_untrusted) }
|
||||
add_warning "allow_untrusted is not permitted in official Homebrew-Cask taps"
|
||||
|
||||
@ -21,7 +21,7 @@ module Hbc
|
||||
def self.search_remote(query)
|
||||
matches = begin
|
||||
GitHub.search_code(
|
||||
user: "caskroom",
|
||||
user: ["Homebrew", "caskroom"],
|
||||
path: "Casks",
|
||||
filename: query,
|
||||
extension: "rb",
|
||||
|
||||
@ -3,7 +3,7 @@ module Hbc
|
||||
@full_version ||= begin
|
||||
<<~EOS
|
||||
Homebrew-Cask #{HOMEBREW_VERSION}
|
||||
caskroom/homebrew-cask #{Hbc.default_tap.version_string}
|
||||
#{Hbc.default_tap.full_name} #{Hbc.default_tap.version_string}
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
||||
@ -470,7 +470,7 @@ class Reporter
|
||||
next unless tabs.first.tap == tap # skip if installed formula is not from this tap.
|
||||
new_tap = Tap.fetch(new_tap_name)
|
||||
# For formulae migrated to cask: Auto-install cask or provide install instructions.
|
||||
if new_tap_name == "caskroom/cask"
|
||||
if ["homebrew/cask", "caskroom/cask"].include?(new_tap_name)
|
||||
if new_tap.installed? && (HOMEBREW_PREFIX/"Caskroom").directory?
|
||||
ohai "#{name} has been moved to Homebrew-Cask."
|
||||
ohai "brew unlink #{name}"
|
||||
|
||||
@ -9,3 +9,4 @@ require "compat/extend/string"
|
||||
require "compat/gpg"
|
||||
require "compat/dependable"
|
||||
require "compat/os/mac"
|
||||
require "compat/tap"
|
||||
|
||||
38
Library/Homebrew/compat/tap.rb
Normal file
38
Library/Homebrew/compat/tap.rb
Normal file
@ -0,0 +1,38 @@
|
||||
class Tap
|
||||
module Compat
|
||||
def initialize(user, repo)
|
||||
super
|
||||
|
||||
return unless user == "caskroom"
|
||||
|
||||
# TODO: Remove this check after migration.
|
||||
return unless repo == "tap-migration-test"
|
||||
|
||||
new_user = "Homebrew"
|
||||
new_repo = (repo == "cask") ? repo : "cask-#{repo}"
|
||||
|
||||
old_name = name
|
||||
old_path = path
|
||||
old_remote = path.git_origin
|
||||
|
||||
super(new_user, new_repo)
|
||||
|
||||
return unless old_path.git?
|
||||
|
||||
new_name = name
|
||||
new_path = path
|
||||
new_remote = default_remote
|
||||
|
||||
ohai "Migrating tap #{old_name} to #{new_name}..." if $stdout.tty?
|
||||
|
||||
puts "Moving #{old_path} to #{new_path}..." if $stdout.tty?
|
||||
path.dirname.mkpath
|
||||
FileUtils.mv old_path, new_path
|
||||
|
||||
puts "Changing remote from #{old_remote} to #{new_remote}..." if $stdout.tty?
|
||||
new_path.git_origin = new_remote
|
||||
end
|
||||
end
|
||||
|
||||
prepend Compat
|
||||
end
|
||||
@ -13,6 +13,13 @@ module GitRepositoryExtension
|
||||
end
|
||||
end
|
||||
|
||||
def git_origin=(origin)
|
||||
return unless git? && Utils.git_available?
|
||||
cd do
|
||||
safe_system "git", "remote", "set-url", "origin", origin
|
||||
end
|
||||
end
|
||||
|
||||
def git_head
|
||||
return unless git? && Utils.git_available?
|
||||
cd do
|
||||
|
||||
@ -101,7 +101,7 @@ module Homebrew
|
||||
EOS
|
||||
break if new_tap_name == CoreTap.instance.name
|
||||
|
||||
install_cmd = if new_tap_user == "caskroom"
|
||||
install_cmd = if new_tap_user == "caskroom" || (new_tap_user == "homebrew" && new_tap_repo.start_with?("cask"))
|
||||
"cask install"
|
||||
else
|
||||
"install"
|
||||
|
||||
@ -12,7 +12,7 @@ describe Hbc::CLI::Info, :cask do
|
||||
local-caffeine: 1.2.3
|
||||
http://example.com/local-caffeine
|
||||
Not installed
|
||||
From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-caffeine.rb
|
||||
From: https://github.com/Homebrew/homebrew-cask-spec/blob/master/Casks/local-caffeine.rb
|
||||
==> Name
|
||||
None
|
||||
==> Artifacts
|
||||
@ -26,7 +26,7 @@ describe Hbc::CLI::Info, :cask do
|
||||
local-caffeine: 1.2.3
|
||||
http://example.com/local-caffeine
|
||||
Not installed
|
||||
From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-caffeine.rb
|
||||
From: https://github.com/Homebrew/homebrew-cask-spec/blob/master/Casks/local-caffeine.rb
|
||||
==> Name
|
||||
None
|
||||
==> Artifacts
|
||||
@ -34,7 +34,7 @@ describe Hbc::CLI::Info, :cask do
|
||||
local-transmission: 2.61
|
||||
http://example.com/local-transmission
|
||||
Not installed
|
||||
From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-transmission.rb
|
||||
From: https://github.com/Homebrew/homebrew-cask-spec/blob/master/Casks/local-transmission.rb
|
||||
==> Name
|
||||
None
|
||||
==> Artifacts
|
||||
@ -56,7 +56,7 @@ describe Hbc::CLI::Info, :cask do
|
||||
with-caveats: 1.2.3
|
||||
http://example.com/local-caffeine
|
||||
Not installed
|
||||
From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-caveats.rb
|
||||
From: https://github.com/Homebrew/homebrew-cask-spec/blob/master/Casks/with-caveats.rb
|
||||
==> Name
|
||||
None
|
||||
==> Artifacts
|
||||
@ -82,7 +82,7 @@ describe Hbc::CLI::Info, :cask do
|
||||
with-conditional-caveats: 1.2.3
|
||||
http://example.com/local-caffeine
|
||||
Not installed
|
||||
From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-conditional-caveats.rb
|
||||
From: https://github.com/Homebrew/homebrew-cask-spec/blob/master/Casks/with-conditional-caveats.rb
|
||||
==> Name
|
||||
None
|
||||
==> Artifacts
|
||||
@ -97,7 +97,7 @@ describe Hbc::CLI::Info, :cask do
|
||||
with-languages: 1.2.3
|
||||
http://example.com/local-caffeine
|
||||
Not installed
|
||||
From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-languages.rb
|
||||
From: https://github.com/Homebrew/homebrew-cask-spec/blob/master/Casks/with-languages.rb
|
||||
==> Name
|
||||
None
|
||||
==> Languages
|
||||
@ -114,7 +114,7 @@ describe Hbc::CLI::Info, :cask do
|
||||
without-languages: 1.2.3
|
||||
http://example.com/local-caffeine
|
||||
Not installed
|
||||
From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/without-languages.rb
|
||||
From: https://github.com/Homebrew/homebrew-cask-spec/blob/master/Casks/without-languages.rb
|
||||
==> Name
|
||||
None
|
||||
==> Artifacts
|
||||
|
||||
@ -89,7 +89,7 @@ describe Hbc::CLI::Style, :cask do
|
||||
end
|
||||
end
|
||||
|
||||
it { is_expected.to contain_exactly(a_path_ending_with("/caskroom/homebrew-spec/Casks"), a_path_ending_with("/third-party/homebrew-tap/Casks")) }
|
||||
it { is_expected.to contain_exactly(a_path_ending_with("/homebrew/homebrew-cask-spec/Casks"), a_path_ending_with("/third-party/homebrew-tap/Casks")) }
|
||||
end
|
||||
|
||||
context "when at least one cask token is a path that exists" do
|
||||
|
||||
@ -27,7 +27,7 @@ RSpec.shared_context "Homebrew-Cask" do
|
||||
|
||||
[Hbc::Config.global.binarydir, Hbc.caskroom, Hbc.cache].each(&:mkpath)
|
||||
|
||||
Hbc.default_tap = Tap.fetch("caskroom", "spec").tap do |tap|
|
||||
Hbc.default_tap = Tap.fetch("Homebrew", "cask-spec").tap do |tap|
|
||||
FileUtils.mkdir_p tap.path.dirname
|
||||
FileUtils.ln_sf TEST_FIXTURE_DIR.join("cask"), tap.path
|
||||
end
|
||||
@ -42,7 +42,6 @@ RSpec.shared_context "Homebrew-Cask" do
|
||||
FileUtils.rm_rf HOMEBREW_CASK_DIRS.values
|
||||
FileUtils.rm_rf [Hbc::Config.global.binarydir, Hbc.caskroom, Hbc.cache]
|
||||
Hbc.default_tap.path.unlink
|
||||
FileUtils.rm_rf Hbc.default_tap.path.parent
|
||||
third_party_tap.path.unlink
|
||||
FileUtils.rm_rf third_party_tap.path.parent
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user