Skip to content
Snippets Groups Projects
Commit a533bdb2 authored by Kamil Trzcińśki's avatar Kamil Trzcińśki
Browse files

Added Merge Requests view

parent 915ad255
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -13,6 +13,8 @@ class PipelinesFinder
from_ids(pipelines, ids_for_ref(pipelines, branches))
when 'tags'
from_ids(pipelines, ids_for_ref(pipelines, tags))
when 'merge_requests'
from_ids(Ci::Pipeline, ids_for_merge_requests(project))
else
pipelines
end
Loading
Loading
@@ -24,6 +26,12 @@ class PipelinesFinder
pipelines.where(ref: refs).group(:ref).select('max(id)')
end
 
def ids_for_merge_requests(project)
Ci::Pipeline.
joins('JOIN merge_requests ON merge_requests.source_project_id=ci_commits.gl_project_id AND merge_requests.source_branch=ci_commits.ref').
where('merge_requests.target_project_id=?', project.id)
end
def from_ids(pipelines, ids)
pipelines.unscoped.where(id: ids)
end
Loading
Loading
Loading
Loading
@@ -27,7 +27,7 @@ module Ci
end
 
def project_id
project.id
gl_project_id
end
 
def valid_commit_sha
Loading
Loading
@@ -161,6 +161,12 @@ module Ci
git_commit_message =~ /(\[ci skip\])/ if git_commit_message
end
 
def merge_request
MergeRequest.includes(:merge_request_diff)
.where(source_branch: ref, source_project_id: gl_project_id)
.reorder(iid: :asc).last
end
private
 
def update_state
Loading
Loading
- status = pipeline.status
- project = pipeline.project_id == @project.id ? @project : pipeline.project
%tr.commit
- if merge_requests
%td.merge-request
- mr = pipeline.merge_request
- if mr
= link_to namespace_project_merge_request_path(project.namespace, project, mr) do
%strong !#{mr.iid}
%td.commit-link
= link_to namespace_project_pipeline_path(@project.namespace, @project, pipeline.id), class: "ci-status ci-#{status}" do
= link_to namespace_project_pipeline_path(project.namespace, project, pipeline.id), class: "ci-status ci-#{status}" do
= ci_icon_for_status(status)
%strong ##{pipeline.id}
 
%td
%div.branch-commit
- if pipeline.ref
= link_to pipeline.ref, namespace_project_commits_path(@project.namespace, @project, pipeline.ref), class: "monospace"
= link_to pipeline.ref, namespace_project_commits_path(project.namespace, project, pipeline.ref), class: "monospace"
·
= link_to pipeline.short_sha, namespace_project_commit_path(@project.namespace, @project, pipeline.sha), class: "commit-id monospace"
= link_to pipeline.short_sha, namespace_project_commit_path(project.namespace, project, pipeline.sha), class: "commit-id monospace"
 
- if pipeline.tag?
%span.label.label-primary tag
Loading
Loading
@@ -25,7 +33,7 @@
 
%p.commit-title
- if commit_data = pipeline.commit_data
= link_to_gfm truncate(commit_data.title, length: 60), namespace_project_commit_path(@project.namespace, @project, commit_data.id), class: "commit-row-message"
= link_to_gfm truncate(commit_data.title, length: 60), namespace_project_commit_path(project.namespace, project, commit_data.id), class: "commit-row-message"
- else
Cant find HEAD commit for this branch
 
Loading
Loading
@@ -36,7 +44,7 @@
- status = stages_status[stage]
- tooltip = "#{stage.titleize}: #{status || 'not found'}"
- if status
= link_to namespace_project_pipeline_path(@project.namespace, @project, pipeline.id, anchor: stage), class: "has-tooltip ci-status-icon-#{status}", title: tooltip do
= link_to namespace_project_pipeline_path(project.namespace, project, pipeline.id, anchor: stage), class: "has-tooltip ci-status-icon-#{status}", title: tooltip do
= ci_icon_for_status(status)
- else
.light.has-tooltip{ title: tooltip }
Loading
Loading
@@ -58,14 +66,14 @@
%ul.dropdown-menu.dropdown-menu-align-right
- artifacts.each do |build|
%li
= link_to download_namespace_project_build_artifacts_path(@project.namespace, @project, build), rel: 'nofollow' do
= link_to download_namespace_project_build_artifacts_path(project.namespace, project, build), rel: 'nofollow' do
= icon("download")
%span #{build.name}
 
- if can?(current_user, :update_pipeline, @project)
- if can?(current_user, :update_pipeline, project)
- if pipeline.retryable?
= link_to retry_namespace_project_pipeline_path(@project.namespace, @project, pipeline.id), class: 'btn has-tooltip', title: "Retry", method: :post do
= link_to retry_namespace_project_pipeline_path(project.namespace, project, pipeline.id), class: 'btn has-tooltip', title: "Retry", method: :post do
= icon("repeat")
- if pipeline.cancelable?
= link_to cancel_namespace_project_pipeline_path(@project.namespace, @project, pipeline.id), class: 'btn btn-remove has-tooltip', title: "Cancel", method: :post do
= link_to cancel_namespace_project_pipeline_path(project.namespace, project, pipeline.id), class: 'btn btn-remove has-tooltip', title: "Cancel", method: :post do
= icon("remove")
Loading
Loading
@@ -25,6 +25,10 @@
= link_to project_pipelines_path(@project, scope: :tags) do
Tags
 
%li{class: ('active' if @scope == 'merge_requests')}
= link_to project_pipelines_path(@project, scope: :merge_requests) do
Merge Requests
.nav-controls
- if can? current_user, :create_pipeline, @project
= link_to new_namespace_project_pipeline_path(@project.namespace, @project), class: 'btn btn-create' do
Loading
Loading
@@ -47,6 +51,8 @@
.table-holder
%table.table.builds
%tbody
- if @scope == 'merge_requests'
%th MR
%th ID
%th Commit
- stages.each do |stage|
Loading
Loading
@@ -55,6 +61,6 @@
= stage.titleize.pluralize
%th Duration
%th
= render @pipelines, commit_sha: true, stage: true, allow_retry: true, stages: stages
= render @pipelines, commit_sha: true, stage: true, allow_retry: true, stages: stages, merge_requests: @scope == 'merge_requests'
 
= paginate @pipelines, theme: 'gitlab'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment