Commit c75f1d3d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'dm-tree-last-commit' into 'master'

Show last commit for current tree on tree page

See merge request !11442
parents 319cab41 afef4a66
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
---
title: Show last commit for current tree on tree page
merge_request:
author:
......@@ -31,4 +31,16 @@ feature 'user browses project', feature: true, js: true do
expect(page).to have_content 'oid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897'
expect(page).to have_content 'size 1575078'
end
scenario 'can see last commit for current directory' do
last_commit = project.repository.last_commit_for_path(project.default_branch, 'files')
click_link 'files'
wait_for_ajax
page.within('.blob-commit-info') do
expect(page).to have_content last_commit.short_id
expect(page).to have_content last_commit.author_name
end
end
end
......@@ -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
......
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