aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2016-09-07 08:23:40 +0100
committerGitHub2016-09-07 08:23:40 +0100
commit4d123e6227ec5dc34a0f0a4001f7093340877258 (patch)
tree148ac4a912a04544b9cabb76986abd91a48f5d2a /Library
parentadaba7157dfb5ef51f3e8798c26645f010b0a4de (diff)
parent1160d0e347d09ea57df4cf943f5ff35736657cc0 (diff)
downloadbrew-4d123e6227ec5dc34a0f0a4001f7093340877258.tar.bz2
Merge pull request #857 from MikeMcQuaid/update-report-link-more
update-report: also link docs, completions.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/update-report.rb13
-rw-r--r--Library/Homebrew/utils.rb18
2 files changed, 22 insertions, 9 deletions
diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb
index e1ac3ec67..45d9f4f4a 100644
--- a/Library/Homebrew/cmd/update-report.rb
+++ b/Library/Homebrew/cmd/update-report.rb
@@ -88,7 +88,7 @@ module Homebrew
puts if ARGV.include?("--preinstall")
end
- link_manpages
+ link_completions_and_docs
Tap.each(&:link_manpages)
Homebrew.failed = true if ENV["HOMEBREW_UPDATE_FAILED"]
@@ -163,9 +163,16 @@ module Homebrew
end
end
- def link_manpages
+ def link_completions_and_docs
return if HOMEBREW_PREFIX.to_s == HOMEBREW_REPOSITORY.to_s
- link_path_manpages(HOMEBREW_REPOSITORY/"share", "brew update")
+ command = "brew update"
+ link_src_dst_dirs(HOMEBREW_REPOSITORY/"etc/bash_completion.d",
+ HOMEBREW_PREFIX/"etc/bash_completion.d", command)
+ link_src_dst_dirs(HOMEBREW_REPOSITORY/"share/doc/homebrew",
+ HOMEBREW_PREFIX/"share/doc/homebrew", command, link_dir: true)
+ link_src_dst_dirs(HOMEBREW_REPOSITORY/"share/zsh/site-functions",
+ HOMEBREW_PREFIX/"share/zsh/site-functions", command)
+ link_path_manpages(HOMEBREW_REPOSITORY/"share", command)
end
end
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 41b9a4661..4b8aeaff4 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -589,25 +589,31 @@ def truncate_text_to_approximate_size(s, max_bytes, options = {})
out
end
-def link_path_manpages(path, command)
- return unless (path/"man").exist?
+def link_src_dst_dirs(src_dir, dst_dir, command, link_dir: false)
+ return unless src_dir.exist?
conflicts = []
- (path/"man").find do |src|
- next if src.directory?
- dst = HOMEBREW_PREFIX/"share"/src.relative_path_from(path)
+ src_paths = link_dir ? [src_dir] : src_dir.find
+ src_paths.each do |src|
+ next if src.directory? && !link_dir
+ dst = dst_dir.parent/src.relative_path_from(src_dir.parent)
next if dst.symlink? && src == dst.resolved_path
if dst.exist?
conflicts << dst
next
end
+ dst_dir.parent.mkpath
dst.make_relative_symlink(src)
end
unless conflicts.empty?
onoe <<-EOS.undent
- Could not link #{name} manpages to:
+ Could not link:
#{conflicts.join("\n")}
Please delete these files and run `#{command}`.
EOS
end
end
+
+def link_path_manpages(path, command)
+ link_src_dst_dirs(path/"man", HOMEBREW_PREFIX/"share/man", command)
+end