From 5e5f6af869be2e0cce0b1e4d19a551a52a78612e Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 13 Sep 2016 13:44:01 +0200 Subject: Add Pipelines for Commit --- app/controllers/projects/commit_controller.rb | 17 +++++++++-------- app/views/projects/commit/_builds.html.haml | 2 +- app/views/projects/commit/_ci_menu.html.haml | 5 +++++ app/views/projects/commit/pipelines.html.haml | 7 +++++++ config/routes.rb | 1 + 5 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 app/views/projects/commit/pipelines.html.haml diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index 02fb3f56890..cdfc1ba7b92 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -10,10 +10,11 @@ class Projects::CommitController < Projects::ApplicationController before_action :require_non_empty_project before_action :authorize_download_code!, except: [:cancel_builds, :retry_builds] before_action :authorize_update_build!, only: [:cancel_builds, :retry_builds] + before_action :authorize_read_pipeline!, only: [:pipelines] before_action :authorize_read_commit_status!, only: [:builds] before_action :commit - before_action :define_commit_vars, only: [:show, :diff_for_path, :builds] - before_action :define_status_vars, only: [:show, :builds] + before_action :define_commit_vars, only: [:show, :diff_for_path, :builds, :pipelines] + before_action :define_status_vars, only: [:show, :builds, :pipelines] before_action :define_note_vars, only: [:show, :diff_for_path] before_action :authorize_edit_tree!, only: [:revert, :cherry_pick] @@ -31,6 +32,9 @@ class Projects::CommitController < Projects::ApplicationController render_diff_for_path(@commit.diffs(diff_options)) end + def pipelines + end + def builds end @@ -96,10 +100,6 @@ class Projects::CommitController < Projects::ApplicationController @noteable = @commit ||= @project.commit(params[:id]) end - def pipelines - @pipelines ||= project.pipelines.where(sha: commit.sha) - end - def ci_builds @ci_builds ||= Ci::Build.where(pipeline: pipelines) end @@ -134,8 +134,9 @@ class Projects::CommitController < Projects::ApplicationController end def define_status_vars - @statuses = CommitStatus.where(pipeline: pipelines).relevant - @builds = Ci::Build.where(pipeline: pipelines).relevant + @ci_pipelines = project.pipelines.where(sha: commit.sha) + @statuses = CommitStatus.where(pipeline: @ci_pipelines).relevant + @builds = Ci::Build.where(pipeline: @ci_pipelines).relevant end def assign_change_commit_vars(mr_source_branch) diff --git a/app/views/projects/commit/_builds.html.haml b/app/views/projects/commit/_builds.html.haml index a508382578a..b7087749428 100644 --- a/app/views/projects/commit/_builds.html.haml +++ b/app/views/projects/commit/_builds.html.haml @@ -1,2 +1,2 @@ -- @pipelines.each do |pipeline| +- @ci_pipelines.each do |pipeline| = render "pipeline", pipeline: pipeline, pipeline_details: true diff --git a/app/views/projects/commit/_ci_menu.html.haml b/app/views/projects/commit/_ci_menu.html.haml index 935433306ea..aae07a3fbd4 100644 --- a/app/views/projects/commit/_ci_menu.html.haml +++ b/app/views/projects/commit/_ci_menu.html.haml @@ -7,3 +7,8 @@ = link_to builds_namespace_project_commit_path(@project.namespace, @project, @commit.id) do Builds %span.badge= @statuses.count + - if can?(current_user, :read_pipeline, @project) + = nav_link(path: 'commit#pipelines') do + = link_to pipelines_namespace_project_commit_path(@project.namespace, @project, @commit.id) do + Pipelines + %span.badge= @ci_pipelines.count diff --git a/app/views/projects/commit/pipelines.html.haml b/app/views/projects/commit/pipelines.html.haml new file mode 100644 index 00000000000..d85d6729a81 --- /dev/null +++ b/app/views/projects/commit/pipelines.html.haml @@ -0,0 +1,7 @@ +- page_title "Pipelines", "#{@commit.title} (#{@commit.short_id})", "Commits" + +.prepend-top-default + = render "commit_box" + += render "ci_menu" += render "pipelines_list", pipelines: @ci_pipelines diff --git a/config/routes.rb b/config/routes.rb index 4d6ec699cbd..ba3864b92be 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -635,6 +635,7 @@ Rails.application.routes.draw do member do get :branches get :builds + get :pipelines post :cancel_builds post :retry_builds post :revert -- cgit v1.2.1 From d4444c53491b3c9f2bd3a3112eacce6de66edc50 Mon Sep 17 00:00:00 2001 From: Luke Bennett Date: Wed, 14 Sep 2016 01:49:41 +0100 Subject: Commit status icon now links to pipelines tab of commit view Removed commit from pipeline list items Used local_assigns and changed to positive naming ffor boolean props --- app/helpers/ci_status_helper.rb | 2 +- app/views/projects/ci/pipelines/_pipeline.html.haml | 19 +++++++++++-------- app/views/projects/commit/_pipelines_list.haml | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb index 639deb7c521..b7f48630bd4 100644 --- a/app/helpers/ci_status_helper.rb +++ b/app/helpers/ci_status_helper.rb @@ -56,7 +56,7 @@ module CiStatusHelper def render_commit_status(commit, tooltip_placement: 'auto left') project = commit.project - path = builds_namespace_project_commit_path(project.namespace, project, commit) + path = pipelines_namespace_project_commit_path(project.namespace, project, commit) render_status_with_link('commit', commit.status, path, tooltip_placement: tooltip_placement) end diff --git a/app/views/projects/ci/pipelines/_pipeline.html.haml b/app/views/projects/ci/pipelines/_pipeline.html.haml index 6391c67021b..04e48a4dc17 100644 --- a/app/views/projects/ci/pipelines/_pipeline.html.haml +++ b/app/views/projects/ci/pipelines/_pipeline.html.haml @@ -1,4 +1,7 @@ - status = pipeline.status +- show_commit = local_assigns.fetch(:show_commit, true) +- show_branch = local_assigns.fetch(:show_branch, true) + %tr.commit %td.commit-link = link_to namespace_project_pipeline_path(pipeline.project.namespace, pipeline.project, pipeline.id) do @@ -10,14 +13,14 @@ .branch-commit = link_to namespace_project_pipeline_path(pipeline.project.namespace, pipeline.project, pipeline.id) do %span ##{pipeline.id} - - if pipeline.ref - - unless defined?(hide_branch) && hide_branch - .icon-container - = pipeline.tag? ? icon('tag') : icon('code-fork') - = link_to pipeline.ref, namespace_project_commits_path(pipeline.project.namespace, pipeline.project, pipeline.ref), class: "monospace branch-name" - .icon-container - = custom_icon("icon_commit") - = link_to pipeline.short_sha, namespace_project_commit_path(pipeline.project.namespace, pipeline.project, pipeline.sha), class: "commit-id monospace" + - if pipeline.ref && show_branch + .icon-container + = pipeline.tag? ? icon('tag') : icon('code-fork') + = link_to pipeline.ref, namespace_project_commits_path(pipeline.project.namespace, pipeline.project, pipeline.ref), class: "monospace branch-name" + - if show_commit + .icon-container + = custom_icon("icon_commit") + = link_to pipeline.short_sha, namespace_project_commit_path(pipeline.project.namespace, pipeline.project, pipeline.sha), class: "commit-id monospace" - if pipeline.latest? %span.label.label-success.has-tooltip{ title: 'Latest build for this branch' } latest - if pipeline.triggered? diff --git a/app/views/projects/commit/_pipelines_list.haml b/app/views/projects/commit/_pipelines_list.haml index 95a8c7b4a5d..fe5f684d3f2 100644 --- a/app/views/projects/commit/_pipelines_list.haml +++ b/app/views/projects/commit/_pipelines_list.haml @@ -11,4 +11,4 @@ %th Stages %th %th - = render pipelines, commit_sha: true, stage: true, allow_retry: true, stages: pipelines.stages, status_icon_only: true, hide_branch: true + = render pipelines, commit_sha: true, stage: true, allow_retry: true, stages: pipelines.stages, status_icon_only: true, show_commit: false -- cgit v1.2.1 From 610a4e02f25104e63bac6f00ae576e3ab96d4c18 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Thu, 15 Sep 2016 21:50:01 +0200 Subject: Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 10f1da4c681..639356e9001 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -32,6 +32,7 @@ v 8.12.0 - Allow to set request_access_enabled for groups and projects - Cleanup misalignments in Issue list view !6206 - Only create a protected branch upon a push to a new branch if a rule for that branch doesn't exist + - Add Pipelines for Commit - Prune events older than 12 months. (ritave) - Prepend blank line to `Closes` message on merge request linked to issue (lukehowell) - Fix issues/merge-request templates dropdown for forked projects -- cgit v1.2.1 From 9c74af1f4751f57014d9186746663aafc728574f Mon Sep 17 00:00:00 2001 From: Luke Bennett Date: Fri, 16 Sep 2016 11:56:51 +0100 Subject: Rearranged commit tabs and changed commit `Commit` column header to `Pipeline` Changed `Commit` column header to `Pipeline` on pipeline index --- app/views/projects/commit/_ci_menu.html.haml | 8 ++++---- app/views/projects/commit/_pipelines_list.haml | 2 +- app/views/projects/pipelines/index.html.haml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/projects/commit/_ci_menu.html.haml b/app/views/projects/commit/_ci_menu.html.haml index aae07a3fbd4..cbfd99ca448 100644 --- a/app/views/projects/commit/_ci_menu.html.haml +++ b/app/views/projects/commit/_ci_menu.html.haml @@ -3,12 +3,12 @@ = link_to namespace_project_commit_path(@project.namespace, @project, @commit.id) do Changes %span.badge= @diffs.size - = nav_link(path: 'commit#builds') do - = link_to builds_namespace_project_commit_path(@project.namespace, @project, @commit.id) do - Builds - %span.badge= @statuses.count - if can?(current_user, :read_pipeline, @project) = nav_link(path: 'commit#pipelines') do = link_to pipelines_namespace_project_commit_path(@project.namespace, @project, @commit.id) do Pipelines %span.badge= @ci_pipelines.count + = nav_link(path: 'commit#builds') do + = link_to builds_namespace_project_commit_path(@project.namespace, @project, @commit.id) do + Builds + %span.badge= @statuses.count diff --git a/app/views/projects/commit/_pipelines_list.haml b/app/views/projects/commit/_pipelines_list.haml index fe5f684d3f2..998812793a2 100644 --- a/app/views/projects/commit/_pipelines_list.haml +++ b/app/views/projects/commit/_pipelines_list.haml @@ -7,7 +7,7 @@ %table.table.builds %tbody %th Status - %th Commit + %th Pipeline %th Stages %th %th diff --git a/app/views/projects/pipelines/index.html.haml b/app/views/projects/pipelines/index.html.haml index faf28db68d1..50c7e5044b2 100644 --- a/app/views/projects/pipelines/index.html.haml +++ b/app/views/projects/pipelines/index.html.haml @@ -46,7 +46,7 @@ %table.table.builds %tbody %th Status - %th Commit + %th Pipeline %th Stages %th %th -- cgit v1.2.1