Skip to content

Commit

Permalink
Generalise the untap step so we can add to update
Browse files Browse the repository at this point in the history
brew-update needs to be able to unsymlink removed stuff from taps too.
  • Loading branch information
mxcl committed Mar 18, 2012
1 parent a190d47 commit 21b04d5
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions Library/Homebrew/cmd/untap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,31 @@ def untap

raise "No such tap!" unless tapd.directory?

gitignores = (HOMEBREW_LIBRARY/"Formula/.gitignore").read.split rescue []
files = []
tapd.find_formula{ |file| files << Pathname.new("#{user}-#{repo}").join(file) }
untapped = unlink_tap_formula(files)
rm_rf tapd
puts "Untapped #{untapped} formula"
end

def unlink_tap_formula formulae
untapped = 0
gitignores = (HOMEBREW_LIBRARY/"Formula/.gitignore").read.split rescue []

tapd.find_formula do |pn|
bn = pn.basename.to_s
formulae.each do |formula|
tapd = (HOMEBREW_LIBRARY/"Taps/#{formula}").dirname
bn = formula.basename.to_s
pn = HOMEBREW_LIBRARY/"Formula/#{bn}"
if pn.symlink? and pn.realpath.to_s =~ %r[^#{tapd.realpath}]

if pn.symlink? and pn.realpath.to_s =~ %r[^#{tapd}]
pn.delete
gitignores.delete(bn)
untapped += 1
end
end
rm_rf tapd

HOMEBREW_REPOSITORY.join("Library/Formula/.gitignore").atomic_write(gitignores * "\n")

puts "Untapped #{untapped} formula"
untapped
end
end

0 comments on commit 21b04d5

Please sign in to comment.