2011-03-10 13:33:50 +00:00
|
|
|
module CommitHelper
|
|
|
|
|
|
|
|
def render_commit_stats(stats)
|
|
|
|
res = ["<ul class='diff_stats'>"]
|
|
|
|
stats.files.each do |filename, adds, deletes, total|
|
|
|
|
res << "<li>"
|
|
|
|
res << "<a href='##{h(filename)}'>#{h(filename)}</a> #{total} "
|
|
|
|
res << "<small class='deletions'>#{(0...deletes).map{|i| "-" }.join}</small>"
|
|
|
|
res << "<small class='insertions'>#{(0...adds).map{|i| "+" }.join}</small>"
|
|
|
|
res << "</li>"
|
|
|
|
end
|
|
|
|
res << "</ul>"
|
|
|
|
|
|
|
|
res.join("\n")
|
|
|
|
end
|
|
|
|
|
|
|
|
def format_commit_message(message)
|
2011-04-01 01:36:34 +01:00
|
|
|
h(message).gsub("\n", "<br />").html_safe
|
2011-03-10 13:33:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def commit_date(date)
|
|
|
|
I18n.localize(date, { :format => "%d %B %Y" })
|
|
|
|
end
|
|
|
|
|
2011-04-01 01:36:34 +01:00
|
|
|
def short_hash_id(id)
|
|
|
|
id[0..19]
|
|
|
|
end
|
|
|
|
|
2011-03-10 13:33:50 +00:00
|
|
|
end
|