|
239 | 239 | expect(the_bundle).to include_gem "foo 1.0"
|
240 | 240 | end
|
241 | 241 |
|
| 242 | + it "installs properly a bundler 2.5.17-2.5.23 cache as a bare repository without cloning remote repositories" do |
| 243 | + git = build_git "foo" |
| 244 | + |
| 245 | + short_ref = git.ref_for("main", 11) |
| 246 | + cache_dir = bundled_app("vendor/cache/foo-1.0-#{short_ref}") |
| 247 | + |
| 248 | + gemfile <<-G |
| 249 | + source "https://gem.repo1" |
| 250 | + gem "foo", :git => '#{lib_path("foo-1.0")}' |
| 251 | + G |
| 252 | + bundle "config set global_gem_cache false" |
| 253 | + bundle "config set cache_all true" |
| 254 | + bundle "config path vendor/bundle" |
| 255 | + bundle :install |
| 256 | + |
| 257 | + # Simulate old cache by copying the real cache folder to vendor/cache |
| 258 | + FileUtils.mkdir_p bundled_app("vendor/cache") |
| 259 | + FileUtils.cp_r "#{Dir.glob(vendored_gems("cache/bundler/git/foo-1.0-*")).first}/.", cache_dir |
| 260 | + FileUtils.rm_rf bundled_app("vendor/bundle") |
| 261 | + |
| 262 | + bundle "install --local --verbose" |
| 263 | + expect(err).to include("Installing from cache in old \"bare repository\" format for compatibility") |
| 264 | + |
| 265 | + expect(out).to_not include("Fetching") |
| 266 | + |
| 267 | + # leaves old cache alone |
| 268 | + expect(cache_dir.join("lib/foo.rb")).not_to exist |
| 269 | + expect(cache_dir.join("HEAD")).to exist |
| 270 | + |
| 271 | + expect(the_bundle).to include_gem "foo 1.0" |
| 272 | + end |
| 273 | + |
| 274 | + it "migrates a bundler 2.5.17-2.5.23 cache as a bare repository when not running with --local" do |
| 275 | + git = build_git "foo" |
| 276 | + |
| 277 | + short_ref = git.ref_for("main", 11) |
| 278 | + cache_dir = bundled_app("vendor/cache/foo-1.0-#{short_ref}") |
| 279 | + |
| 280 | + gemfile <<-G |
| 281 | + source "https://gem.repo1" |
| 282 | + gem "foo", :git => '#{lib_path("foo-1.0")}' |
| 283 | + G |
| 284 | + bundle "config set global_gem_cache false" |
| 285 | + bundle "config set cache_all true" |
| 286 | + bundle "config path vendor/bundle" |
| 287 | + bundle :install |
| 288 | + |
| 289 | + # Simulate old cache by copying the real cache folder to vendor/cache |
| 290 | + FileUtils.mkdir_p bundled_app("vendor/cache") |
| 291 | + FileUtils.cp_r "#{Dir.glob(vendored_gems("cache/bundler/git/foo-1.0-*")).first}/.", cache_dir |
| 292 | + FileUtils.rm_rf bundled_app("vendor/bundle") |
| 293 | + |
| 294 | + bundle "install --verbose" |
| 295 | + expect(out).to include("Fetching") |
| 296 | + |
| 297 | + # migrates old cache alone |
| 298 | + expect(cache_dir.join("lib/foo.rb")).to exist |
| 299 | + expect(cache_dir.join("HEAD")).not_to exist |
| 300 | + |
| 301 | + expect(the_bundle).to include_gem "foo 1.0" |
| 302 | + end |
| 303 | + |
| 304 | + it "migrates a bundler 2.5.17-2.5.23 cache as a bare repository when running `bundle cache`, even if gems already installed" do |
| 305 | + git = build_git "foo" |
| 306 | + |
| 307 | + short_ref = git.ref_for("main", 11) |
| 308 | + cache_dir = bundled_app("vendor/cache/foo-1.0-#{short_ref}") |
| 309 | + |
| 310 | + gemfile <<-G |
| 311 | + source "https://gem.repo1" |
| 312 | + gem "foo", :git => '#{lib_path("foo-1.0")}' |
| 313 | + G |
| 314 | + bundle "config set global_gem_cache false" |
| 315 | + bundle "config set cache_all true" |
| 316 | + bundle "config path vendor/bundle" |
| 317 | + bundle :install |
| 318 | + |
| 319 | + # Simulate old cache by copying the real cache folder to vendor/cache |
| 320 | + FileUtils.mkdir_p bundled_app("vendor/cache") |
| 321 | + FileUtils.cp_r "#{Dir.glob(vendored_gems("cache/bundler/git/foo-1.0-*")).first}/.", cache_dir |
| 322 | + |
| 323 | + bundle "cache" |
| 324 | + |
| 325 | + # migrates old cache alone |
| 326 | + expect(cache_dir.join("lib/foo.rb")).to exist |
| 327 | + expect(cache_dir.join("HEAD")).not_to exist |
| 328 | + |
| 329 | + expect(the_bundle).to include_gem "foo 1.0" |
| 330 | + end |
| 331 | + |
242 | 332 | it "copies repository to vendor cache, including submodules" do
|
243 | 333 | # CVE-2022-39253: https://lore.kernel.org/lkml/[email protected]/
|
244 | 334 | system(*%W[git config --global protocol.file.allow always])
|
|
0 commit comments