From f583199f6e24ceaa2f79b7436fb6169b99441928 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 11 Sep 2016 14:14:26 +0100 Subject: [PATCH] test-bot: don't try to `git clean` any taps. Also, unify the cleanup code and be more careful and consistent with untapping. --- Library/Homebrew/dev-cmd/test-bot.rb | 51 ++++++++++++---------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/Library/Homebrew/dev-cmd/test-bot.rb b/Library/Homebrew/dev-cmd/test-bot.rb index a129bd8d30..7d95d2ebbc 100644 --- a/Library/Homebrew/dev-cmd/test-bot.rb +++ b/Library/Homebrew/dev-cmd/test-bot.rb @@ -724,18 +724,15 @@ module Homebrew end end - def cleanup_before - @category = __method__ - return unless ARGV.include? "--cleanup" + def cleanup_git git "gc", "--auto" - git "stash" - git "am", "--abort" - git "rebase", "--abort" - unless ARGV.include? "--no-pull" - git "checkout", "-f", "master" - git "reset", "--hard", "origin/master" + test "git", "clean", "-ffdx", "--exclude=Library/Taps" + + Tap.names.each do |tap| + next if tap == "homebrew/core" + next if tap == @tap.to_s + safe_system "brew", "untap", tap end - git "clean", "-ffdx", "--exclude=Library/Taps/homebrew/homebrew-core" unless @repository == HOMEBREW_REPOSITORY HOMEBREW_REPOSITORY.cd do @@ -752,6 +749,20 @@ module Homebrew safe_system "git", "reset", "--hard", "origin/master" end end + end + + def cleanup_before + @category = __method__ + return unless ARGV.include? "--cleanup" + git "stash" + git "am", "--abort" + git "rebase", "--abort" + unless ARGV.include? "--no-pull" + git "checkout", "-f", "master" + git "reset", "--hard", "origin/master" + end + + cleanup_git pr_locks = "#{@repository}/.git/refs/remotes/*/pr/*/*.lock" Dir.glob(pr_locks) { |lock| FileUtils.rm_rf lock } @@ -771,26 +782,8 @@ module Homebrew git "reset", "--hard", "origin/master" git "stash", "pop" test "brew", "cleanup", "--prune=7" - git "gc", "--auto" - test "git", "clean", "-ffdx", "--exclude=Library/Taps/homebrew/homebrew-core" - Tap.names.each { |s| safe_system "brew", "untap", s if s != "homebrew/core" } - - unless @repository == HOMEBREW_REPOSITORY - HOMEBREW_REPOSITORY.cd do - safe_system "git", "checkout", "-f", "master" - safe_system "git", "reset", "--hard", "origin/master" - safe_system "git", "clean", "-ffdx", "--exclude=Library/Taps" - end - end - - Pathname.glob("#{HOMEBREW_LIBRARY}/Taps/*/*").each do |git_repo| - next if @repository == git_repo - git_repo.cd do - safe_system "git", "checkout", "-f", "master" - safe_system "git", "reset", "--hard", "origin/master" - end - end + cleanup_git if ARGV.include? "--local" FileUtils.rm_rf ENV["HOMEBREW_HOME"]