From: Saito Date: Wed, 30 May 2012 03:47:26 +0000 (+0800) Subject: fix graph problem if authorname or message isnot utf8 encoding X-Git-Tag: v2.6.0~80^2~4 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=c71a76e71a33315977797db3e72be1f76462183f;p=wvm%2Fgitlab.git fix graph problem if authorname or message isnot utf8 encoding --- diff --git a/config/initializers/gitlabhq/20_grit_ext.rb b/config/initializers/gitlabhq/20_grit_ext.rb index f17cf4415..314553f79 100644 --- a/config/initializers/gitlabhq/20_grit_ext.rb +++ b/config/initializers/gitlabhq/20_grit_ext.rb @@ -14,8 +14,23 @@ Grit::Blob.class_eval do end Grit::Commit.class_eval do - def message - Gitlab::Encode.utf8 @message + def to_hash + { + 'id' => id, + 'parents' => parents.map { |p| { 'id' => p.id } }, + 'tree' => tree.id, + 'message' => Gitlab::Encode.utf8(message), + 'author' => { + 'name' => Gitlab::Encode.utf8(author.name), + 'email' => author.email + }, + 'committer' => { + 'name' => Gitlab::Encode.utf8(committer.name), + 'email' => committer.email + }, + 'authored_date' => authored_date.xmlschema, + 'committed_date' => committed_date.xmlschema, + } end end diff --git a/lib/graph_commit.rb b/lib/graph_commit.rb index 0080e8564..54550d99c 100644 --- a/lib/graph_commit.rb +++ b/lib/graph_commit.rb @@ -96,13 +96,13 @@ class GraphCommit h[:parents] = self.parents.collect do |p| [p.id,0,0] end - h[:author] = author.name.force_encoding("UTF-8") + h[:author] = author.name h[:time] = time h[:space] = space h[:refs] = refs.collect{|r|r.name}.join(" ") unless refs.nil? h[:id] = sha h[:date] = date - h[:message] = message.force_encoding("UTF-8") + h[:message] = message h[:login] = author.email h end