Commit 5416d0e0 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Pass `@ref` along so we know which pipeline to show

Closes #23615
parent 4028022f
...@@ -192,9 +192,10 @@ class ApplicationController < ActionController::Base ...@@ -192,9 +192,10 @@ class ApplicationController < ActionController::Base
end end
# JSON for infinite scroll via Pager object # JSON for infinite scroll via Pager object
def pager_json(partial, count) def pager_json(partial, count, locals = {})
html = render_to_string( html = render_to_string(
partial, partial,
locals: locals,
layout: false, layout: false,
formats: [:html] formats: [:html]
) )
......
...@@ -26,8 +26,15 @@ class Projects::CommitsController < Projects::ApplicationController ...@@ -26,8 +26,15 @@ class Projects::CommitsController < Projects::ApplicationController
respond_to do |format| respond_to do |format|
format.html format.html
format.json { pager_json("projects/commits/_commits", @commits.size) }
format.atom { render layout: false } format.atom { render layout: false }
format.json do
pager_json(
'projects/commits/_commits',
@commits.size,
project: @project,
ref: @ref)
end
end end
end end
end end
...@@ -352,13 +352,23 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -352,13 +352,23 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def branch_from def branch_from
# This is always source # This is always source
@source_project = @merge_request.nil? ? @project : @merge_request.source_project @source_project = @merge_request.nil? ? @project : @merge_request.source_project
@commit = @repository.commit(params[:ref]) if params[:ref].present?
if params[:ref].present?
@ref = params[:ref]
@commit = @repository.commit(@ref)
end
render layout: false render layout: false
end end
def branch_to def branch_to
@target_project = selected_target_project @target_project = selected_target_project
@commit = @target_project.commit(params[:ref]) if params[:ref].present?
if params[:ref].present?
@ref = params[:ref]
@commit = @target_project.commit(@ref)
end
render layout: false render layout: false
end end
......
...@@ -54,6 +54,11 @@ module CiStatusHelper ...@@ -54,6 +54,11 @@ module CiStatusHelper
custom_icon(icon_name) custom_icon(icon_name)
end end
def render_commit_ref_status(commit, ref = nil, **args)
pipeline = commit.pipelines_for(ref).last
render_pipeline_status(pipeline, **args)
end
def render_commit_status(commit, tooltip_placement: 'auto left') def render_commit_status(commit, tooltip_placement: 'auto left')
project = commit.project project = commit.project
path = pipelines_namespace_project_commit_path(project.namespace, project, commit) path = pipelines_namespace_project_commit_path(project.namespace, project, commit)
......
...@@ -25,9 +25,11 @@ module CommitsHelper ...@@ -25,9 +25,11 @@ module CommitsHelper
end end
end end
def commit_to_html(commit, project, inline = true) def commit_to_html(commit, ref, project)
template = inline ? "inline_commit" : "commit" render 'projects/commits/commit',
render "projects/commits/#{template}", commit: commit, project: project unless commit.nil? commit: commit,
ref: ref,
project: project
end end
# Breadcrumb links for a Project and, if applicable, a tree path # Breadcrumb links for a Project and, if applicable, a tree path
......
...@@ -225,6 +225,10 @@ class Commit ...@@ -225,6 +225,10 @@ class Commit
) )
end end
def pipelines_for(ref)
project.pipelines.where(sha: sha, ref: ref)
end
def pipelines def pipelines
@pipeline ||= project.pipelines.where(sha: sha) @pipeline ||= project.pipelines.where(sha: sha)
end end
......
...@@ -20,13 +20,13 @@ ...@@ -20,13 +20,13 @@
= commit.short_id = commit.short_id
- if commit.status - if commit.status
.visible-xs-inline .visible-xs-inline
= render_commit_status(commit) = render_commit_ref_status(commit, ref)
- if commit.description? - if commit.description?
%a.text-expander.hidden-xs.js-toggle-button ... %a.text-expander.hidden-xs.js-toggle-button ...
.commit-actions.hidden-xs .commit-actions.hidden-xs
- if commit.status - if commit.status
= render_commit_status(commit) = render_commit_ref_status(commit, ref)
= clipboard_button(clipboard_text: commit.id) = clipboard_button(clipboard_text: commit.id)
= link_to commit.short_id, namespace_project_commit_path(project.namespace, project, commit), class: "commit-short-id btn btn-transparent" = link_to commit.short_id, namespace_project_commit_path(project.namespace, project, commit), class: "commit-short-id btn btn-transparent"
= link_to_browse_code(project, commit) = link_to_browse_code(project, commit)
......
...@@ -11,4 +11,4 @@ ...@@ -11,4 +11,4 @@
%li.warning-row.unstyled %li.warning-row.unstyled
#{number_with_delimiter(hidden)} additional commits have been omitted to prevent performance issues. #{number_with_delimiter(hidden)} additional commits have been omitted to prevent performance issues.
- else - else
%ul.content-list= render commits, project: @project %ul.content-list= render commits, project: @project, ref: @ref
- unless defined?(project)
- project = @project
- commits, hidden = limited_commits(@commits) - commits, hidden = limited_commits(@commits)
- commits.chunk { |c| c.committed_date.in_time_zone.to_date }.each do |day, commits| - commits.chunk { |c| c.committed_date.in_time_zone.to_date }.each do |day, commits|
%li.commit-header= "#{day.strftime('%d %b, %Y')} #{pluralize(commits.count, 'commit')}" %li.commit-header= "#{day.strftime('%d %b, %Y')} #{pluralize(commits.count, 'commit')}"
%li.commits-row %li.commits-row
%ul.list-unstyled.commit-list %ul.list-unstyled.commit-list
= render commits, project: project = render commits, project: project, ref: ref
- if hidden > 0 - if hidden > 0
%li.alert.alert-warning %li.alert.alert-warning
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
%div{id: dom_id(@project)} %div{id: dom_id(@project)}
%ol#commits-list.list-unstyled.content_list %ol#commits-list.list-unstyled.content_list
= render "commits", project: @project = render 'commits', project: @project, ref: @ref
= spinner = spinner
:javascript :javascript
......
= commit_to_html(@commit, @source_project, false) = commit_to_html(@commit, @ref, @source_project) if @commit
= commit_to_html(@commit, @target_project, false) = commit_to_html(@commit, @ref, @target_project) if @commit
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
Most recent commits displayed first Most recent commits displayed first
%ol#commits-list.list-unstyled %ol#commits-list.list-unstyled
= render "projects/commits/commits", project: @merge_request.project = render "projects/commits/commits", project: @merge_request.project, ref: @merge_request.source_branch
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