From 966901b39dd7b37eec68dd6e8a76a79827dc522f Mon Sep 17 00:00:00 2001 From: Daniel Colson Date: Fri, 6 Sep 2024 13:10:04 -0400 Subject: [PATCH] [rubygems/rubygems] Don't include hook templates in cached git source With a default git setup, each cloned repo in the cache will end up with ~60K of sample git hooks. These files all end in `.sample`, and they are disabled by default. Deleting them should be a no-op, and makes the cache a bit smaller. https://github.com/rubygems/rubygems/commit/d2149999cd --- lib/bundler/source/git.rb | 1 + spec/bundler/cache/git_spec.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index 4e94645f6b..2a327e5fb6 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -226,6 +226,7 @@ module Bundler git_proxy.checkout if requires_checkout? FileUtils.cp_r("#{cache_path}/.", app_cache_path) FileUtils.touch(app_cache_path.join(".bundlecache")) + FileUtils.rm_rf(Dir.glob(app_cache_path.join("hooks/*.sample"))) end def load_spec_files diff --git a/spec/bundler/cache/git_spec.rb b/spec/bundler/cache/git_spec.rb index 8958916fec..7c577b105e 100644 --- a/spec/bundler/cache/git_spec.rb +++ b/spec/bundler/cache/git_spec.rb @@ -27,6 +27,7 @@ RSpec.describe "bundle cache with git" do 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 + expect(Dir.glob(bundled_app("vendor/cache/foo-1.0-#{ref}/hooks/*.sample"))).to be_empty FileUtils.rm_rf lib_path("foo-1.0") expect(the_bundle).to include_gems "foo 1.0"