Commit aa11287e authored by Samuel E. Giddins's avatar Samuel E. Giddins

[PodSourceInstaller] Allow opting out of pod source locking

Projects opened via pod try are now editable
Closes https://github.com/CocoaPods/cocoapods-try/issues/31
parent cbbe9042
...@@ -4,6 +4,16 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides ...@@ -4,6 +4,16 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
To install release candidates run `[sudo] gem install cocoapods --pre` To install release candidates run `[sudo] gem install cocoapods --pre`
## Master
##### Enhancements
* Allow opting out of pod source locking, meaning `pod try` yields editable
projects.
[Samuel Giddins](https://github.com/segiddins)
[cocoapods-try#31](https://github.com/CocoaPods/cocoapods-try/issues/31)
## 0.37.1 ## 0.37.1
##### Bug Fixes ##### Bug Fixes
......
...@@ -19,6 +19,7 @@ module Pod ...@@ -19,6 +19,7 @@ module Pod
:clean => true, :clean => true,
:integrate_targets => true, :integrate_targets => true,
:lock_pod_source => true,
:new_version_message => ENV['COCOAPODS_SKIP_UPDATE_MESSAGE'].nil?, :new_version_message => ENV['COCOAPODS_SKIP_UPDATE_MESSAGE'].nil?,
:cache_root => Pathname.new(Dir.home) + 'Library/Caches/CocoaPods', :cache_root => Pathname.new(Dir.home) + 'Library/Caches/CocoaPods',
...@@ -71,6 +72,12 @@ module Pod ...@@ -71,6 +72,12 @@ module Pod
attr_accessor :clean attr_accessor :clean
alias_method :clean?, :clean alias_method :clean?, :clean
# @return [Bool] Whether the installer should remove write permissions for
# installed pod source files after the installation.
#
attr_accessor :lock_pod_source
alias_method :lock_pod_source?, :lock_pod_source
# @return [Bool] Whether CocoaPods should integrate a user target and build # @return [Bool] Whether CocoaPods should integrate a user target and build
# the workspace or just create the Pods project. # the workspace or just create the Pods project.
# #
......
...@@ -122,6 +122,7 @@ module Pod ...@@ -122,6 +122,7 @@ module Pod
install_pod_sources install_pod_sources
run_pre_install_hooks run_pre_install_hooks
clean_pod_sources clean_pod_sources
lock_pod_sources
end end
end end
...@@ -316,6 +317,16 @@ module Pod ...@@ -316,6 +317,16 @@ module Pod
@pod_installers.each(&:clean!) @pod_installers.each(&:clean!)
end end
# Locks the sources of the Pods if the config instructs to do so.
#
# @todo Why the @pod_installers might be empty?
#
def lock_pod_sources
return unless config.lock_pod_source?
return unless @pod_installers
@pod_installers.each(&:lock_files!)
end
# Determines if the dependencies need to be built as dynamic frameworks or # Determines if the dependencies need to be built as dynamic frameworks or
# if they can be built as static libraries by checking for the Swift source # if they can be built as static libraries by checking for the Swift source
# presence. Therefore it is important that the file accessors of the # presence. Therefore it is important that the file accessors of the
......
...@@ -44,7 +44,6 @@ module Pod ...@@ -44,7 +44,6 @@ module Pod
def install! def install!
download_source unless predownloaded? || local? download_source unless predownloaded? || local?
PodSourcePreparer.new(root_spec, root).prepare! if local? PodSourcePreparer.new(root_spec, root).prepare! if local?
lock_files!
end end
# Cleans the installations if appropriate. # Cleans the installations if appropriate.
...@@ -58,6 +57,17 @@ module Pod ...@@ -58,6 +57,17 @@ module Pod
clean_installation unless local? clean_installation unless local?
end end
# Locks the source files if appropriate.
#
# @todo As the pre install hooks need to run before cleaning this
# method should be refactored.
#
# @return [void]
#
def lock_files!
lock_installation unless local?
end
# @return [Hash] # @return [Hash]
# #
attr_reader :specific_source attr_reader :specific_source
...@@ -95,11 +105,7 @@ module Pod ...@@ -95,11 +105,7 @@ module Pod
# #
# @return [void] # @return [void]
# #
def lock_files! def lock_installation
if local?
return
end
# We don't want to lock diretories, as that forces you to override # We don't want to lock diretories, as that forces you to override
# those permissions if you decide to delete the Pods folder. # those permissions if you decide to delete the Pods folder.
Dir.glob(root + '**/*').each do |file| Dir.glob(root + '**/*').each do |file|
......
...@@ -180,6 +180,10 @@ module Pod ...@@ -180,6 +180,10 @@ module Pod
@config.should.clean @config.should.clean
end end
it 'locks pod source files' do
@config.should.lock_pod_source
end
it 'returns the cache root' do it 'returns the cache root' do
@config.cache_root.should == Pathname.new(File.join(ENV['HOME'], 'Library/Caches/CocoaPods')) @config.cache_root.should == Pathname.new(File.join(ENV['HOME'], 'Library/Caches/CocoaPods'))
end end
......
...@@ -137,12 +137,14 @@ module Pod ...@@ -137,12 +137,14 @@ module Pod
it 'locks the source files for each Pod' do it 'locks the source files for each Pod' do
File.expects(:chmod).at_least_once File.expects(:chmod).at_least_once
@installer.install! @installer.install!
@installer.lock_files!
end end
it "doesn't lock local pods" do it "doesn't lock local pods" do
@installer.stubs(:local?).returns(true) @installer.stubs(:local?).returns(true)
File.expects(:chmod).never File.expects(:chmod).never
@installer.install! @installer.install!
@installer.lock_files!
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment