Commit e1d1673e74c35fc2d64e71320668d981d634b02a
1 parent
206230a4
Exists in
master
and in
4 other branches
monkey patch grit to support utf8 encoding
Showing
1 changed file
with
17 additions
and
10 deletions
Show diff stats
config/initializers/gitlabhq/20_grit_ext.rb
1 | require 'grit' | 1 | require 'grit' |
2 | require 'pygments' | 2 | require 'pygments' |
3 | 3 | ||
4 | +Grit::Git.git_timeout = GIT_OPTS["git_timeout"] | ||
5 | +Grit::Git.git_max_size = GIT_OPTS["git_max_size"] | ||
6 | + | ||
4 | Grit::Blob.class_eval do | 7 | Grit::Blob.class_eval do |
5 | include Linguist::BlobHelper | 8 | include Linguist::BlobHelper |
6 | -end | ||
7 | 9 | ||
8 | -#monkey patch raw_object from string | ||
9 | -Grit::GitRuby::Internal::RawObject.class_eval do | ||
10 | - def content | ||
11 | - @content | 10 | + def data |
11 | + @data ||= @repo.git.cat_file({:p => true}, id) | ||
12 | + Gitlab::Encode.utf8 @data | ||
12 | end | 13 | end |
13 | end | 14 | end |
14 | 15 | ||
16 | +Grit::Commit.class_eval do | ||
17 | + def message | ||
18 | + Gitlab::Encode.utf8 @message | ||
19 | + end | ||
20 | +end | ||
15 | 21 | ||
16 | Grit::Diff.class_eval do | 22 | Grit::Diff.class_eval do |
17 | def old_path | 23 | def old_path |
18 | - Gitlab::Encode.utf8 a_path | 24 | + Gitlab::Encode.utf8 @a_path |
19 | end | 25 | end |
20 | 26 | ||
21 | def new_path | 27 | def new_path |
22 | - Gitlab::Encode.utf8 b_path | 28 | + Gitlab::Encode.utf8 @b_path |
23 | end | 29 | end |
24 | -end | ||
25 | 30 | ||
26 | -Grit::Git.git_timeout = GIT_OPTS["git_timeout"] | ||
27 | -Grit::Git.git_max_size = GIT_OPTS["git_max_size"] | 31 | + def diff |
32 | + Gitlab::Encode.utf8 @diff | ||
33 | + end | ||
34 | +end |