diff options
-rw-r--r-- | app/controllers/ci/builds_controller.rb | 40 | ||||
-rw-r--r-- | app/controllers/ci/commits_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/projects/builds_controller.rb | 2 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 4 | ||||
-rw-r--r-- | app/helpers/ci/commits_helper.rb | 24 | ||||
-rw-r--r-- | app/views/ci/admin/builds/_build.html.haml | 6 | ||||
-rw-r--r-- | app/views/ci/admin/runners/show.html.haml | 10 | ||||
-rw-r--r-- | app/views/ci/builds/_build.html.haml | 49 | ||||
-rw-r--r-- | app/views/ci/builds/show.html.haml | 165 | ||||
-rw-r--r-- | app/views/ci/commits/_commit.html.haml | 2 | ||||
-rw-r--r-- | app/views/ci/commits/show.html.haml | 89 | ||||
-rw-r--r-- | app/views/layouts/ci/build.html.haml | 11 | ||||
-rw-r--r-- | app/views/layouts/ci/commit.html.haml | 11 | ||||
-rw-r--r-- | config/routes.rb | 6 |
14 files changed, 25 insertions, 400 deletions
diff --git a/app/controllers/ci/builds_controller.rb b/app/controllers/ci/builds_controller.rb index bf87f81439a..daf3bcf72a9 100644 --- a/app/controllers/ci/builds_controller.rb +++ b/app/controllers/ci/builds_controller.rb @@ -1,41 +1,11 @@ module Ci class BuildsController < Ci::ApplicationController - before_action :authenticate_user!, except: [:status, :show] - before_action :authenticate_public_page!, only: :show + before_action :authenticate_user!, except: [:status] before_action :project - before_action :authorize_access_project!, except: [:status, :show] - before_action :authorize_manage_project!, except: [:status, :show, :retry, :cancel] + before_action :authorize_access_project!, except: [:status] + before_action :authorize_manage_project!, except: [:status, :retry, :cancel] before_action :authorize_manage_builds!, only: [:retry, :cancel] - before_action :build, except: [:show] - layout 'ci/build' - - def show - if params[:id] =~ /\A\d+\Z/ - @build = build - else - # try to find commit by sha - commit = commit_by_sha - - if commit - # Redirect to commit page - redirect_to ci_project_commit_path(@project, @build.commit) - return - end - end - - raise ActiveRecord::RecordNotFound unless @build - - @builds = @project.commits.find_by_sha(@build.sha).builds.order('id DESC') - @builds = @builds.where("id not in (?)", @build.id).page(params[:page]).per(20) - @commit = @build.commit - - respond_to do |format| - format.html - format.json do - render json: @build.to_json(methods: :trace_html) - end - end - end + before_action :build def retry if @build.commands.blank? @@ -68,7 +38,7 @@ module Ci end def build - @build ||= project.builds.unscoped.find_by(id: params[:id]) + @build ||= project.builds.unscoped.find_by!(id: params[:id]) end def commit_by_sha diff --git a/app/controllers/ci/commits_controller.rb b/app/controllers/ci/commits_controller.rb index 887e92f84cf..404e0e4b412 100644 --- a/app/controllers/ci/commits_controller.rb +++ b/app/controllers/ci/commits_controller.rb @@ -5,12 +5,6 @@ module Ci before_action :project before_action :authorize_access_project!, except: [:status, :show, :cancel] before_action :authorize_manage_builds!, only: [:cancel] - before_action :commit, only: :show - layout 'ci/commit' - - def show - @builds = @commit.builds - end def status commit = Ci::Project.find(params[:project_id]).commits.find_by_sha!(params[:id]) diff --git a/app/controllers/projects/builds_controller.rb b/app/controllers/projects/builds_controller.rb index 9bb1a9e14ed..76c7f31f61b 100644 --- a/app/controllers/projects/builds_controller.rb +++ b/app/controllers/projects/builds_controller.rb @@ -20,6 +20,6 @@ class Projects::BuildsController < Projects::ApplicationController private def build - @build ||= ci_project.builds.unscoped.find_by(id: params[:id]) + @build ||= ci_project.builds.unscoped.find_by!(id: params[:id]) end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3ab44719d9f..cab2278adb7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -314,4 +314,8 @@ module ApplicationHelper html.html_safe end + + def truncate_first_line(message, length = 50) + truncate(message.each_line.first.chomp, length: length) if message + end end diff --git a/app/helpers/ci/commits_helper.rb b/app/helpers/ci/commits_helper.rb deleted file mode 100644 index a0df4c3d72d..00000000000 --- a/app/helpers/ci/commits_helper.rb +++ /dev/null @@ -1,24 +0,0 @@ -module Ci - module CommitsHelper - def ci_commit_path(commit) - ci_project_commits_path(commit.project, commit) - end - - def commit_link(commit) - link_to(commit.short_sha, ci_commit_path(commit)) - end - - def truncate_first_line(message, length = 50) - truncate(message.each_line.first.chomp, length: length) if message - end - - def ci_commit_title(commit) - content_tag :span do - link_to( - simple_sanitize(commit.project.name), ci_project_path(commit.project) - ) + ' @ ' + - gitlab_commit_link(@project, @commit.sha) - end - end - end -end diff --git a/app/views/ci/admin/builds/_build.html.haml b/app/views/ci/admin/builds/_build.html.haml index 778d51d03be..2df58713214 100644 --- a/app/views/ci/admin/builds/_build.html.haml +++ b/app/views/ci/admin/builds/_build.html.haml @@ -1,14 +1,16 @@ +- gl_project = build.project.gl_project - if build.commit && build.project %tr.build %td.build-link - = link_to ci_project_build_url(build.project, build) do + = link_to namespace_project_build_path(gl_project.namespace, gl_project, build) do %strong #{build.id} %td.status = ci_status_with_icon(build.status) %td.commit-link - = commit_link(build.commit) + = link_to ci_status_path(build.commit) do + %strong #{build.commit.short_sha} %td.runner - if build.runner diff --git a/app/views/ci/admin/runners/show.html.haml b/app/views/ci/admin/runners/show.html.haml index 09905e0eb47..5bb442cbf92 100644 --- a/app/views/ci/admin/runners/show.html.haml +++ b/app/views/ci/admin/runners/show.html.haml @@ -96,6 +96,7 @@ %table.builds.runner-builds %thead %tr + %th Build ID %th Status %th Project %th Commit @@ -103,6 +104,11 @@ - @builds.each do |build| %tr.build + %td.id + - gl_project = build.project.gl_project + = link_to namespace_project_build_path(gl_project.namespace, gl_project, build) do + = build.id + %td.status = ci_status_with_icon(build.status) @@ -110,8 +116,8 @@ = build.project.name %td.build-link - = link_to ci_project_build_path(build.project, build) do - %strong #{build.short_sha} + = link_to ci_status_path(build.commit) do + %strong #{build.commit.short_sha} %td.timestamp - if build.finished_at diff --git a/app/views/ci/builds/_build.html.haml b/app/views/ci/builds/_build.html.haml deleted file mode 100644 index 8ccc0dff2fb..00000000000 --- a/app/views/ci/builds/_build.html.haml +++ /dev/null @@ -1,49 +0,0 @@ -%tr.build - %td.status - = ci_status_with_icon(build.status) - - %td.build-link - = link_to ci_project_build_path(build.project, build) do - %strong Build ##{build.id} - - - if defined?(ref) - %td - = build.ref - - %td - = build.stage - - %td - = build.name - .pull-right - - if build.tags.any? - - build.tag_list.each do |tag| - %span.label.label-primary - = tag - - if build.trigger_request - %span.label.label-info triggered - - if build.allow_failure - %span.label.label-danger allowed to fail - - %td.duration - - if build.duration - #{duration_in_words(build.finished_at, build.started_at)} - - %td.timestamp - - if build.finished_at - %span #{time_ago_in_words build.finished_at} ago - - - if build.project.coverage_enabled? - %td.coverage - - if build.coverage - #{build.coverage}% - - %td - - if defined?(controls) && current_user && can?(current_user, :manage_builds, gl_project) - .pull-right - - if build.active? - = link_to cancel_ci_project_build_path(build.project, build, return_to: request.original_url), title: 'Cancel build' do - %i.fa.fa-remove.cred - - elsif build.commands.present? - = link_to retry_ci_project_build_path(build.project, build, return_to: request.original_url), method: :post, title: 'Retry build' do - %i.fa.fa-repeat diff --git a/app/views/ci/builds/show.html.haml b/app/views/ci/builds/show.html.haml deleted file mode 100644 index be33c5e8aa4..00000000000 --- a/app/views/ci/builds/show.html.haml +++ /dev/null @@ -1,165 +0,0 @@ -#up-build-trace -- if @commit.matrix_for_ref?(@build.ref) - %ul.center-top-menu - - @commit.builds_without_retry_for_ref(@build.ref).each do |build| - %li{class: ('active' if build == @build) } - = link_to ci_project_build_url(@project, build) do - = ci_icon_for_status(build.status) - %span - - if build.name - = build.name - - else - = build.id - - - - unless @commit.builds_without_retry_for_ref(@build.ref).include?(@build) - %li.active - %a - Build ##{@build.id} - · - %i.fa.fa-warning-sign - This build was retried. - -.gray-content-block - .build-head - %h4 - - if @build.commit.tag? - Build for tag - %code #{@build.ref} - - else - Build for commit - %strong.monospace= commit_link(@build.commit) - from - - = link_to ci_project_path(@build.project, ref: @build.ref) do - %strong.monospace= "#{@build.ref}" - - - if @build.duration - .pull-right - %span - %i.fa.fa-time - #{duration_in_words(@build.finished_at, @build.started_at)} - - .clearfix - = ci_status_with_icon(@build.status) - .pull-right - = @build.updated_at.stamp('19:00 Aug 27') - -.row.prepend-top-default - .col-md-9 - .clearfix - - if @build.active? - .autoscroll-container - %button.btn.btn-success.btn-sm#autoscroll-button{:type => "button", :data => {:state => 'disabled'}} enable autoscroll - .clearfix - .scroll-controls - = link_to '#up-build-trace', class: 'btn' do - %i.fa.fa-angle-up - = link_to '#down-build-trace', class: 'btn' do - %i.fa.fa-angle-down - - %pre.trace#build-trace - %code.bash - = preserve do - = raw @build.trace_html - %div#down-build-trace - - .col-md-3 - - if @build.coverage - .build-widget - %h4.title - Test coverage - %h1 #{@build.coverage}% - - - .build-widget - %h4.title - Build - - if current_user && can?(current_user, :manage_builds, gl_project) - .pull-right - - if @build.active? - = link_to "Cancel", cancel_ci_project_build_path(@project, @build), class: 'btn btn-sm btn-danger' - - elsif @build.commands.present? - = link_to "Retry", retry_ci_project_build_path(@project, @build), class: 'btn btn-sm btn-primary', method: :post - - - if @build.duration - %p - %span.attr-name Duration: - #{duration_in_words(@build.finished_at, @build.started_at)} - %p - %span.attr-name Created: - #{time_ago_in_words(@build.created_at)} ago - - if @build.finished_at - %p - %span.attr-name Finished: - #{time_ago_in_words(@build.finished_at)} ago - %p - %span.attr-name Runner: - - if @build.runner && current_user && current_user.admin - \#{link_to "##{@build.runner.id}", ci_admin_runner_path(@build.runner.id)} - - elsif @build.runner - \##{@build.runner.id} - - - if @build.trigger_request - .build-widget - %h4.title - Trigger - - %p - %span.attr-name Token: - #{@build.trigger_request.trigger.short_token} - - - if @build.trigger_request.variables - %p - %span.attr-name Variables: - - %code - - @build.trigger_request.variables.each do |key, value| - #{key}=#{value} - - .build-widget - %h4.title - Commit - .pull-right - %small #{build_commit_link @build} - %p - %span.attr-name Branch: - #{build_ref_link @build} - %p - %span.attr-name Author: - #{@build.commit.git_author_name} - %p - %span.attr-name Message: - #{@build.commit.git_commit_message} - - - if @build.tags.any? - .build-widget - %h4.title - Tags - - @build.tag_list.each do |tag| - %span.label.label-primary - = tag - - - if @builds.present? - .build-widget - %h4.title #{pluralize(@builds.count, "other build")} for #{@build.short_sha}: - %table.builds - - @builds.each_with_index do |build, i| - %tr.build - %td - = ci_icon_for_status(build.status) - %td - = link_to ci_project_build_url(@project, build) do - - if build.name - = build.name - - else - %span ##{build.id} - - %td.status= build.status - - - = paginate @builds - - -:javascript - new CiBuild("#{ci_project_build_url(@project, @build)}", "#{@build.status}") diff --git a/app/views/ci/commits/_commit.html.haml b/app/views/ci/commits/_commit.html.haml index 6e6cc9b2c37..b24a3b826cf 100644 --- a/app/views/ci/commits/_commit.html.haml +++ b/app/views/ci/commits/_commit.html.haml @@ -7,7 +7,7 @@ %td.build-link - = link_to ci_project_commits_path(commit.project, commit.sha) do + = link_to ci_status_path(commit) do %strong #{commit.short_sha} %td.build-message diff --git a/app/views/ci/commits/show.html.haml b/app/views/ci/commits/show.html.haml deleted file mode 100644 index 7ebef8c5e06..00000000000 --- a/app/views/ci/commits/show.html.haml +++ /dev/null @@ -1,89 +0,0 @@ -.commit-info - .append-bottom-20 - = ci_status_with_icon(@commit.status) - - .gray-content-block.middle-block - %pre.commit-message - - if @commit.git_commit_message - #{@commit.git_commit_message} - - else - No commit message - - .gray-content-block.second-block - .row - .col-sm-6 - %p - %span.attr-name Commit: - #{gitlab_commit_link(@project, @commit.sha)} - %p - - if @commit.refs.present? - %span.attr-name Refs: - - @commit.refs.each do |ref| - #{gitlab_ref_link(@project, ref)} - .col-sm-6 - - if @commit.git_author_name || @commit.git_author_email - %p - %span.attr-name Author: - #{@commit.git_author_name} (#{@commit.git_author_email}) - - if @commit.created_at - %p - %span.attr-name Created at: - #{@commit.created_at.to_s(:short)} - - - if current_user && can?(current_user, :manage_builds, gl_project) - - if @commit.builds.running_or_pending.any? - .pull-right - = link_to "Cancel", cancel_ci_project_commits_path(@project, @commit), class: 'btn btn-sm btn-danger' - - -- if @commit.yaml_errors.present? - .bs-callout.bs-callout-danger - %h4 Found errors in your .gitlab-ci.yml: - %ul - - @commit.yaml_errors.split(",").each do |error| - %li= error - -- unless @commit.ci_yaml_file - .bs-callout.bs-callout-warning - \.gitlab-ci.yml not found in this commit - -- @commit.refs.each do |ref| - %h3 - Builds for #{gitlab_ref_link(@project, ref)} - - if @commit.duration_for_ref(ref) > 0 - %small.pull-right - %i.fa.fa-time - #{time_interval_in_words @commit.duration_for_ref(ref)} - - %table.table.builds - %thead - %tr - %th Status - %th Build ID - %th Stage - %th Name - %th Duration - %th Finished at - - if @project.coverage_enabled? - %th Coverage - %th - = render @commit.builds_without_retry.for_ref(ref), controls: true - -- if @commit.retried_builds.any? - %h3 - Retried builds - - %table.table.builds - %thead - %tr - %th Status - %th Build ID - %th Ref - %th Stage - %th Name - %th Duration - %th Finished at - - if @project.coverage_enabled? - %th Coverage - %th - = render @commit.retried_builds, ref: true diff --git a/app/views/layouts/ci/build.html.haml b/app/views/layouts/ci/build.html.haml deleted file mode 100644 index a1356f0dc2e..00000000000 --- a/app/views/layouts/ci/build.html.haml +++ /dev/null @@ -1,11 +0,0 @@ -!!! 5 -%html{ lang: "en"} - = render 'layouts/head' - %body{class: "ci-body #{user_application_theme}", 'data-page' => body_data_page} - - header_title ci_commit_title(@commit) - - if current_user - = render "layouts/header/default", title: header_title - - else - = render "layouts/header/public", title: header_title - - = render 'layouts/ci/page', sidebar: 'nav_project' diff --git a/app/views/layouts/ci/commit.html.haml b/app/views/layouts/ci/commit.html.haml deleted file mode 100644 index a1356f0dc2e..00000000000 --- a/app/views/layouts/ci/commit.html.haml +++ /dev/null @@ -1,11 +0,0 @@ -!!! 5 -%html{ lang: "en"} - = render 'layouts/head' - %body{class: "ci-body #{user_application_theme}", 'data-page' => body_data_page} - - header_title ci_commit_title(@commit) - - if current_user - = render "layouts/header/default", title: header_title - - else - = render "layouts/header/public", title: header_title - - = render 'layouts/ci/page', sidebar: 'nav_project' diff --git a/config/routes.rb b/config/routes.rb index 7f7c918ea5c..ccce40589e7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -28,16 +28,14 @@ Gitlab::Application.routes.draw do end end - resource :charts, only: [:show] - - resources :commits, only: [:show] do + resources :commits, only: [] do member do get :status get :cancel end end - resources :builds, only: [:show] do + resources :builds, only: [] do member do get :cancel get :status |