Commit 9a3d665919218ebe30fd1b10a70e75db16675bff

Authored by Dmitriy Zaporozhets
1 parent 35fb7d54

Show last commit for Blob#show

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/assets/stylesheets/sections/tree.scss
... ... @@ -133,3 +133,21 @@
133 133 color: #777;
134 134 }
135 135 }
  136 +
  137 +.blob-commit-info {
  138 + list-style: none;
  139 + margin: 0;
  140 + padding: 0;
  141 + margin-bottom: 10px;
  142 +
  143 + .commit {
  144 + .commit-row-title {
  145 + font-size: 13px;
  146 +
  147 + .commit-row-message {
  148 + font-weight: normal;
  149 + color: #555;
  150 + }
  151 + }
  152 + }
  153 +}
... ...
app/controllers/projects/refs_controller.rb
... ... @@ -34,7 +34,7 @@ class Projects::RefsController &lt; Projects::ApplicationController
34 34 contents = tree.entries
35 35 @logs = contents.map do |content|
36 36 file = params[:path] ? File.join(params[:path], content.name) : content.name
37   - last_commit = @repo.commits(@commit.id, file, 1).last
  37 + last_commit = @repo.last_commit_for_path(@commit.id, file)
38 38 {
39 39 file_name: content.name,
40 40 commit: last_commit
... ...
app/models/repository.rb
... ... @@ -204,4 +204,8 @@ class Repository
204 204 end
205 205 end
206 206 end
  207 +
  208 + def last_commit_for_path(sha, path)
  209 + commits(sha, path, 1).last
  210 + end
207 211 end
... ...
app/views/projects/blob/_blob.html.haml
... ... @@ -15,6 +15,10 @@
15 15 - else
16 16 = link_to title, '#'
17 17  
  18 +%ul.blob-commit-info.bs-callout.bs-callout-info
  19 + - blob_commit = @repository.last_commit_for_path(@commit.id, @blob.path)
  20 + = render blob_commit, project: @project
  21 +
18 22 %div#tree-content-holder.tree-content-holder
19 23 .file-holder
20 24 .file-title
... ...
app/views/projects/blob/show.html.haml
1 1 %div.tree-ref-holder
2 2 = render 'shared/ref_switcher', destination: 'blob', path: @path
  3 +
3 4 %div#tree-holder.tree-holder
4 5 = render 'blob', blob: @blob
5 6  
... ...