diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-10-21 16:22:43 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-10-24 22:26:06 +0800 |
commit | 5416d0e0837f69f35a3a9deaf947fd62e5293661 (patch) | |
tree | 464b29e773327e213a035131ee0f8f2c770f0fd7 | |
parent | 4028022f56f81f9cbe1227dae53c878f702bd8fa (diff) | |
download | gitlab-ce-5416d0e0837f69f35a3a9deaf947fd62e5293661.tar.gz |
Pass `@ref` along so we know which pipeline to show
Closes #23615
-rw-r--r-- | app/controllers/application_controller.rb | 3 | ||||
-rw-r--r-- | app/controllers/projects/commits_controller.rb | 9 | ||||
-rw-r--r-- | app/controllers/projects/merge_requests_controller.rb | 14 | ||||
-rw-r--r-- | app/helpers/ci_status_helper.rb | 5 | ||||
-rw-r--r-- | app/helpers/commits_helper.rb | 8 | ||||
-rw-r--r-- | app/models/commit.rb | 4 | ||||
-rw-r--r-- | app/views/projects/commits/_commit.html.haml | 4 | ||||
-rw-r--r-- | app/views/projects/commits/_commit_list.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/commits/_commits.html.haml | 5 | ||||
-rw-r--r-- | app/views/projects/commits/show.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/merge_requests/branch_from.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/merge_requests/branch_to.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/merge_requests/show/_commits.html.haml | 2 |
13 files changed, 44 insertions, 18 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 37600ed875c..517ad4f03f3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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] ) diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb index c2e7bf1ffec..aba87b6144b 100644 --- a/app/controllers/projects/commits_controller.rb +++ b/app/controllers/projects/commits_controller.rb @@ -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 diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 2ee53f7ceda..eff79b63cee 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -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 diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb index b7f48630bd4..7d1b41b8fbe 100644 --- a/app/helpers/ci_status_helper.rb +++ b/app/helpers/ci_status_helper.rb @@ -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) diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 33dcee49aee..ed402b698fb 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -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 diff --git a/app/models/commit.rb b/app/models/commit.rb index e64fd1e0c1b..02e06657306 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -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 diff --git a/app/views/projects/commits/_commit.html.haml b/app/views/projects/commits/_commit.html.haml index fb48aef0559..00bf812f33f 100644 --- a/app/views/projects/commits/_commit.html.haml +++ b/app/views/projects/commits/_commit.html.haml @@ -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) diff --git a/app/views/projects/commits/_commit_list.html.haml b/app/views/projects/commits/_commit_list.html.haml index 46e4de40042..ce416caa494 100644 --- a/app/views/projects/commits/_commit_list.html.haml +++ b/app/views/projects/commits/_commit_list.html.haml @@ -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 diff --git a/app/views/projects/commits/_commits.html.haml b/app/views/projects/commits/_commits.html.haml index dd12eae8f7e..943ec24cfb5 100644 --- a/app/views/projects/commits/_commits.html.haml +++ b/app/views/projects/commits/_commits.html.haml @@ -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 diff --git a/app/views/projects/commits/show.html.haml b/app/views/projects/commits/show.html.haml index 876c8002627..9628cbd1634 100644 --- a/app/views/projects/commits/show.html.haml +++ b/app/views/projects/commits/show.html.haml @@ -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 diff --git a/app/views/projects/merge_requests/branch_from.html.haml b/app/views/projects/merge_requests/branch_from.html.haml index 4f90dde6fa8..f99f1946a5e 100644 --- a/app/views/projects/merge_requests/branch_from.html.haml +++ b/app/views/projects/merge_requests/branch_from.html.haml @@ -1 +1 @@ -= commit_to_html(@commit, @source_project, false) += commit_to_html(@commit, @ref, @source_project) if @commit diff --git a/app/views/projects/merge_requests/branch_to.html.haml b/app/views/projects/merge_requests/branch_to.html.haml index 67a7a6bcec9..a8b3c5d950a 100644 --- a/app/views/projects/merge_requests/branch_to.html.haml +++ b/app/views/projects/merge_requests/branch_to.html.haml @@ -1 +1 @@ -= commit_to_html(@commit, @target_project, false) += commit_to_html(@commit, @ref, @target_project) if @commit diff --git a/app/views/projects/merge_requests/show/_commits.html.haml b/app/views/projects/merge_requests/show/_commits.html.haml index 0b05785430b..b488f343214 100644 --- a/app/views/projects/merge_requests/show/_commits.html.haml +++ b/app/views/projects/merge_requests/show/_commits.html.haml @@ -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 |