--
You received this message because you are subscribed to the Google Groups "Calagator Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to calagator-develo...@googlegroups.com.
To post to this group, send email to calagator-...@googlegroups.com.
Visit this group at http://groups.google.com/group/calagator-development.
For more options, visit https://groups.google.com/d/optout.
I don’t have the ability to check on Windows at the moment, but it seems that explicitly converting the returned string to UTF-8 before running the regexp might be a way to skirt this.On July 27, 2014 at 6:25:23 PM, Bryan Stearns (bryans...@gmail.com) wrote:
I'm seeing an intermittent failure running Calagator tests (actually, from loading the Rails environment to run tests with "bundle exec rake"):--/Users/stearns/rad/calagator/app/helpers/application_helper.rb:44:in `match':incompatible encoding regexp match (Windows-31J regexp with UTF-8 string) (Encoding::CompatibilityError)where ApplicationHelper.source_code_version_raw is trying to match the output from a backtick'd git command (which has UTF-8 encoding) with a regex that has a /s switch on it:m = s.match(/^Date: (.+?)$/s)That /s means "Use Windows 31J encoding" (and has since Ruby 1.9.0). I haven't had to mess with Ruby encodings (especially on Windows) so I don't know whether the /s is important -- I'm on Mac, and removing the /s gets rid of the failure.In trying to isolate the failure, I've gone from consistent success with an unrelated uncommited change (to a Rakefile task that isn't even being run!) to having consistent failure after simply committing the change, then consistent success after "git reset HEAD^" (to un-commit it again). I've looked, and the encoding of s is Encoding:UTF-8 in both cases (that is, in situations where it's failing consistently or succeeding consistently.Any suggestions? Anyone know why the /s is needed? Can someone who develops on Windows look to see what encoding a backtick'd git command returns nowadays?Thanks,...Bryan
You received this message because you are subscribed to the Google Groups "Calagator Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to calagator-development+unsub...@googlegroups.com.
Subversion spelunking time! Out of curiosity, I dug into the early history of this bit of code…
Calagator has had its revision in the footer since our first day of development on January 19, 2008. Igal added it in revision 26 using Subversion’s keyword substitution feature.
Three months later, on Mar 2, 2008, support for git-svn revisions was added and the svn support changed to use a shell command. The regular expressions with /s were there from the start in revisions 236 and 250.
For context: Ruby 1.8.7 was released ninety days later, on May 31.
Over time, as this logic moved from the layout into application_helper.rb, got Mercurial support (?!), and underwent some refactoring, the original /s remained.
I would hazard a guess that Igal’s original intention with the /s was probably not to invoke a somewhat-obscure Japanese code page, but instead was a holdover from perl, where it’s used to treat multi-line strings as if they were single-line.
So: I propose we change the /s to Ruby’s equivalent /m and see how things work. (It also might be a good time to drop support for Mercurial and SVN revisions.) We don’t ever want this revision-parsing code to get in the way people trying to work on Calagator, so we may want to widen the set of exceptions caught by the surrounding begin…rescue block.
~Reid
To unsubscribe from this group and stop receiving emails from it, send an email to calagator-develo...@googlegroups.com.