Skip to content

Commit

Permalink
[rubygems/rubygems] Stop removing the .git folder from cached git gems
Browse files Browse the repository at this point in the history
If we want to change git gems to use a proper cache, instead of using
the cache folder as the install location, so we need to keep git
information in the cache, so that when running `bundle install` or
`bundler install --local`, we are able to figure out whether the
revision that needs to be checked out is present locally in the cache or
needs to be fetched from the remote repository.

rubygems/rubygems@607eda63eb
  • Loading branch information
deivid-rodriguez authored and matzbot committed Jul 23, 2024
1 parent b1db070 commit a4ec5f8
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 3 deletions.
1 change: 1 addition & 0 deletions lib/bundler/plugin/api/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 196,7 @@ def cache(spec, custom_path = nil)

FileUtils.rm_rf(new_cache_path)
FileUtils.cp_r(install_path, new_cache_path)
FileUtils.rm_rf(app_cache_path.join(".git"))
FileUtils.touch(app_cache_path.join(".bundlecache"))
end

Expand Down
1 change: 0 additions & 1 deletion lib/bundler/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 140,6 @@ def cache(custom_path = nil, local = false)
end

Dir[cache_path.join("*/.git")].each do |git_dir|
FileUtils.rm_rf(git_dir)
FileUtils.touch(File.expand_path("../.bundlecache", git_dir))
end

Expand Down
2 changes: 0 additions & 2 deletions spec/bundler/cache/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 25,6 @@
bundle "config set cache_all true"
bundle :cache
expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist
expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.bundlecache")).to be_file

FileUtils.rm_rf lib_path("foo-1.0")
Expand All @@ -47,7 46,6 @@
bundle :cache

expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist

FileUtils.rm_rf lib_path("foo-1.0")
expect(the_bundle).to include_gems "foo 1.0"
Expand Down

0 comments on commit a4ec5f8

Please sign in to comment.