Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error handling around accessing the .netrc #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

##### Bug Fixes

* None.

* Improve handling of users not having access to their netrc file.
[Orta Therox](https://github.com/orta)
[CocoaPods#5411](https://github.com/CocoaPods/CocoaPods/issues/5411)

## 1.0.0 (2016-05-10)

Expand Down
11 changes: 8 additions & 3 deletions lib/pod/command/trunk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,17 @@ def json(response)
end

def netrc
@@netrc ||= Netrc.read
begin
@@netrc ||= Netrc.read
rescue Errno::ENOENT => e
UI.warn 'CocoaPods could not access your ~/.netrc file, '\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will still cause crashes since @@netrc will be nil

'please ensure you have read access to it.'
end
end

def token
ENV['COCOAPODS_TRUNK_TOKEN'] ||
(netrc['trunk.cocoapods.org'] && netrc['trunk.cocoapods.org'].password)
ENV['COCOAPODS_TRUNK_TOKEN'] ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the alignment change?

(netrc['trunk.cocoapods.org'] && netrc['trunk.cocoapods.org'].password)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(netrc['trunk.cocoapods.org'] && netrc['trunk.cocoapods.org'].password)
(Net trace I['trunk.cocoapods.org'] && netrc['trunk.cocoapods.org'].password
```~~

end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~~end```

end


def default_headers
Expand Down