Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pod install issue when git's core.fsmonitor feature is enabled (again) #12349

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions lib/cocoapods/downloader/cache.rb
Expand Up @@ -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|
Expand Down
10 changes: 10 additions & 0 deletions spec/unit/validator_spec.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down