diff options
| author | Max Howell | 2012-03-07 22:48:44 +0000 |
|---|---|---|
| committer | Max Howell | 2012-03-16 21:06:17 +0000 |
| commit | 7280590e881635f4e47bb619043f5bfd1af05780 (patch) | |
| tree | 71f433dd8933fb42461efce1dbd1bc876c430c9f | |
| parent | 2c84be96d8325abf6e3062197c99f5dc12f79109 (diff) | |
| download | brew-7280590e881635f4e47bb619043f5bfd1af05780.tar.bz2 | |
Link new tapped formula during brew update
Required me to spoil tap's code. All in the name of DRY! Alas!
| -rw-r--r-- | Library/Homebrew/cmd/tap.rb | 29 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/update.rb | 12 |
2 files changed, 30 insertions, 11 deletions
diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb index 74f0b20d7..f87349977 100644 --- a/Library/Homebrew/cmd/tap.rb +++ b/Library/Homebrew/cmd/tap.rb @@ -21,21 +21,28 @@ module Homebrew extend self raise "Already tapped!" if tapd.directory? abort unless system "git clone https://github.com/#{user}/homebrew-#{repo} #{tapd}" - gitignores = (HOMEBREW_LIBRARY/"Formula/.gitignore").read.split rescue [] - - cd HOMEBREW_LIBRARY/"Formula" - tapd.find_formula do |relative_pathname| - # using the system ln is the only way to get relative symlinks - system "ln -s ../Taps/#{user}-#{repo}/#{relative_pathname} 2>/dev/null" - if $?.success? - gitignores << relative_pathname.basename.to_s - else - opoo "#{relative_pathname.basename('.rb')} conflicts" + files = [] + tapd.find_formula{ |file| files << Pathname.new("#{user}-#{repo}").join(file) } + link_tap_formula(files) + end + + def link_tap_formula formulae + ignores = (HOMEBREW_LIBRARY/"Formula/.gitignore").read.split rescue [] + + cd HOMEBREW_LIBRARY/"Formula" do + formulae.each do |formula| + # using the system ln is the only way to get relative symlinks + system "ln -s ../Taps/#{formula} 2>/dev/null" + if $?.success? + ignores << formula.basename.to_s + else + opoo "#{formula.basename('.rb')} conflicts" + end end end tf = Tempfile.new("brew-tap") - tf.write(gitignores.uniq.join("\n")) + tf.write(ignores.uniq.join("\n")) tf.close mv tf.path, "#{HOMEBREW_LIBRARY}/Formula/.gitignore" end diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb index 3d7713784..7939136a5 100644 --- a/Library/Homebrew/cmd/update.rb +++ b/Library/Homebrew/cmd/update.rb @@ -1,3 +1,5 @@ +require 'cmd/tap' + module Homebrew extend self def update @@ -14,6 +16,7 @@ module Homebrew extend self master_updater.pull! report.merge!(master_updater.report) + new_files = [] Dir["Library/Taps/*"].each do |tapd| cd tapd do updater = Updater.new @@ -23,6 +26,7 @@ module Homebrew extend self end end end + Homebrew.link_tap_formula(report.new_tapped_formula) if report.empty? puts "Already up-to-date." @@ -117,6 +121,14 @@ class Report < Hash # dump_deleted_commands end + def new_tapped_formula + fetch(:A, []).map do |path| + case path when %r{^Library/Taps(/\w+-\w+/.*)} + Pathname.new($1) + end + end.compact + end + def select_formula key fetch(key, []).map do |path| case path when %r{^Library/Formula} |
