# -*- encoding : utf-8 -*-
module CommitHelper
def render_commit_stats(stats)
res = ["
"]
stats.files.each do |filename, adds, deletes, total|
res << ""
res << "#{h(filename)} | "
res << "#{total} | "
res << "#{(0...deletes).map{|i| "-" }.join}"
res << "#{(0...adds).map{|i| "+" }.join} | "
res << "
"
end
res << "
"
res.join("\n").encode_to_default.html_safe
end
# def format_commit_message(message)
# h(message).gsub("\n", "
").html_safe
# end
def commit_date(date)
I18n.localize(date, { :format => "%d %B %Y" })
end
def short_hash_id(id)
id[0..19]
end
def shortest_hash_id(id)
id[0..8]
end
def short_commit_message(message)
# Why 42? Because it is the Answer!
truncate(message, :length => 42, :omission => "...").encode_to_default
end
end