Commit d3b24a76 authored by Douwe Maan's avatar Douwe Maan Committed by Dmitriy Zaporozhets

Show last commit for current tree on tree page

parent fb67ea49
...@@ -42,6 +42,8 @@ class Projects::BlobController < Projects::ApplicationController ...@@ -42,6 +42,8 @@ class Projects::BlobController < Projects::ApplicationController
environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit } environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit }
@environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last @environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last
@last_commit = @repository.last_commit_for_path(@commit.id, @blob.path)
render 'show' render 'show'
end end
......
...@@ -24,6 +24,8 @@ class Projects::TreeController < Projects::ApplicationController ...@@ -24,6 +24,8 @@ class Projects::TreeController < Projects::ApplicationController
end end
end end
@last_commit = @repository.last_commit_for_path(@commit.id, @tree.path) || @commit
respond_to do |format| respond_to do |format|
format.html format.html
# Disable cache so browser history works # Disable cache so browser history works
......
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
.info-well.hidden-xs .info-well.hidden-xs
.well-segment .well-segment
%ul.blob-commit-info %ul.blob-commit-info
- blob_commit = @repository.last_commit_for_path(@commit.id, blob.path) = render 'projects/commits/commit', commit: @last_commit, project: @project, ref: @ref
= render blob_commit, project: @project, ref: @ref
- auxiliary_viewer = blob.auxiliary_viewer - auxiliary_viewer = blob.auxiliary_viewer
- if auxiliary_viewer && !auxiliary_viewer.render_error - if auxiliary_viewer && !auxiliary_viewer.render_error
......
...@@ -7,4 +7,4 @@ ...@@ -7,4 +7,4 @@
= render 'projects/last_push' = render 'projects/last_push'
%div{ class: container_class } %div{ class: container_class }
= render 'projects/files', commit: @commit, project: @project, ref: @ref = render 'projects/files', commit: @last_commit, project: @project, ref: @ref
---
title: Show last commit for current tree on tree page
merge_request:
author:
...@@ -21,11 +21,11 @@ describe 'projects/tree/show' do ...@@ -21,11 +21,11 @@ describe 'projects/tree/show' do
let(:tree) { repository.tree(commit.id, path) } let(:tree) { repository.tree(commit.id, path) }
before do before do
assign(:id, File.join(ref, path))
assign(:ref, ref) assign(:ref, ref)
assign(:commit, commit)
assign(:id, commit.id)
assign(:tree, tree)
assign(:path, path) assign(:path, path)
assign(:last_commit, commit)
assign(:tree, tree)
end end
it 'displays correctly' do it 'displays correctly' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment