Commit 3d184acc authored by Orta's avatar Orta

Merge pull request #3438 from mglidden/mglidden-readonly

Automatically lock Pod source files after installing (#1154)
parents 6b7aeade 724af1c0
...@@ -13,6 +13,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -13,6 +13,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Samuel Giddins](https://github.com/segiddins) [Samuel Giddins](https://github.com/segiddins)
[#3433](https://github.com/CocoaPods/CocoaPods/issues/3433) [#3433](https://github.com/CocoaPods/CocoaPods/issues/3433)
* Automatically lock Pod source files after installing.
[Mason Glidden](https://github.com/mglidden)
[#1154](https://github.com/CocoaPods/CocoaPods/issues/1154)
## 0.37.0.beta.1 ## 0.37.0.beta.1
......
...@@ -44,6 +44,7 @@ module Pod ...@@ -44,6 +44,7 @@ module Pod
def install! def install!
download_source unless predownloaded? || local? download_source unless predownloaded? || local?
run_prepare_command run_prepare_command
lock_files!
end end
# Cleans the installations if appropriate. # Cleans the installations if appropriate.
...@@ -89,6 +90,25 @@ module Pod ...@@ -89,6 +90,25 @@ module Pod
) )
end end
# Locks all of the files in this pod (source, license, etc). This will
# cause Xcode to warn you if you try to accidently edit one of the files.
#
# @return [void]
#
def lock_files!
if local?
return
end
# We don't want to lock diretories, as that forces you to override
# those permissions if you decide to delete the Pods folder.
Dir.glob(root + '**/*').each do |file|
unless File.directory?(file)
File.chmod(0444, file)
end
end
end
extend Executable extend Executable
executable :bash executable :bash
......
...@@ -132,6 +132,21 @@ module Pod ...@@ -132,6 +132,21 @@ module Pod
end end
#--------------------------------------# #--------------------------------------#
describe 'Locking' do
it 'locks the source files for each Pod' do
File.expects(:chmod).at_least_once
@installer.install!
end
it "doesn't lock local pods" do
@installer.stubs(:local?).returns(true)
File.expects(:chmod).never
@installer.install!
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