Skip to content

Commit d599df2

Browse files
Merge pull request #8076 from rubygems/deivid-rodriguez/fix-git-cache-without-root-git-dir-ancestor
Fix old cache format detection when application is not source controlled (cherry picked from commit 7597304)
1 parent 28d7b40 commit d599df2

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

bundler/lib/bundler/source/git.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def specs(*)
191191
set_up_app_cache!(app_cache_path) if use_app_cache?
192192

193193
if requires_checkout? && !@copied
194-
FileUtils.rm_rf(app_cache_path) if use_app_cache? && git_proxy.not_a_bare_repository?
194+
FileUtils.rm_rf(app_cache_path) if use_app_cache? && git_proxy.not_a_repository?
195195

196196
fetch
197197
checkout

bundler/lib/bundler/source/git/git_proxy.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ def current_branch
8484
end
8585
end
8686

87-
def not_a_bare_repository?
88-
git_local("rev-parse", "--is-bare-repository", dir: path).strip == "false"
87+
def not_a_repository?
88+
_, status = git_null("rev-parse", "--resolve-git-dir", path.to_s, dir: path)
89+
90+
!status.success?
8991
end
9092

9193
def contains?(commit)

bundler/spec/cache/git_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,6 @@
323323
FileUtils.mkdir_p bundled_app("vendor/cache")
324324
FileUtils.cp_r git_path, bundled_app("vendor/cache/foo-1.0-#{path_revision}")
325325
FileUtils.rm_rf bundled_app("vendor/cache/foo-1.0-#{path_revision}/.git")
326-
# bundle install with git repo needs to be run under the git environment.
327-
Dir.chdir(bundled_app) { system(*%W[git init --quiet]) }
328326

329327
bundle :install, env: { "BUNDLE_DEPLOYMENT" => "true", "BUNDLE_CACHE_ALL" => "true" }
330328
end

0 commit comments

Comments
 (0)