Commit 016012b14598f65aedec6f859bc47da7b7311ae7
1 parent
ba8048d7
Exists in
master
and in
4 other branches
Fixed: Commit message encoding error
Showing
10 changed files
with
24 additions
and
20 deletions
Show diff stats
app/helpers/commits_helper.rb
@@ -21,13 +21,4 @@ module CommitsHelper | @@ -21,13 +21,4 @@ module CommitsHelper | ||
21 | link_to "More", project_commits_path(@project, :offset => offset.to_i + limit.to_i, :limit => limit), | 21 | link_to "More", project_commits_path(@project, :offset => offset.to_i + limit.to_i, :limit => limit), |
22 | :remote => true, :class => "lite_button vm", :style => "text-align:center; width:930px; ", :id => "more-commits-link" | 22 | :remote => true, :class => "lite_button vm", :style => "text-align:center; width:930px; ", :id => "more-commits-link" |
23 | end | 23 | end |
24 | - | ||
25 | - # Cause some errors with trucate & encoding use this method | ||
26 | - def truncate_commit_message(commit, size = 60) | ||
27 | - message = commit.message | ||
28 | - message.length > size ? (message[0..(size - 1)] + "...") : message | ||
29 | - # if special characters occurs | ||
30 | - rescue | ||
31 | - commit.message | ||
32 | - end | ||
33 | end | 24 | end |
app/views/commits/_commits.html.haml
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" | 11 | = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" |
12 | %p | 12 | %p |
13 | %strong | 13 | %strong |
14 | - = truncate_commit_message(commit) | 14 | + = commit.truncated_message |
15 | = link_to "Browse Code", tree_project_path(@project, :commit_id => commit.id), :class => "lite_button", :style => "float:right" | 15 | = link_to "Browse Code", tree_project_path(@project, :commit_id => commit.id), :class => "lite_button", :style => "float:right" |
16 | = link_to truncate(commit.id.to_s, :length => 16), project_commit_path(@project, :id => commit.id), :class => "lite_button", :style => "width:120px;float:right" | 16 | = link_to truncate(commit.id.to_s, :length => 16), project_commit_path(@project, :id => commit.id), :class => "lite_button", :style => "width:120px;float:right" |
17 | %span | 17 | %span |
app/views/commits/show.html.haml
1 | %h3 | 1 | %h3 |
2 | - = "[ #{@commit.committer} ] #{truncate_commit_message(@commit, 80)}" | 2 | + = "[ #{@commit.committer} ] #{@commit.truncated_message(40)}" |
3 | -#= link_to 'Back', project_commits_path(@project), :class => "button" | 3 | -#= link_to 'Back', project_commits_path(@project), :class => "button" |
4 | %table.round-borders | 4 | %table.round-borders |
5 | %tr | 5 | %tr |
app/views/projects/_recent_commits.html.haml
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" | 6 | = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;" |
7 | %p{:style => "margin-bottom: 3px;"} | 7 | %p{:style => "margin-bottom: 3px;"} |
8 | %strong | 8 | %strong |
9 | - = link_to truncate_commit_message(commit, 60), project_commit_path(@project, :id => commit.id) | 9 | + = link_to commit.truncated_message(60), project_commit_path(@project, :id => commit.id) |
10 | 10 | ||
11 | %span | 11 | %span |
12 | %span.author | 12 | %span.author |
app/views/projects/_recent_messages.html.haml
@@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
19 | - css_class = "dash_commit" | 19 | - css_class = "dash_commit" |
20 | - commit = parent | 20 | - commit = parent |
21 | - item_code = commit.author.email | 21 | - item_code = commit.author.email |
22 | - - link_item_name = truncate_commit_message(commit, 50) | 22 | + - link_item_name = commit.truncated_message(50) |
23 | - link_to_item = project_commit_path(@project, :id => commit.id) | 23 | - link_to_item = project_commit_path(@project, :id => commit.id) |
24 | - else | 24 | - else |
25 | - css_class = "dash_wall" | 25 | - css_class = "dash_wall" |
app/views/projects/_tree.html.haml
@@ -30,15 +30,15 @@ | @@ -30,15 +30,15 @@ | ||
30 | %th Last Update | 30 | %th Last Update |
31 | %th | 31 | %th |
32 | Last commit | 32 | Last commit |
33 | - = link_to "history", project_commits_path(@project, :path => params[:path]), :class => "right" | 33 | + = link_to "history", project_commits_path(@project, :path => params[:path], :branch => params[:branch],:tag => params[:tag]), :class => "right" |
34 | - if params[:path] | 34 | - if params[:path] |
35 | - file = File.join(params[:path], "..") | 35 | - file = File.join(params[:path], "..") |
36 | %tr{ :class => "tree-item", :url => tree_file_project_path(@project, @commit.id, file) } | 36 | %tr{ :class => "tree-item", :url => tree_file_project_path(@project, @commit.id, file) } |
37 | %td.tree-item-file-name | 37 | %td.tree-item-file-name |
38 | = image_tag "dir.png" | 38 | = image_tag "dir.png" |
39 | = link_to "..", tree_file_project_path(@project, @commit.id, file, :branch => @branch, :tag => @tag), :remote => :true | 39 | = link_to "..", tree_file_project_path(@project, @commit.id, file, :branch => @branch, :tag => @tag), :remote => :true |
40 | - %td | ||
41 | - %td | 40 | + %td |
41 | + %td | ||
42 | 42 | ||
43 | - contents.select{ |i| i.is_a?(Grit::Tree)}.each do |content| | 43 | - contents.select{ |i| i.is_a?(Grit::Tree)}.each do |content| |
44 | = render :partial => "projects/tree_item", :locals => { :content => content } | 44 | = render :partial => "projects/tree_item", :locals => { :content => content } |
@@ -52,7 +52,7 @@ | @@ -52,7 +52,7 @@ | ||
52 | }); | 52 | }); |
53 | 53 | ||
54 | - if params[:path] && request.xhr? | 54 | - if params[:path] && request.xhr? |
55 | - :javascript | 55 | + :javascript |
56 | $(window).unbind('popstate'); | 56 | $(window).unbind('popstate'); |
57 | $(window).bind('popstate', function() { | 57 | $(window).bind('popstate', function() { |
58 | if(location.pathname.search("tree") != -1) { | 58 | if(location.pathname.search("tree") != -1) { |
app/views/projects/_tree_file.html.haml
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | %strong | 4 | %strong |
5 | = name | 5 | = name |
6 | = link_to "raw", blob_project_path(@project, :commit_id => @commit.id, :path => params[:path] ), :class => "right", :target => "_blank" | 6 | = link_to "raw", blob_project_path(@project, :commit_id => @commit.id, :path => params[:path] ), :class => "right", :target => "_blank" |
7 | - = link_to "history", project_commits_path(@project, :path => params[:path]), :class => "right", :style => "margin-right:10px;" | 7 | + = link_to "history", project_commits_path(@project, :path => params[:path], :branch => params[:branch], :tag => params[:tag] ), :class => "right", :style => "margin-right:10px;" |
8 | %br/ | 8 | %br/ |
9 | - if file.text? | 9 | - if file.text? |
10 | .view_file_content | 10 | .view_file_content |
@@ -14,6 +14,6 @@ | @@ -14,6 +14,6 @@ | ||
14 | .view_file_content_image | 14 | .view_file_content_image |
15 | %img{ :src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} | 15 | %img{ :src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} |
16 | - else | 16 | - else |
17 | - %p | 17 | + %p |
18 | %center No preview for this file type | 18 | %center No preview for this file type |
19 | 19 |
app/views/projects/_tree_item.html.haml
@@ -12,4 +12,4 @@ | @@ -12,4 +12,4 @@ | ||
12 | = time_ago_in_words(content_commit.committed_date) | 12 | = time_ago_in_words(content_commit.committed_date) |
13 | ago | 13 | ago |
14 | %td | 14 | %td |
15 | - = link_to truncate_commit_message(content_commit, 40), project_commit_path(@project, content_commit) | 15 | + = link_to content_commit.truncated_message(40), project_commit_path(@project, content_commit) |
config/initializers/grit_ext.rb
@@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
1 | +module CommitExt | ||
2 | + # Cause of encoding rails truncate raise error | ||
3 | + # this method is temporary decision | ||
4 | + def truncated_message(size = 80) | ||
5 | + message.length > size ? (message[0..(size - 1)] + "...") : message | ||
6 | + rescue | ||
7 | + "-- invalid encoding for commit message" | ||
8 | + end | ||
9 | +end |