Pass @ref along so we know which pipeline to show

Closes #23615
This commit is contained in:
Lin Jen-Shin 2016-10-21 16:22:43 +08:00
parent 4028022f56
commit 5416d0e083
13 changed files with 44 additions and 18 deletions

View file

@ -192,9 +192,10 @@ class ApplicationController < ActionController::Base
end
# JSON for infinite scroll via Pager object
def pager_json(partial, count)
def pager_json(partial, count, locals = {})
html = render_to_string(
partial,
locals: locals,
layout: false,
formats: [:html]
)

View file

@ -26,8 +26,15 @@ class Projects::CommitsController < Projects::ApplicationController
respond_to do |format|
format.html
format.json { pager_json("projects/commits/_commits", @commits.size) }
format.atom { render layout: false }
format.json do
pager_json(
'projects/commits/_commits',
@commits.size,
project: @project,
ref: @ref)
end
end
end
end

View file

@ -352,13 +352,23 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def branch_from
# This is always source
@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
end
def branch_to
@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
end

View file

@ -54,6 +54,11 @@ module CiStatusHelper
custom_icon(icon_name)
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')
project = commit.project
path = pipelines_namespace_project_commit_path(project.namespace, project, commit)

View file

@ -25,9 +25,11 @@ module CommitsHelper
end
end
def commit_to_html(commit, project, inline = true)
template = inline ? "inline_commit" : "commit"
render "projects/commits/#{template}", commit: commit, project: project unless commit.nil?
def commit_to_html(commit, ref, project)
render 'projects/commits/commit',
commit: commit,
ref: ref,
project: project
end
# Breadcrumb links for a Project and, if applicable, a tree path

View file

@ -225,6 +225,10 @@ class Commit
)
end
def pipelines_for(ref)
project.pipelines.where(sha: sha, ref: ref)
end
def pipelines
@pipeline ||= project.pipelines.where(sha: sha)
end

View file

@ -20,13 +20,13 @@
= commit.short_id
- if commit.status
.visible-xs-inline
= render_commit_status(commit)
= render_commit_ref_status(commit, ref)
- if commit.description?
%a.text-expander.hidden-xs.js-toggle-button ...
.commit-actions.hidden-xs
- if commit.status
= render_commit_status(commit)
= render_commit_ref_status(commit, ref)
= 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_browse_code(project, commit)

View file

@ -11,4 +11,4 @@
%li.warning-row.unstyled
#{number_with_delimiter(hidden)} additional commits have been omitted to prevent performance issues.
- else
%ul.content-list= render commits, project: @project
%ul.content-list= render commits, project: @project, ref: @ref

View file

@ -1,13 +1,10 @@
- unless defined?(project)
- project = @project
- commits, hidden = limited_commits(@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.commits-row
%ul.list-unstyled.commit-list
= render commits, project: project
= render commits, project: project, ref: ref
- if hidden > 0
%li.alert.alert-warning

View file

@ -35,7 +35,7 @@
%div{id: dom_id(@project)}
%ol#commits-list.list-unstyled.content_list
= render "commits", project: @project
= render 'commits', project: @project, ref: @ref
= spinner
:javascript

View file

@ -1 +1 @@
= commit_to_html(@commit, @source_project, false)
= commit_to_html(@commit, @ref, @source_project) if @commit

View file

@ -1 +1 @@
= commit_to_html(@commit, @target_project, false)
= commit_to_html(@commit, @ref, @target_project) if @commit

View file

@ -3,4 +3,4 @@
Most recent commits displayed first
%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