AwEsOmE blame + minor fixes
This commit is contained in:
parent
74a4a3de13
commit
6120547800
|
@ -5,7 +5,9 @@ class Git::TreesController < Git::BaseController
|
|||
@path = params[:path]
|
||||
|
||||
@tree = @git_repository.tree(@treeish)
|
||||
|
||||
@commit = @git_repository.commits(@treeish, 1).first
|
||||
# @commit = @git_repository.commit(@treeish) unless @commit
|
||||
|
||||
@tree = @tree / @path if @path
|
||||
|
||||
|
|
|
@ -27,4 +27,13 @@ module CommitHelper
|
|||
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 => "...")
|
||||
end
|
||||
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
class Git::Repository
|
||||
delegate :commits, :tree, :tags, :heads, :to => :repo
|
||||
delegate :commits, :commit, :tree, :tags, :heads, :to => :repo
|
||||
|
||||
attr_accessor :path, :name
|
||||
|
||||
|
|
|
@ -1,25 +1,58 @@
|
|||
= render :partial => "git/commits/commit", :locals => { :commit => @commit }
|
||||
.block
|
||||
.secondary-navigation
|
||||
%ul.wat-cf
|
||||
%li.first.active= link_to t("layout.git.repositories.source"), platform_repository_project_repo_path(@platform, @repository, @project)
|
||||
%li= link_to t("layout.git.repositories.commits"), commits_path(@platform, @repository, @project, :treeish => @treeish)
|
||||
|
||||
= link_to "Raw", raw_commit_path(@platform, @repository, @project, @commit.id, @path)
|
||||
= link_to "Normal", blob_commit_path(@platform, @repository, @project, @commit.id, @path)
|
||||
= link_to "History", commits_path(@platform, @repository, @project, @treeish, @path)
|
||||
.content
|
||||
.inner
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.models.project")
|
||||
\:
|
||||
= @project.name
|
||||
|
||||
.row
|
||||
%table{ :class => "blame" }
|
||||
%thead
|
||||
%tr
|
||||
%td
|
||||
%td
|
||||
%td
|
||||
.block
|
||||
.content
|
||||
.inner
|
||||
= render :partial => "git/commits/commits", :object => [@commit]
|
||||
|
||||
%tbody
|
||||
- @blame.each_with_index do |elem, index|
|
||||
%tr
|
||||
%td.message
|
||||
.row= link_to elem[0].id, commit_path(@platform, @repository, @project, elem[0].id)
|
||||
.row= elem[0].committer
|
||||
.row= commit_date(elem[0].committed_date)
|
||||
.row!= format_commit_message(elem[0].message)
|
||||
.block
|
||||
.content
|
||||
.inner
|
||||
%h3= render_path
|
||||
|
||||
%td.line_numbers= index
|
||||
%td.code= elem[1]
|
||||
.blob_header
|
||||
.size #{(@blob.size / 1024.0).round(3)} Kb
|
||||
.buttons
|
||||
#{link_to "Raw", raw_commit_path(@platform, @repository, @project, @commit_hash, @path)} #{link_to "Normal", blob_path(@platform, @repository, @project, @treeish, @path)} #{link_to "History", commits_path(@platform, @repository, @project, @treeish, @path)}
|
||||
.clear
|
||||
.blame_data
|
||||
%table.table.blame
|
||||
- index = 1
|
||||
- @blame.each do |elem|
|
||||
%tr
|
||||
%td.message{ :rowspan => elem[1].length }
|
||||
.commit #{link_to shortest_hash_id(elem[0].id), commit_path(@platform, @repository, @project, elem[0].id)} by #{elem[0].author} #{elem[0].author != elem[0].committer ? "(#{elem[0].committer})" : "" }
|
||||
.message
|
||||
%span.date= commit_date(elem[0].committed_date)
|
||||
%span.message= short_commit_message(elem[0].message)
|
||||
|
||||
%td.lines
|
||||
= index
|
||||
- index += 1
|
||||
|
||||
%td.code
|
||||
%pre
|
||||
%div= elem[1].first
|
||||
|
||||
- elem[1][1..-1].each do |line|
|
||||
%tr
|
||||
%td.lines
|
||||
= index
|
||||
- index += 1
|
||||
%td.code
|
||||
%pre
|
||||
%div= line
|
||||
|
||||
- content_for :sidebar, render(:partial => 'git/shared/sidebar')
|
|
@ -23,4 +23,4 @@
|
|||
.parent
|
||||
Parent:
|
||||
%span{ :style => "float: right;"}
|
||||
#{link_to short_hash_id(parent.id), commit_path(@platform, @repository, @project, parent)}
|
||||
#{link_to short_hash_id(parent.id), tree_path(@platform, @repository, @project, :treeish => parent.id)}
|
|
@ -196,3 +196,53 @@ table.diff .diff-content {
|
|||
float: right;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.blame_data {
|
||||
overflow-x: auto;
|
||||
border-right: 1px solid #EAEAEA;
|
||||
}
|
||||
|
||||
table.blame {
|
||||
line-height: 1.4em;
|
||||
font-family: 'Bitstream Vera Sans Mono','Courier',monospace;
|
||||
border-left: 1px solid #EAEAEA;
|
||||
/*border-right: 1px solid #EAEAEA;*/
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table.blame td {
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
table.blame td.lines {
|
||||
width: auto;
|
||||
text-align: right;
|
||||
background-color: #ECECEC;
|
||||
border-right: 1px solid #DDDDDD;
|
||||
color: #AAAAAA;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
table.blame td.code {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
table.blame td.code pre {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
table.blame td.message {
|
||||
width: auto;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
table.blame td.message .commit {
|
||||
margin: 10px;
|
||||
width: 430px;
|
||||
}
|
||||
|
||||
table.blame td.message .message {
|
||||
margin-bottom: 10px;
|
||||
margin-left: 10px;
|
||||
width: 430px;
|
||||
}
|
Loading…
Reference in New Issue