aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorXu Cheng2015-08-28 14:33:00 +0800
committerXu Cheng2015-08-28 17:15:23 +0800
commita5aba7f7d865d0a6008ee541a1a18008a23cbc5d (patch)
treef526fd789c5ece72a7eb23287f1b3e01351b5b98 /Library
parent3458b99d6e46ac9010170a874de036ae659ffe47 (diff)
downloadbrew-a5aba7f7d865d0a6008ee541a1a18008a23cbc5d.tar.bz2
tap: rmdir when tap failed or interrupted
Fixes Homebrew/homebrew#43280. Closes Homebrew/homebrew#43352. Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/tap.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb
index 4942d0327..3da9f3f24 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})"