diff options
| author | Adam Vandenberg | 2010-09-22 21:38:52 -0700 |
|---|---|---|
| committer | Adam Vandenberg | 2010-09-24 07:50:20 -0700 |
| commit | 5bc0ca46fa58cb21ce62891bd0dac241848c2612 (patch) | |
| tree | 1029c7ff826b8cdecf6317ce527a2272020b8f83 /Library | |
| parent | 4f5894cd51b1a4daabb9e85b8f73fd6b215bfcb0 (diff) | |
| download | homebrew-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.rb | 11 |
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 |
