From bc5fdc61839bee9d58c5b04504e6e0cbabbe15c9 Mon Sep 17 00:00:00 2001 From: Justin Martin Date: Tue, 16 Apr 2024 11:35:22 -0700 Subject: [PATCH] Use rsync to exclude copying the fsmonitor--daemon.ipc --- CHANGELOG.md | 4 +++- lib/cocoapods/downloader/cache.rb | 7 +++++-- spec/unit/validator_spec.rb | 10 ++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71fd7c8116..fbcd19e3f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ##### Bug Fixes -* None. +* Fix pod install issue when git's `core.fsmonitor` feature is enabled (again) + [Justin Martin](https://github.com/justinseanmartin) + [#12349](https://github.com/CocoaPods/CocoaPods/issues/12349) ## 1.15.2 (2024-02-06) diff --git a/lib/cocoapods/downloader/cache.rb b/lib/cocoapods/downloader/cache.rb index 5d990e46e2..8cb5c63a78 100644 --- a/lib/cocoapods/downloader/cache.rb +++ b/lib/cocoapods/downloader/cache.rb @@ -283,13 +283,16 @@ def copy_and_clean(source, destination, spec) specs_by_platform = group_subspecs_by_platform(spec) destination.parent.mkpath Cache.write_lock(destination) do - FileUtils.rm_rf(destination) - FileUtils.cp_r(source, destination) + rsync_contents(source, destination) Pod::Installer::PodSourcePreparer.new(spec, destination).prepare! Sandbox::PodDirCleaner.new(destination, specs_by_platform).clean! end end + def rsync_contents(source, destination) + Pod::Executable.execute_command('rsync', ['-a', '--exclude=.git', '--delete', "#{source}/", destination]) + end + def group_subspecs_by_platform(spec) specs_by_platform = {} [spec, *spec.recursive_subspecs].each do |ss| diff --git a/spec/unit/validator_spec.rb b/spec/unit/validator_spec.rb index afdd215824..738782fc53 100644 --- a/spec/unit/validator_spec.rb +++ b/spec/unit/validator_spec.rb @@ -41,6 +41,10 @@ def podspec_path(name = 'JSONKit', version = '1.4', source = nil) source.specification_path(name, version) end + def stub_downloader_cache_rsync + Downloader::Cache.any_instance.expects(:rsync_contents).with { |_, destination| FileUtils.mkdir_p(destination) } + end + #-------------------------------------------------------------------------# describe 'Quick mode' do @@ -786,6 +790,7 @@ def podspec_path(name = 'JSONKit', version = '1.4', source = nil) require 'fourflusher' Fourflusher::SimControl.any_instance.stubs(:destination).returns(['-destination', 'id=XXX']) Validator.any_instance.unstub(:xcodebuild) + stub_downloader_cache_rsync validator = Validator.new(podspec_path, config.sources_manager.master.map(&:url)) validator.stubs(:check_file_patterns) validator.stubs(:validate_url) @@ -803,6 +808,7 @@ def podspec_path(name = 'JSONKit', version = '1.4', source = nil) require 'fourflusher' Fourflusher::SimControl.any_instance.stubs(:destination).returns(['-destination', 'id=XXX']) Validator.any_instance.unstub(:xcodebuild) + stub_downloader_cache_rsync PodTarget.any_instance.stubs(:should_build?).returns(true) Installer::Xcode::PodsProjectGenerator::PodTargetInstaller.any_instance.stubs(:validate_targets_contain_sources) # since we skip downloading validator = Validator.new(podspec_path, config.sources_manager.master.map(&:url)) @@ -833,6 +839,7 @@ def podspec_path(name = 'JSONKit', version = '1.4', source = nil) require 'fourflusher' Fourflusher::SimControl.any_instance.stubs(:destination).returns(['-destination', 'id=XXX']) Validator.any_instance.unstub(:xcodebuild) + stub_downloader_cache_rsync PodTarget.any_instance.stubs(:should_build?).returns(true) Installer::Xcode::PodsProjectGenerator::PodTargetInstaller.any_instance.stubs(:validate_targets_contain_sources) # since we skip downloading validator = Validator.new(podspec_path, config.sources_manager.master.map(&:url)) @@ -864,6 +871,7 @@ def podspec_path(name = 'JSONKit', version = '1.4', source = nil) require 'fourflusher' Fourflusher::SimControl.any_instance.stubs(:destination).returns(['-destination', 'id=XXX']) Validator.any_instance.unstub(:xcodebuild) + stub_downloader_cache_rsync PodTarget.any_instance.stubs(:should_build?).returns(true) Installer::Xcode::PodsProjectGenerator::PodTargetInstaller.any_instance.stubs(:validate_targets_contain_sources) # since we skip downloading validator = Validator.new(podspec_path, config.sources_manager.master.map(&:url)) @@ -897,6 +905,7 @@ def podspec_path(name = 'JSONKit', version = '1.4', source = nil) require 'fourflusher' Fourflusher::SimControl.any_instance.stubs(:destination).returns(['-destination', 'id=XXX']) Validator.any_instance.unstub(:xcodebuild) + stub_downloader_cache_rsync PodTarget.any_instance.stubs(:should_build?).returns(true) Installer::Xcode::PodsProjectGenerator::PodTargetInstaller.any_instance.stubs(:validate_targets_contain_sources) # since we skip downloading validator = Validator.new(podspec_path, config.sources_manager.master.map(&:url)) @@ -931,6 +940,7 @@ def podspec_path(name = 'JSONKit', version = '1.4', source = nil) require 'fourflusher' Fourflusher::SimControl.any_instance.stubs(:destination).returns(['-destination', 'id=XXX']) Validator.any_instance.unstub(:xcodebuild) + stub_downloader_cache_rsync validator = Validator.new(podspec_path, config.sources_manager.master.map(&:url)) validator.stubs(:check_file_patterns) validator.stubs(:validate_url)