Skip to content

Commit

Permalink
brew tap --repair
Browse files Browse the repository at this point in the history
Removes dead symlinks in Formula and re-symlinks all Taps.

Closes Homebrew#11565.
  • Loading branch information
mxcl authored and fgeller committed Aug 22, 2012
1 parent 3d44954 commit dbae6b6
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Library/Homebrew/cmd/tap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ def tap
tapd.children.each do |tap|
puts tap.basename.sub('-', '/') if (tap/'.git').directory?
end if tapd.directory?
elsif ARGV.first == "--repair"
repair_taps
else
install_tap(*tap_args)
end
Expand Down Expand Up @@ -58,6 +60,28 @@ def link_tap_formula formulae
tapped
end

def repair_taps
count = 0
# prune dead symlinks in Formula
Dir["#{HOMEBREW_REPOSITORY}/Library/Formula/*.rb"].each do |fn|
if not File.exist? fn
File.delete fn
count += 1
end
end
puts "Pruned #{count} dead formula"

count = 0
# check symlinks are all set in each tap
HOMEBREW_REPOSITORY.join("Library/Taps").children.each do |tap|
files = []
tap.find_formula{ |file| files << tap.basename.join(file) }
count += link_tap_formula(files)
end

puts "Tapped #{count} formula"
end

private

def tap_args
Expand Down

0 comments on commit dbae6b6

Please sign in to comment.