Commit c71a76e71a33315977797db3e72be1f76462183f

Authored by Saito
1 parent efd9a717

fix graph problem if authorname or message isnot utf8 encoding

config/initializers/gitlabhq/20_grit_ext.rb
@@ -14,8 +14,23 @@ Grit::Blob.class_eval do @@ -14,8 +14,23 @@ Grit::Blob.class_eval do
14 end 14 end
15 15
16 Grit::Commit.class_eval do 16 Grit::Commit.class_eval do
17 - def message  
18 - Gitlab::Encode.utf8 @message 17 + def to_hash
  18 + {
  19 + 'id' => id,
  20 + 'parents' => parents.map { |p| { 'id' => p.id } },
  21 + 'tree' => tree.id,
  22 + 'message' => Gitlab::Encode.utf8(message),
  23 + 'author' => {
  24 + 'name' => Gitlab::Encode.utf8(author.name),
  25 + 'email' => author.email
  26 + },
  27 + 'committer' => {
  28 + 'name' => Gitlab::Encode.utf8(committer.name),
  29 + 'email' => committer.email
  30 + },
  31 + 'authored_date' => authored_date.xmlschema,
  32 + 'committed_date' => committed_date.xmlschema,
  33 + }
19 end 34 end
20 end 35 end
21 36
lib/graph_commit.rb
@@ -96,13 +96,13 @@ class GraphCommit @@ -96,13 +96,13 @@ class GraphCommit
96 h[:parents] = self.parents.collect do |p| 96 h[:parents] = self.parents.collect do |p|
97 [p.id,0,0] 97 [p.id,0,0]
98 end 98 end
99 - h[:author] = author.name.force_encoding("UTF-8") 99 + h[:author] = author.name
100 h[:time] = time 100 h[:time] = time
101 h[:space] = space 101 h[:space] = space
102 h[:refs] = refs.collect{|r|r.name}.join(" ") unless refs.nil? 102 h[:refs] = refs.collect{|r|r.name}.join(" ") unless refs.nil?
103 h[:id] = sha 103 h[:id] = sha
104 h[:date] = date 104 h[:date] = date
105 - h[:message] = message.force_encoding("UTF-8") 105 + h[:message] = message
106 h[:login] = author.email 106 h[:login] = author.email
107 h 107 h
108 end 108 end