Pass around only absolute paths when dealing with taps
This commit is contained in:
parent
a0494441d3
commit
b40a3413e3
@ -25,7 +25,7 @@ module Homebrew extend self
|
||||
abort unless system "git clone https://github.com/#{repouser}/homebrew-#{repo} #{tapd}"
|
||||
|
||||
files = []
|
||||
tapd.find_formula{ |file| files << tapd.dirname.basename.join(tapd.basename, file) }
|
||||
tapd.find_formula { |file| files << tapd.join(file) }
|
||||
link_tap_formula(files)
|
||||
puts "Tapped #{files.length} formula"
|
||||
|
||||
@ -42,24 +42,23 @@ module Homebrew extend self
|
||||
true
|
||||
end
|
||||
|
||||
def link_tap_formula formulae
|
||||
def link_tap_formula paths
|
||||
ignores = (HOMEBREW_LIBRARY/"Formula/.gitignore").read.split rescue []
|
||||
tapped = 0
|
||||
|
||||
formulae.each do |formula|
|
||||
from = HOMEBREW_LIBRARY.join("Taps/#{formula}")
|
||||
to = HOMEBREW_LIBRARY.join("Formula/#{formula.basename}")
|
||||
paths.each do |path|
|
||||
to = HOMEBREW_LIBRARY.join("Formula", path.basename)
|
||||
|
||||
# Unexpected, but possible, lets proceed as if nothing happened
|
||||
to.delete if to.symlink? and to.realpath == from
|
||||
to.delete if to.symlink? && to.resolved_path == path
|
||||
|
||||
begin
|
||||
to.make_relative_symlink(from)
|
||||
to.make_relative_symlink(path)
|
||||
rescue SystemCallError
|
||||
to = to.realpath if to.exist?
|
||||
opoo "Could not tap #{Tty.white}#{tap_ref(from)}#{Tty.reset} over #{Tty.white}#{tap_ref(to)}#{Tty.reset}"
|
||||
to = to.resolved_path if to.symlink?
|
||||
opoo "Could not tap #{Tty.white}#{tap_ref(path)}#{Tty.reset} over #{Tty.white}#{tap_ref(to)}#{Tty.reset}"
|
||||
else
|
||||
ignores << formula.basename.to_s
|
||||
ignores << path.basename.to_s
|
||||
tapped += 1
|
||||
end
|
||||
end
|
||||
@ -86,7 +85,7 @@ module Homebrew extend self
|
||||
# check symlinks are all set in each tap
|
||||
each_tap do |user, repo|
|
||||
files = []
|
||||
repo.find_formula { |file| files << user.basename.join(repo.basename, file) }
|
||||
repo.find_formula { |file| files << repo.join(file) }
|
||||
count += link_tap_formula(files)
|
||||
end
|
||||
|
||||
|
@ -18,24 +18,23 @@ module Homebrew extend self
|
||||
raise "No such tap!" unless tapd.directory?
|
||||
|
||||
files = []
|
||||
tapd.find_formula{ |file| files << Pathname.new("#{user}/homebrew-#{repo}").join(file) }
|
||||
tapd.find_formula { |file| files << tapd.join(file) }
|
||||
unlink_tap_formula(files)
|
||||
tapd.rmtree
|
||||
tapd.dirname.rmdir_if_possible
|
||||
puts "Untapped #{files.length} formula"
|
||||
end
|
||||
|
||||
def unlink_tap_formula formulae
|
||||
def unlink_tap_formula paths
|
||||
untapped = 0
|
||||
gitignores = (HOMEBREW_LIBRARY/"Formula/.gitignore").read.split rescue []
|
||||
|
||||
formulae.each do |formula|
|
||||
file = HOMEBREW_LIBRARY.join("Taps", formula)
|
||||
link = HOMEBREW_LIBRARY.join("Formula", formula.basename)
|
||||
paths.each do |path|
|
||||
link = HOMEBREW_LIBRARY.join("Formula", path.basename)
|
||||
|
||||
if link.symlink? && (!link.exist? || link.resolved_path == file)
|
||||
if link.symlink? && (!link.exist? || link.resolved_path == path)
|
||||
link.delete
|
||||
gitignores.delete(file.basename.to_s)
|
||||
gitignores.delete(path.basename.to_s)
|
||||
untapped += 1
|
||||
end
|
||||
end
|
||||
|
@ -17,11 +17,10 @@ module Homebrew extend self
|
||||
cd HOMEBREW_REPOSITORY
|
||||
git_init_if_necessary
|
||||
|
||||
taps = HOMEBREW_LIBRARY.join("Taps")
|
||||
tapped_formulae = []
|
||||
HOMEBREW_LIBRARY.join("Formula").children.each do |path|
|
||||
next unless path.symlink?
|
||||
tapped_formulae << path.resolved_path.relative_path_from(taps)
|
||||
tapped_formulae << path.resolved_path
|
||||
end
|
||||
unlink_tap_formula(tapped_formulae)
|
||||
|
||||
@ -179,8 +178,7 @@ class Updater
|
||||
when :R then $3
|
||||
else $2
|
||||
end
|
||||
path = Pathname.pwd.join(path).relative_path_from(HOMEBREW_REPOSITORY)
|
||||
map[status] << path.to_s
|
||||
map[status] << Pathname.pwd.join(path)
|
||||
end
|
||||
end
|
||||
|
||||
@ -219,12 +217,12 @@ class Report < Hash
|
||||
end
|
||||
|
||||
def tapped_formula_for key
|
||||
fetch(key, []).map do |path|
|
||||
case path when %r{^Library/Taps/([\w_-]+/[\w_-]+/.*)}
|
||||
relative_path = $1
|
||||
if valid_formula_location?(relative_path)
|
||||
Pathname.new(relative_path)
|
||||
end
|
||||
fetch(key, []).select do |path|
|
||||
case path.relative_path_from(HOMEBREW_REPOSITORY).to_s
|
||||
when %r{^Library/Taps/([\w_-]+/[\w_-]+/.*)}
|
||||
valid_formula_location?($1)
|
||||
else
|
||||
false
|
||||
end
|
||||
end.compact
|
||||
end
|
||||
@ -249,10 +247,11 @@ class Report < Hash
|
||||
|
||||
def select_formula key
|
||||
fetch(key, []).map do |path|
|
||||
case path when %r{^Library/Formula}
|
||||
File.basename(path, ".rb")
|
||||
case path.relative_path_from(HOMEBREW_REPOSITORY).to_s
|
||||
when %r{^Library/Formula}
|
||||
path.basename(".rb").to_s
|
||||
when %r{^Library/Taps/([\w_-]+)/(homebrew-)?([\w_-]+)/(.*)\.rb}
|
||||
"#$1/#$3/#{File.basename(path, '.rb')}"
|
||||
"#$1/#$3/#{path.basename(".rb")}"
|
||||
end
|
||||
end.compact.sort
|
||||
end
|
||||
|
@ -85,9 +85,9 @@ class UpdaterTests < Test::Unit::TestCase
|
||||
perform_update(fixture('update_git_diff_output_with_tapped_formulae_changes'))
|
||||
assert @updater.expectations_met?
|
||||
assert_equal [
|
||||
Pathname('someuser/sometap/Formula/antiword.rb'),
|
||||
Pathname('someuser/sometap/HomebrewFormula/lua.rb'),
|
||||
Pathname('someuser/sometap/custom-formula.rb'),
|
||||
HOMEBREW_LIBRARY.join("Taps", "someuser/sometap/Formula/antiword.rb"),
|
||||
HOMEBREW_LIBRARY.join("Taps", "someuser/sometap/HomebrewFormula/lua.rb"),
|
||||
HOMEBREW_LIBRARY.join("Taps", "someuser/sometap/custom-formula.rb"),
|
||||
], @report.tapped_formula_for(:A)
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user