diff --git a/Library/Homebrew/cmd/update-bash.sh b/Library/Homebrew/cmd/update-bash.sh index 05e7322ba8..2c0c3ea9b8 100755 --- a/Library/Homebrew/cmd/update-bash.sh +++ b/Library/Homebrew/cmd/update-bash.sh @@ -44,6 +44,36 @@ git_init_if_necessary() { fi } +rename_taps_dir_if_necessary() { + local tap_dir + for tap_dir in "$HOMEBREW_LIBRARY"/Taps/* + do + [[ -d "$tap_dir/.git" ]] || continue + local tap_dir_basename + tap_dir_basename="${tap_dir##*/}" + if [[ "$tap_dir_basename" = *"-"* ]] + then + # only replace the *last* dash: yes, tap filenames suck + local user + local repo + user="$(echo "${tap_dir_basename%-*}" | tr "[:upper:]" "[:lower:]")" + repo="$(echo "${tap_dir_basename:${#user}+1}" | tr "[:upper:]" "[:lower:]")" + mkdir -p "$HOMEBREW_LIBRARY/Taps/$user" + mv "$tap_dir", "$HOMEBREW_LIBRARY/Taps/$user/homebrew-$repo" + + if [[ ${#${tap_dir_basename//[^\-]}} -gt 1 ]] + then + echo "Homebrew changed the structure of Taps like /." >&2 + echo "So you may need to rename $HOMEBREW_LIBRARY/Taps/$user/homebrew-$repo manually." >&2 + fi + else + echo "Homebrew changed the structure of Taps like /. " >&2 + echo "$tap_dir is an incorrect Tap path." >&2 + echo "So you may need to rename it to $HOMEBREW_LIBRARY/Taps//homebrew- manually." >&2 + fi + done +} + repo_var() { local repo_var="$1" if [[ "$repo_var" = "$HOMEBREW_REPOSITORY" ]] @@ -247,6 +277,9 @@ EOS chdir "$HOMEBREW_REPOSITORY" git_init_if_necessary + # rename Taps directories + # this procedure will be removed in the future if it seems unnecessary + rename_taps_dir_if_necessary for DIR in "$HOMEBREW_REPOSITORY" "$HOMEBREW_LIBRARY"/Taps/*/* do diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index 92bf87daf1..a96a3b11c4 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -23,10 +23,6 @@ module Homebrew end report.update(master_updater.report) - # rename Taps directories - # this procedure will be removed in the future if it seems unnecessasry - rename_taps_dir_if_necessary - updated_taps = [] Tap.each do |tap| next unless tap.git? @@ -106,34 +102,6 @@ module Homebrew `git rev-parse --short #{revision}`.chomp end - def rename_taps_dir_if_necessary - Dir.glob("#{HOMEBREW_LIBRARY}/Taps/*/") do |tapd| - begin - if File.directory?(tapd + "/.git") - tapd_basename = File.basename(tapd) - if tapd_basename.include?("-") - # only replace the *last* dash: yes, tap filenames suck - user, repo = tapd_basename.reverse.sub("-", "/").reverse.split("/") - - FileUtils.mkdir_p("#{HOMEBREW_LIBRARY}/Taps/#{user.downcase}") - FileUtils.mv(tapd, "#{HOMEBREW_LIBRARY}/Taps/#{user.downcase}/homebrew-#{repo.downcase}") - - if tapd_basename.count("-") >= 2 - opoo "Homebrew changed the structure of Taps like /. "\ - + "So you may need to rename #{HOMEBREW_LIBRARY}/Taps/#{user.downcase}/homebrew-#{repo.downcase} manually." - end - else - opoo "Homebrew changed the structure of Taps like /. "\ - "#{tapd} is incorrect name format. You may need to rename it like / manually." - end - end - rescue => ex - onoe ex.message - next # next tap directory - end - end - end - def load_tap_migrations load "tap_migrations.rb" rescue LoadError