Link new tapped formula during brew update
Required me to spoil tap's code. All in the name of DRY! Alas!
This commit is contained in:
parent
2c84be96d8
commit
7280590e88
@ -21,21 +21,28 @@ module Homebrew extend self
|
|||||||
raise "Already tapped!" if tapd.directory?
|
raise "Already tapped!" if tapd.directory?
|
||||||
abort unless system "git clone https://github.com/#{user}/homebrew-#{repo} #{tapd}"
|
abort unless system "git clone https://github.com/#{user}/homebrew-#{repo} #{tapd}"
|
||||||
|
|
||||||
gitignores = (HOMEBREW_LIBRARY/"Formula/.gitignore").read.split rescue []
|
files = []
|
||||||
|
tapd.find_formula{ |file| files << Pathname.new("#{user}-#{repo}").join(file) }
|
||||||
|
link_tap_formula(files)
|
||||||
|
end
|
||||||
|
|
||||||
cd HOMEBREW_LIBRARY/"Formula"
|
def link_tap_formula formulae
|
||||||
tapd.find_formula do |relative_pathname|
|
ignores = (HOMEBREW_LIBRARY/"Formula/.gitignore").read.split rescue []
|
||||||
# using the system ln is the only way to get relative symlinks
|
|
||||||
system "ln -s ../Taps/#{user}-#{repo}/#{relative_pathname} 2>/dev/null"
|
cd HOMEBREW_LIBRARY/"Formula" do
|
||||||
if $?.success?
|
formulae.each do |formula|
|
||||||
gitignores << relative_pathname.basename.to_s
|
# using the system ln is the only way to get relative symlinks
|
||||||
else
|
system "ln -s ../Taps/#{formula} 2>/dev/null"
|
||||||
opoo "#{relative_pathname.basename('.rb')} conflicts"
|
if $?.success?
|
||||||
|
ignores << formula.basename.to_s
|
||||||
|
else
|
||||||
|
opoo "#{formula.basename('.rb')} conflicts"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
tf = Tempfile.new("brew-tap")
|
tf = Tempfile.new("brew-tap")
|
||||||
tf.write(gitignores.uniq.join("\n"))
|
tf.write(ignores.uniq.join("\n"))
|
||||||
tf.close
|
tf.close
|
||||||
mv tf.path, "#{HOMEBREW_LIBRARY}/Formula/.gitignore"
|
mv tf.path, "#{HOMEBREW_LIBRARY}/Formula/.gitignore"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
require 'cmd/tap'
|
||||||
|
|
||||||
module Homebrew extend self
|
module Homebrew extend self
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@ -14,6 +16,7 @@ module Homebrew extend self
|
|||||||
master_updater.pull!
|
master_updater.pull!
|
||||||
report.merge!(master_updater.report)
|
report.merge!(master_updater.report)
|
||||||
|
|
||||||
|
new_files = []
|
||||||
Dir["Library/Taps/*"].each do |tapd|
|
Dir["Library/Taps/*"].each do |tapd|
|
||||||
cd tapd do
|
cd tapd do
|
||||||
updater = Updater.new
|
updater = Updater.new
|
||||||
@ -23,6 +26,7 @@ module Homebrew extend self
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Homebrew.link_tap_formula(report.new_tapped_formula)
|
||||||
|
|
||||||
if report.empty?
|
if report.empty?
|
||||||
puts "Already up-to-date."
|
puts "Already up-to-date."
|
||||||
@ -117,6 +121,14 @@ class Report < Hash
|
|||||||
# dump_deleted_commands
|
# dump_deleted_commands
|
||||||
end
|
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
|
def select_formula key
|
||||||
fetch(key, []).map do |path|
|
fetch(key, []).map do |path|
|
||||||
case path when %r{^Library/Formula}
|
case path when %r{^Library/Formula}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user