Show last commit for current tree on tree page

This commit is contained in:
Douwe Maan 2017-05-17 09:23:00 -05:00 committed by Dmitriy Zaporozhets
parent fb67ea491b
commit d3b24a7638
6 changed files with 13 additions and 6 deletions

View file

@ -42,6 +42,8 @@ class Projects::BlobController < Projects::ApplicationController
environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit }
@environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last
@last_commit = @repository.last_commit_for_path(@commit.id, @blob.path)
render 'show'
end

View file

@ -24,6 +24,8 @@ class Projects::TreeController < Projects::ApplicationController
end
end
@last_commit = @repository.last_commit_for_path(@commit.id, @tree.path) || @commit
respond_to do |format|
format.html
# Disable cache so browser history works

View file

@ -3,8 +3,7 @@
.info-well.hidden-xs
.well-segment
%ul.blob-commit-info
- blob_commit = @repository.last_commit_for_path(@commit.id, blob.path)
= render blob_commit, project: @project, ref: @ref
= render 'projects/commits/commit', commit: @last_commit, project: @project, ref: @ref
- auxiliary_viewer = blob.auxiliary_viewer
- if auxiliary_viewer && !auxiliary_viewer.render_error

View file

@ -7,4 +7,4 @@
= render 'projects/last_push'
%div{ class: container_class }
= render 'projects/files', commit: @commit, project: @project, ref: @ref
= render 'projects/files', commit: @last_commit, project: @project, ref: @ref

View file

@ -0,0 +1,4 @@
---
title: Show last commit for current tree on tree page
merge_request:
author:

View file

@ -21,11 +21,11 @@ describe 'projects/tree/show' do
let(:tree) { repository.tree(commit.id, path) }
before do
assign(:id, File.join(ref, path))
assign(:ref, ref)
assign(:commit, commit)
assign(:id, commit.id)
assign(:tree, tree)
assign(:path, path)
assign(:last_commit, commit)
assign(:tree, tree)
end
it 'displays correctly' do