diff options
author | Carl Lerche <carllerche@mac.com> | 2010-07-15 10:29:18 -0700 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-07-15 10:29:31 -0700 |
commit | aebee5916f3613cfeec2d751d4db503388901a42 (patch) | |
tree | 9af3f4749c4e55791206040cd5473ea6e8a5a4f5 | |
parent | bf367148a45bfc56142db4d4fc32f137e1056f60 (diff) | |
download | bundler-aebee5916f3613cfeec2d751d4db503388901a42.tar.gz |
Don't remote fetch the git repository if the commit is available locally
-rw-r--r-- | lib/bundler/source.rb | 7 | ||||
-rw-r--r-- | spec/install/git_spec.rb | 12 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb index 404b3925d2..e765c47628 100644 --- a/lib/bundler/source.rb +++ b/lib/bundler/source.rb @@ -595,6 +595,7 @@ module Bundler def cache if cached? + return if has_revision_cached? Bundler.ui.info "Updating #{uri}" in_cache { git %|fetch --force --quiet "#{uri}" refs/heads/*:refs/heads/*| } else @@ -620,6 +621,12 @@ module Bundler end end + def has_revision_cached? + return unless @revision + git %|cat-file -t #{@revision}| + $? == 0 + end + def revision @revision ||= in_cache { git("rev-parse #{ref}").strip } end diff --git a/spec/install/git_spec.rb b/spec/install/git_spec.rb index afa57254f1..a8ba290c83 100644 --- a/spec/install/git_spec.rb +++ b/spec/install/git_spec.rb @@ -386,4 +386,16 @@ describe "bundle install with git sources" do out.should == "WIN" end + it "does not to a remote fetch if the revision is cached locally" do + build_git "foo" + + install_gemfile <<-G + gem "foo", :git => "#{lib_path('foo-1.0')}" + G + + FileUtils.rm_rf(lib_path('foo-1.0')) + + bundle "install" + out.should_not =~ /updating/i + end end |