Commit 98b5c364 authored by Saito's avatar Saito

use monkey patch to trancoding content

parent 26deb7e0
...@@ -7,5 +7,23 @@ Grit::Blob.class_eval do ...@@ -7,5 +7,23 @@ Grit::Blob.class_eval do
include Utils::Colorize include Utils::Colorize
end 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_timeout = GIT_OPTS["git_timeout"]
Grit::Git.git_max_size = GIT_OPTS["git_max_size"] Grit::Git.git_max_size = GIT_OPTS["git_max_size"]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment