From a5aba7f7d865d0a6008ee541a1a18008a23cbc5d Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Fri, 28 Aug 2015 14:33:00 +0800 Subject: [PATCH] tap: rmdir when tap failed or interrupted Fixes Homebrew/homebrew#43280. Closes Homebrew/homebrew#43352. Signed-off-by: Xu Cheng --- Library/Homebrew/cmd/tap.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb index 4942d03270..3da9f3f24b 100644 --- a/Library/Homebrew/cmd/tap.rb +++ b/Library/Homebrew/cmd/tap.rb @@ -25,7 +25,16 @@ module Homebrew remote = clone_target || "https://github.com/#{tap.user}/homebrew-#{tap.repo}" args = %W[clone #{remote} #{tap.path}] args << "--depth=1" unless ARGV.include?("--full") - safe_system "git", *args + + begin + safe_system "git", *args + rescue Interrupt, ErrorDuringExecution + ignore_interrupts do + sleep 0.1 # wait for git to cleanup the top directory when interrupt happens. + tap.path.parent.rmdir_if_possible + end + raise + end formula_count = tap.formula_files.size puts "Tapped #{formula_count} formula#{plural(formula_count, "e")} (#{tap.path.abv})"