use monkey patch to trancoding content
This commit is contained in:
parent
26deb7e0b5
commit
98b5c3647b
1 changed files with 18 additions and 0 deletions
|
@ -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"]
|
||||
|
|
Loading…
Reference in a new issue