diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-06-08 15:11:52 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-06-08 15:11:52 +0200 |
commit | a533bdb2292b3e5dea44d8072bd2a06da516134f (patch) | |
tree | 62b76066e110edbdac010fcb6213d52c4cccba51 | |
parent | 915ad255cdc7afa9a44ba24eed62f28184e81836 (diff) | |
download | gitlab-ce-merge-requests-view.tar.gz |
Added Merge Requests viewmerge-requests-view
-rw-r--r-- | app/finders/pipelines_finder.rb | 8 | ||||
-rw-r--r-- | app/models/ci/pipeline.rb | 8 | ||||
-rw-r--r-- | app/views/projects/ci/pipelines/_pipeline.html.haml | 26 | ||||
-rw-r--r-- | app/views/projects/pipelines/index.html.haml | 8 |
4 files changed, 39 insertions, 11 deletions
diff --git a/app/finders/pipelines_finder.rb b/app/finders/pipelines_finder.rb index c19a795d467..df2c2fb2294 100644 --- a/app/finders/pipelines_finder.rb +++ b/app/finders/pipelines_finder.rb @@ -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 @@ -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 diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 9b5b46f4928..a4741027121 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -27,7 +27,7 @@ module Ci end def project_id - project.id + gl_project_id end def valid_commit_sha @@ -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 diff --git a/app/views/projects/ci/pipelines/_pipeline.html.haml b/app/views/projects/ci/pipelines/_pipeline.html.haml index a0ffa065067..c1640afe7e8 100644 --- a/app/views/projects/ci/pipelines/_pipeline.html.haml +++ b/app/views/projects/ci/pipelines/_pipeline.html.haml @@ -1,16 +1,24 @@ - 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 @@ -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 @@ -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 } @@ -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") diff --git a/app/views/projects/pipelines/index.html.haml b/app/views/projects/pipelines/index.html.haml index a78450e09d4..f27e8a0140e 100644 --- a/app/views/projects/pipelines/index.html.haml +++ b/app/views/projects/pipelines/index.html.haml @@ -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 @@ -47,6 +51,8 @@ .table-holder %table.table.builds %tbody + - if @scope == 'merge_requests' + %th MR %th ID %th Commit - stages.each do |stage| @@ -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' |