Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Validate on all pod commands that the user is using a terminal in utf-8 #1570

Closed
wants to merge 5 commits into from

4 participants

@Kapin
Collaborator

When finished this should fix #1542. I'm not sure if this is the best way to handle this and what to do with the 1.8.7 case but I think it's a start at least.

@coveralls

Coverage Status

Coverage remained the same when pulling c9e08db on Kapin:utf-8-validation into 525180c on CocoaPods:master.

@coveralls

Coverage Status

Coverage remained the same when pulling 0cfcf4c on Kapin:utf-8-validation into 525180c on CocoaPods:master.

@fabiopelosin

Great!

Some questions:

  • Why did you remove the parenthesis from the if statement? CocoaPods always use them.
  • Should we raise or just print a message in yellow? Not sure about this, just proposing the alternative.
  • I think that we should introduce a little explanation about hot to fix the issue. We could either indicate how to set up the environment directly or link to a relevant resource (for now just an issue, in future maybe a troubleshooting section guides.cocoapods.org).
@Kapin
Collaborator
  1. Removed parenthesis because I was't thinking. I'll restore them.
  2. Raising seems to explode the builder at this point (might be a travis config issue?), but besides that I think that if a user can't use CocoaPods properly without it, I would say it is an error.
  3. The copy was temporary. I'd definitely rather do that :)
@alloy
Owner

Why did you remove the parenthesis from the if statement? CocoaPods always use them.

Is that since the introduction of the new style tool? Although a quick look through the sources does not seem to indicate they are being used in any if statement.

@fabiopelosin

@alloy Actually you're right. I prefer to use the parenthesis though when there is more than one condition tested (i.e. a logic operator is used like &&)

@fabiopelosin

Btw, @Kapin don't forget about the changelog :smile:

@Kapin
Collaborator

@irrationalfab of course. Could you help me look into why travis is breaking? It appears that one of the builders is not using utf-8 encoding :)

@fabiopelosin

@Kapin ah, it looks like your deduction is correct. You could further investigate it with a test commit :-/ it by printing the value of Encoding.default_external. This is one of the reasons why I'm tempted not to raise. CocoaPods works fine in the 99% even without that setting. The issue manifests itself only with certain Pods.

@Kapin
Collaborator

@irrationalfab, fair enough on that point. I'll convert it to a warning.

Kapin added some commits
@Kapin Kapin Use a yellow warning instead of an exception + Changelog
Updated copy as well to be a little bit more useful.
bbf5e04
@Kapin Kapin Merge 5105f98
@Kapin
Collaborator

Wasn't sure the best way of doing the yellow so I improvised. I know we do it elsewhere but I didn't want to start pulling in dependencies all over the place. Once again copy is up for debate but it is better than last time.

@coveralls

Coverage Status

Coverage remained the same when pulling 5105f98 on Kapin:utf-8-validation into aa25ac0 on CocoaPods:master.

@fabiopelosin

@Kapin In this specific case, as it would not be appropriate to import dependencies, as you say, I use a solution similar to yours. However instead of monkey patching the string class (with the same method that later on will be overridden by the colored gem) I would prefer to simply wrap the two strings with the color codes inline. I.e.

puts "\e[33mWARNING: blah blah.\e[0m"
@coveralls

Coverage Status

Coverage remained the same when pulling ad7630d on Kapin:utf-8-validation into aa25ac0 on CocoaPods:master.

@fabiopelosin

Aceness looks great to me!

@Kapin
Collaborator

@irrationalfab merge as is or would you prefer I squash?

@fabiopelosin

As a general rule we prioritize getting things done on keeping a clean history. However in this case I think that a nice squash would be sweet.

@Kapin
Collaborator

@irrationalfab closing this and going to open a squashed one and merge it.

@Kapin Kapin closed this
@fabiopelosin

@Kapin Actually I was wrong :-/ the recommendation, which sounds reasonable to me, from the Ruby Style Guide is:

Don't use parentheses around the condition of an if/unless/while/until.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 10, 2013
  1. @Kapin
  2. @Kapin
Commits on Nov 12, 2013
  1. @Kapin

    Use a yellow warning instead of an exception + Changelog

    Kapin authored
    Updated copy as well to be a little bit more useful.
  2. @Kapin

    Merge

    Kapin authored
  3. @Kapin

    Inlining the yellow

    Kapin authored
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 1 deletion.
  1. +5 −0 CHANGELOG.md
  2. +6 −1 bin/pod
View
5 CHANGELOG.md
@@ -54,6 +54,11 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[Joshua Kalpin](https://github.com/Kapin)
[#1567](https://github.com/CocoaPods/CocoaPods/pull/1567)
+* Users are now warned if their terminal encoding is not UTF-8. This fixes an issue
+ with a small percentage of pod names that are incompatible with ASCII.
+ [Joshua Kalpin](https://github.com/Kapin)
+ [#1570](https://github.com/CocoaPods/CocoaPods/pull/1570)
+
* Dtrace files are now properly left unflagged when installing, regardless of configuration
[Swizzlr](https://github.com/swizzlr)
[#1560](https://github.com/CocoaPods/CocoaPods/pull/1560)
View
7 bin/pod
@@ -1,5 +1,10 @@
#!/usr/bin/env ruby
+if RUBY_VERSION > '1.8.7' && Encoding.default_external != Encoding::UTF_8
+ puts "\e[33mWARNING: CocoaPods requires your terminal to be using UTF-8 encoding."
+ puts "See https://github.com/CocoaPods/guides.cocoapods.org/issues/26 for details on how to fix this\e[0m"
+end
+
if $0 == __FILE__ && !ENV['COCOAPODS_NO_BUNDLER']
ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
require "rubygems"
@@ -10,7 +15,7 @@ elsif ENV['COCOAPODS_NO_BUNDLER']
gem "cocoapods"
end
-if (ENV['CP_STDOUT_SYNC'] == 'TRUE')
+if ENV['CP_STDOUT_SYNC'] == 'TRUE'
STDOUT.sync = true
end
Something went wrong with that request. Please try again.