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
commit8a60d852b3ad4ba0dc6c59dc9a5d956eed300e1d (patch)
treeca3c33013f091ab58b1a89191cd315bb1181017b /Library
parente750242b73d3dba199fd7491972854ca6b48ea38 (diff)
downloadbrew-8a60d852b3ad4ba0dc6c59dc9a5d956eed300e1d.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