Commit 625c79bc authored by Boris Bügling's avatar Boris Bügling

Merge pull request #4735 from sirlantis/fix-needs-sudo-check

[SourcesManager] Fix wrong sudo recommendation 🌈
parents e28e4c1c a5dd848a
......@@ -4,6 +4,15 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
To install release candidates run `[sudo] gem install cocoapods --pre`
## Master
##### Enhancements
##### Bug Fixes
* Fix suggestion of sudo when it actually isn't needed
[Marcel Jackwerth](https://github.com/sirlantis)
## 1.0.0.beta.2 (2016-01-05)
##### Enhancements
......
......@@ -366,12 +366,10 @@ module Pod
'Update CocoaPods, or checkout the appropriate tag in the repo.'
end
needs_sudo = path_writable?(__FILE__)
if config.new_version_message? && cocoapods_update?(versions)
last = versions['last']
rc = Gem::Version.new(last).prerelease?
install_message = needs_sudo ? 'sudo ' : ''
install_message = needs_sudo? ? 'sudo ' : ''
install_message << 'gem install cocoapods'
install_message << ' --pre' if rc
message = [
......@@ -487,6 +485,12 @@ module Pod
Pathname(path).dirname.writable?
end
# @return [Bool] Whether `gem install` probably needs `sudo` to succeed.
#
def needs_sudo?
!path_writable?(__FILE__)
end
# @return [Source] The git source with the given name. If no git source
# with given name is found it raises.
#
......
......@@ -390,6 +390,16 @@ module Pod
SourcesManager.send(:path_writable?, path).should.be.true
end
it 'knows when sudo is needed' do
SourcesManager.stubs(:path_writable?).returns(false)
SourcesManager.send(:needs_sudo?).should.be.true
end
it 'knows when sudo is not needed' do
SourcesManager.stubs(:path_writable?).returns(true)
SourcesManager.send(:needs_sudo?).should.be.false
end
it 'returns whether a repository is compatible' do
SourcesManager.stubs(:version_information).returns('min' => '0.0.1')
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