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.)
This commit is contained in:
Adam Vandenberg 2010-09-22 21:38:52 -07:00
parent e750242b73
commit 8a60d852b3

View File

@ -257,6 +257,17 @@ class GitDownloadStrategy <AbstractDownloadStrategy
unless system "/usr/bin/which git" unless system "/usr/bin/which git"
ohai "Cloning #{@url}" 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? unless @clone.exist?
safe_system 'git', 'clone', @url, @clone # indeed, leave it verbose safe_system 'git', 'clone', @url, @clone # indeed, leave it verbose
else else