aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorAdam Vandenberg2010-09-22 21:38:52 -0700
committerAdam Vandenberg2010-09-24 07:50:20 -0700
commit5bc0ca46fa58cb21ce62891bd0dac241848c2612 (patch)
tree1029c7ff826b8cdecf6317ce527a2272020b8f83 /Library
parent4f5894cd51b1a4daabb9e85b8f73fd6b215bfcb0 (diff)
downloadhomebrew-5bc0ca46fa58cb21ce62891bd0dac241848c2612.tar.bz2
Check git repos for validity before updating.
If you `brew install erlang` and then control-C during the git clone, you can leave your cloned repo in an invalid state. This change does a "git status" on the clone if it exists, and nukes it if the status is invalid (forcing a clean clone.)
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/download_strategy.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index 767a26d15..083031e06 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -257,6 +257,17 @@ class GitDownloadStrategy <AbstractDownloadStrategy
unless system "/usr/bin/which git"
ohai "Cloning #{@url}"
+
+ if @clone.exist?
+ Dir.chdir(@clone) do
+ # Check for interupted clone from a previous install
+ unless system 'git', 'status', '-s'
+ ohai "Removing invalid .git repo from cache"
+ FileUtils.rm_rf @clone
+ end
+ end
+ end
+
unless @clone.exist?
safe_system 'git', 'clone', @url, @clone # indeed, leave it verbose
else