Skip to content

Commit

Permalink
Don't actually care if git repo is inside the repository, always cach…
Browse files Browse the repository at this point in the history
…e it, closes rubygems#1989
  • Loading branch information
José Valim committed Jul 17, 2012
1 parent 438ef20 commit 51aaf18
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/bundler/source.rb
Expand Up @@ -694,6 +694,9 @@ def name
File.basename(@uri, '.git')
end

# This is the path which is going to contain a specific
# checkout of the git repository. When using local git
# repos, this is set to the local repo.
def install_path
@install_path ||= begin
git_scope = "#{base_name}-#{shortref_for_path(revision)}"
Expand Down Expand Up @@ -778,7 +781,7 @@ def install(spec)

def cache(spec)
return unless Bundler.settings[:cache_all]
return if path.expand_path(Bundler.root).to_s.index(Bundler.root.to_s) == 0
return if path == app_cache_path
cached!
FileUtils.rm_rf(app_cache_path)
git_proxy.checkout if requires_checkout?
Expand All @@ -792,6 +795,10 @@ def load_spec_files
raise GitError, "#{to_s} is not checked out. Please run `bundle install`"
end

# This is the path which is going to contain a cache
# of the git repository. When using the same git repository
# across different projects, this cache will be shared.
# When using local git repos, this is set to the local repo.
def cache_path
@cache_path ||= begin
git_scope = "#{base_name}-#{uri_hash}"
Expand Down
18 changes: 18 additions & 0 deletions spec/cache/git_spec.rb
Expand Up @@ -30,6 +30,24 @@
should_be_installed "foo 1.0"
end

it "copies repository to vendor cache and uses it even when installed with bundle --path" do
git = build_git "foo"
ref = git.ref_for("master", 11)

install_gemfile <<-G
gem "foo", :git => '#{lib_path("foo-1.0")}'
G

bundle "install --path vendor/bundle"
bundle "#{cmd} --all"

bundled_app("vendor/cache/foo-1.0-#{ref}").should exist
bundled_app("vendor/cache/foo-1.0-#{ref}/.git").should_not exist

FileUtils.rm_rf lib_path("foo-1.0")
should_be_installed "foo 1.0"
end

it "runs twice without exploding" do
build_git "foo"

Expand Down

0 comments on commit 51aaf18

Please sign in to comment.