Skip to content

Commit

Permalink
Merge pull request #12349 from justinseanmartin/jmartin/12158-redux
Browse files Browse the repository at this point in the history
Fix pod install issue when git's `core.fsmonitor` feature is enabled (again)
  • Loading branch information
justinseanmartin committed Apr 16, 2024
2 parents 54f95f9 + bc5fdc6 commit 028af0b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
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

0 comments on commit 028af0b

Please sign in to comment.