Commit 1af84f8ceb8cbe5d6ba5704dd94d7593b0a37429

Authored by Dmitriy Zaporozhets
2 parents 35fb7d54 9a3d6659

Merge branch 'feature/blob_last_commit' into 'master'

Feature: show last commit for Blob#show

Fixes #970
app/assets/stylesheets/sections/tree.scss
@@ -133,3 +133,21 @@ @@ -133,3 +133,21 @@
133 color: #777; 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 < Projects::ApplicationController @@ -34,7 +34,7 @@ class Projects::RefsController < Projects::ApplicationController
34 contents = tree.entries 34 contents = tree.entries
35 @logs = contents.map do |content| 35 @logs = contents.map do |content|
36 file = params[:path] ? File.join(params[:path], content.name) : content.name 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 file_name: content.name, 39 file_name: content.name,
40 commit: last_commit 40 commit: last_commit
app/models/repository.rb
@@ -204,4 +204,8 @@ class Repository @@ -204,4 +204,8 @@ class Repository
204 end 204 end
205 end 205 end
206 end 206 end
  207 +
  208 + def last_commit_for_path(sha, path)
  209 + commits(sha, path, 1).last
  210 + end
207 end 211 end
app/views/projects/blob/_blob.html.haml
@@ -15,6 +15,10 @@ @@ -15,6 +15,10 @@
15 - else 15 - else
16 = link_to title, '#' 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 %div#tree-content-holder.tree-content-holder 22 %div#tree-content-holder.tree-content-holder
19 .file-holder 23 .file-holder
20 .file-title 24 .file-title
app/views/projects/blob/show.html.haml
1 %div.tree-ref-holder 1 %div.tree-ref-holder
2 = render 'shared/ref_switcher', destination: 'blob', path: @path 2 = render 'shared/ref_switcher', destination: 'blob', path: @path
  3 +
3 %div#tree-holder.tree-holder 4 %div#tree-holder.tree-holder
4 = render 'blob', blob: @blob 5 = render 'blob', blob: @blob
5 6