diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2011-12-31 01:20:16 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2011-12-31 01:20:16 +0400 |
commit | d34904b86c07f6a408bbd4496ea23a23f1208ec5 (patch) | |
tree | 89efb2d01d3ecc65c1b67322d002bf3a894b80a4 /config | |
parent | e33aab0b21e38f4cf7aed8bb6451d737fcefe110 (diff) | |
parent | 31f3d6efb3b4b3f4ae5ffd64455cc2e26106a61d (diff) |
Merge branch 'grit_ext'
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/gitlabhq/20_grit_ext.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/config/initializers/gitlabhq/20_grit_ext.rb b/config/initializers/gitlabhq/20_grit_ext.rb index 356844537aa..d9f2c001804 100644 --- a/config/initializers/gitlabhq/20_grit_ext.rb +++ b/config/initializers/gitlabhq/20_grit_ext.rb @@ -7,5 +7,23 @@ Grit::Blob.class_eval do include Utils::Colorize end +#monkey patch raw_object from string +Grit::GitRuby::Internal::RawObject.class_eval do + def content + transcoding(@content) + end + + private + def transcoding(content) + content ||= "" + detection = CharlockHolmes::EncodingDetector.detect(content) + if hash = detection + content = CharlockHolmes::Converter.convert(content, hash[:encoding], 'UTF-8') if hash[:encoding] + end + content + end +end + + Grit::Git.git_timeout = GIT_OPTS["git_timeout"] Grit::Git.git_max_size = GIT_OPTS["git_max_size"] |