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