Commit bbafb0b4 authored by Fabio Pelosin's avatar Fabio Pelosin

Merge branch 'check-if-sudo-needed-for-gem-install' of…

Merge branch 'check-if-sudo-needed-for-gem-install' of https://github.com/segiddins/CocoaPods into segiddins-check-if-sudo-needed-for-gem-install

* 'check-if-sudo-needed-for-gem-install' of https://github.com/segiddins/CocoaPods:
  Conditionally include `sudo` in suggested update command

Conflicts:
	spec/unit/sources_manager_spec.rb
parents 72e592d4 6baca709
...@@ -210,9 +210,12 @@ module Pod ...@@ -210,9 +210,12 @@ module Pod
"Update CocoaPods, or checkout the appropriate tag in the repo." "Update CocoaPods, or checkout the appropriate tag in the repo."
end end
needs_sudo = path_writable?(__FILE__)
if config.new_version_message? && cocoapods_update?(versions) if config.new_version_message? && cocoapods_update?(versions)
UI.puts "\nCocoaPods #{versions['last']} is available.\n" \ UI.puts "\nCocoaPods #{versions['last']} is available.\n" \
"To update use: [sudo] gem install cocoapods\n".green "To update use: #{needs_sudo ? 'sudo ' : ''}" \
'gem install cocoapods\n'.green
end end
end end
...@@ -298,6 +301,12 @@ module Pod ...@@ -298,6 +301,12 @@ module Pod
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
private
def path_writable?(path)
Pathname(path).dirname.writable?
end
end end
end end
end end
......
...@@ -164,6 +164,12 @@ module Pod ...@@ -164,6 +164,12 @@ module Pod
e.message.should.match /Repairing-Our-Broken-Specs-Repository/ e.message.should.match /Repairing-Our-Broken-Specs-Repository/
end end
it 'returns whether a path is writable' do
path = '/Users/'
Pathname.any_instance.stubs(:writable?).returns(true)
SourcesManager.send(:path_writable?, path).should.be.true
end
it "returns whether a repository is compatible" do it "returns whether a repository is compatible" do
SourcesManager.stubs(:version_information).returns({ 'min' => '0.0.1' }) SourcesManager.stubs(:version_information).returns({ 'min' => '0.0.1' })
SourcesManager.repo_compatible?('stub').should.be.true SourcesManager.repo_compatible?('stub').should.be.true
......
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