Skip to content

Commit

Permalink
[Repo remove] Handle file permission errors
Browse files Browse the repository at this point in the history
Fixes #1778
  • Loading branch information
kylef committed Feb 16, 2014
1 parent 5a6c839 commit a3ec49e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -19,6 +19,12 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
* Improves `pod init` to save Xcode project file in Podfile when one was supplied.
[Kyle Fuller](https://github.com/kylef)

###### Bug Fixes

* Fixes a bug with `pod repo remove` silently handling permission errors.
[Kyle Fuller](https://github.com/kylef)
#1778


## 0.29.0
[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.28.0...0.29.0)
Expand Down
2 changes: 2 additions & 0 deletions lib/cocoapods/command/repo.rb
Expand Up @@ -163,6 +163,8 @@ def validate!
super
help! 'Deleting a repo needs a `NAME`.' unless @name
help! "repo #{@name} does not exist" unless File.directory?(dir)
help! "You do not have permission to delete the #{@name} repository." \
"Perhaps try prefixing this command with sudo." unless File.writable?(dir)
end

def run
Expand Down
8 changes: 8 additions & 0 deletions spec/functional/command/repo_spec.rb
Expand Up @@ -104,6 +104,14 @@ module Pod
lambda { run_command('repo', 'remove', 'nonexistant') }.should.raise CLAide::Help
end

it "complains if we do not have permission" do
File.stubs(:writable?).returns(false)
upstream = SpecHelper.temporary_directory + 'upstream'
FileUtils.cp_r(test_repo_path, upstream)
lambda { run_command('repo', 'remove', upstream) }.should.raise CLAide::Help
FileUtils.rm_rf(upstream)
end

it "removes a spec-repo" do
upstream = SpecHelper.temporary_directory + 'upstream'
FileUtils.cp_r(test_repo_path, upstream)
Expand Down

0 comments on commit a3ec49e

Please sign in to comment.