Merge branch 'master' of github.com:evilmartians/rosa-build
This commit is contained in:
commit
7bec39cd1e
|
@ -0,0 +1,25 @@
|
|||
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)
|
||||
h(message).gsub("\n", "<br />")
|
||||
end
|
||||
|
||||
def commit_date(date)
|
||||
I18n.localize(date, { :format => "%d %B %Y" })
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,36 @@
|
|||
module DiffHelper
|
||||
def render_inline_diff(commit, diff)
|
||||
[render_inline_diff_header(commit, diff), render_inline_diff_body(diff.diff), render_inline_diff_footer].join("\n")
|
||||
end
|
||||
|
||||
def render_inline_diff_header(commit, diff)
|
||||
res = "<a name='#{h(diff.a_path)}'></a>"
|
||||
if diff.b_path.present?
|
||||
res += link_to("view file @ #{commit.id}", blob_commit_path(@platform.name, @project.name, commit.id, diff.b_path))
|
||||
res += "<br />"
|
||||
end
|
||||
|
||||
res += "<table class='diff inline'>
|
||||
<thead>
|
||||
<tr>
|
||||
<td class='comments'> </td>
|
||||
<td class='line_numbers'></td>
|
||||
<td class='line_numbers'></td>
|
||||
<td class=''> </td>
|
||||
</tr>
|
||||
</thead>"
|
||||
|
||||
res
|
||||
end
|
||||
|
||||
def render_inline_diff_body(diff)
|
||||
diff_display ||= Diff::Display::Unified.new(diff)
|
||||
"<tbody>
|
||||
#{diff_display.render(Git::Diff::InlineCallback.new)}
|
||||
</tbody>"
|
||||
end
|
||||
|
||||
def render_inline_diff_footer
|
||||
"</table>"
|
||||
end
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
.commit_row
|
||||
= render :partial => "commit_pane", :locals => { :commit => commit }
|
||||
|
||||
.row= link_to commit.message, commit_path(@platform.name, @project.name, commit.id)
|
|
@ -0,0 +1,7 @@
|
|||
= render :partial => "committer_pane", :locals => { :commit => commit }
|
||||
|
||||
.row.tree Tree: #{link_to @commit.tree.id, tree_path(@platform.name, @project.name, commit.tree.id)}
|
||||
|
||||
.row.parents
|
||||
- commit.parents.each do |parent|
|
||||
Parent: #{link_to parent, commit_path(@platform.name, @project.name, parent)}
|
|
@ -0,0 +1,5 @@
|
|||
- if @commit.committer != @commit.author
|
||||
.row.author Author: #{@commit.author}, #{commit_date(@commit.authored_date)}
|
||||
.row.committer Committer: #{@commit.committer}, #{commit_date(@commit.committed_date)}
|
||||
- else
|
||||
.row.author #{@commit.author}, #{commit_date(@commit.committed_date)}
|
|
@ -0,0 +1,4 @@
|
|||
- if @path.present?
|
||||
%h3 Commits for: #{@path}
|
||||
|
||||
= render :partial => "commit", :collection => @commits
|
|
@ -0,0 +1,14 @@
|
|||
%h3 Commit: #{@commit.id}
|
||||
|
||||
= render :partial => "commit_pane", :locals => { :commit => @commit}
|
||||
|
||||
#{link_to "raw diff", commit_path(@project.title, @repository.name, @commit.id, :diff)} | #{link_to "patch", commit_path(@project.title, @repository.name, @commit.id, :patch)}
|
||||
|
||||
.row.commit_message
|
||||
%code!= format_commit_message(@commit.message)
|
||||
|
||||
.row.commit_stats
|
||||
!= render_commit_stats(@commit.stats)
|
||||
|
||||
- @commit.diffs.each do |diff|
|
||||
!= render_inline_diff(@commit, diff)
|
Loading…
Reference in New Issue