Skip to content
Snippets Groups Projects
Commit 98b5c364 authored by Saito's avatar Saito
Browse files

use monkey patch to trancoding content

parent 26deb7e0
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment