Commit b97a46f7 authored by Jonas Wälter's avatar Jonas Wälter Committed by David Kim

Fix signature badge on commits tab of merge request

parent 8131801a
......@@ -176,7 +176,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
# or from cache if already merged
@commits =
set_commits_for_rendering(
@merge_request.recent_commits.with_latest_pipeline(@merge_request.source_branch).with_markdown_cache,
@merge_request.recent_commits(load_from_gitaly: true).with_latest_pipeline(@merge_request.source_branch).with_markdown_cache,
commits_count: @merge_request.commits_count
)
......
......@@ -615,8 +615,8 @@ class MergeRequest < ApplicationRecord
context_commits.count
end
def commits(limit: nil)
return merge_request_diff.commits(limit: limit) if merge_request_diff.persisted?
def commits(limit: nil, load_from_gitaly: false)
return merge_request_diff.commits(limit: limit, load_from_gitaly: load_from_gitaly) if merge_request_diff.persisted?
commits_arr = if compare_commits
reversed_commits = compare_commits.reverse
......@@ -628,8 +628,8 @@ class MergeRequest < ApplicationRecord
CommitCollection.new(source_project, commits_arr, source_branch)
end
def recent_commits
commits(limit: MergeRequestDiff::COMMITS_SAFE_SIZE)
def recent_commits(load_from_gitaly: false)
commits(limit: MergeRequestDiff::COMMITS_SAFE_SIZE, load_from_gitaly: load_from_gitaly)
end
def commits_count
......
......@@ -288,9 +288,9 @@ class MergeRequestDiff < ApplicationRecord
end
end
def commits(limit: nil)
strong_memoize(:"commits_#{limit || 'all'}") do
load_commits(limit: limit)
def commits(limit: nil, load_from_gitaly: false)
strong_memoize(:"commits_#{limit || 'all'}_#{load_from_gitaly}") do
load_commits(limit: limit, load_from_gitaly: load_from_gitaly)
end
end
......@@ -700,9 +700,14 @@ class MergeRequestDiff < ApplicationRecord
end
end
def load_commits(limit: nil)
commits = merge_request_diff_commits.with_users.limit(limit)
.map { |commit| Commit.from_hash(commit.to_hash, project) }
def load_commits(limit: nil, load_from_gitaly: false)
if load_from_gitaly
commits = Gitlab::Git::Commit.batch_by_oid(repository, merge_request_diff_commits.limit(limit).map(&:sha))
commits = Commit.decorate(commits, project)
else
commits = merge_request_diff_commits.with_users.limit(limit)
.map { |commit| Commit.from_hash(commit.to_hash, project) }
end
CommitCollection
.new(merge_request.source_project, commits, merge_request.source_branch)
......
......@@ -21,7 +21,7 @@ RSpec.describe 'projects/merge_requests/_commits.html.haml', :sidekiq_might_not_
controller.prepend_view_path('app/views/projects')
assign(:merge_request, merge_request)
assign(:commits, merge_request.commits)
assign(:commits, merge_request.commits(load_from_gitaly: true))
assign(:hidden_commit_count, 0)
end
......@@ -34,6 +34,12 @@ RSpec.describe 'projects/merge_requests/_commits.html.haml', :sidekiq_might_not_
expect(rendered).to have_link(href: href)
end
it 'shows signature verification badge' do
render
expect(rendered).to have_css('.gpg-status-box')
end
context 'when there are hidden commits' do
before do
assign(:hidden_commit_count, 1)
......
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