From fc795d6ee2bdc1229f82c535222752364b5c9e44 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 5 Oct 2015 21:20:54 +0200 Subject: Fix graphical glitches --- app/controllers/ci/projects_controller.rb | 8 +++++--- app/views/ci/commits/_commit.html.haml | 3 ++- app/views/ci/commits/show.html.haml | 26 +++++++++++++++++--------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/app/controllers/ci/projects_controller.rb b/app/controllers/ci/projects_controller.rb index 33b8ae64659..64d544acfd9 100644 --- a/app/controllers/ci/projects_controller.rb +++ b/app/controllers/ci/projects_controller.rb @@ -14,9 +14,11 @@ module Ci def show @ref = params[:ref] - @commits = @project.commits.reverse_order - # TODO: this is broken - # @commits = @commits.where(ref: @ref) if @ref + @commits = @project.commits.group(:sha).reverse_order + if @ref + builds = @project.builds.where(ref: @ref).select(:commit_id).distinct + @commits = @commits.where(id: builds) + end @commits = @commits.page(params[:page]).per(20) end diff --git a/app/views/ci/commits/_commit.html.haml b/app/views/ci/commits/_commit.html.haml index f8a1fa50851..6e6cc9b2c37 100644 --- a/app/views/ci/commits/_commit.html.haml +++ b/app/views/ci/commits/_commit.html.haml @@ -16,7 +16,8 @@ %td.build-branch - unless @ref %span - = link_to truncate(commit.last_ref, length: 25), ci_project_path(@project, ref: commit.last_ref) + - commit.refs.each do |ref| + = link_to truncate(ref, length: 25), ci_project_path(@project, ref: ref) %td.duration - if commit.duration > 0 diff --git a/app/views/ci/commits/show.html.haml b/app/views/ci/commits/show.html.haml index 7217671fe95..7ebef8c5e06 100644 --- a/app/views/ci/commits/show.html.haml +++ b/app/views/ci/commits/show.html.haml @@ -4,14 +4,22 @@ .gray-content-block.middle-block %pre.commit-message - #{@commit.git_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 + %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 @@ -22,10 +30,10 @@ %span.attr-name Created at: #{@commit.created_at.to_s(:short)} -- if current_user && can?(current_user, :manage_builds, gl_project) - .pull-right - - if @commit.builds.running_or_pending.any? - = link_to "Cancel", cancel_ci_project_commits_path(@project, @commit), class: 'btn btn-sm btn-danger' + - 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? @@ -41,7 +49,7 @@ - @commit.refs.each do |ref| %h3 - Builds for #{ref} + Builds for #{gitlab_ref_link(@project, ref)} - if @commit.duration_for_ref(ref) > 0 %small.pull-right %i.fa.fa-time -- cgit v1.2.1 From a266752821116e4736c493ad865e5ba6e1821c0d Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 6 Oct 2015 11:59:55 +0200 Subject: Latest builds always include builds with unique name and unique ref --- app/models/ci/build.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index f35224916ed..3c92710968c 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -47,7 +47,7 @@ module Ci scope :failed, ->() { where(status: "failed") } scope :unstarted, ->() { where(runner_id: nil) } scope :running_or_pending, ->() { where(status:[:running, :pending]) } - scope :latest, ->() { where(id: unscope(:select).select('max(id)').group(:name)).order(stage_idx: :asc) } + scope :latest, ->() { where(id: unscope(:select).select('max(id)').group(:name, :ref)).order(stage_idx: :asc) } scope :ignore_failures, ->() { where(allow_failure: false) } scope :for_ref, ->(ref) { where(ref: ref) } scope :similar, ->(build) { where(ref: build.ref, tag: build.tag, trigger_request_id: build.trigger_request_id) } -- cgit v1.2.1 From 065fe557f7c1ec8a520b7c18c83fa062f90d1443 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 6 Oct 2015 12:00:15 +0200 Subject: Fixed failure reading .gitlab-ci.yml --- app/models/ci/commit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/ci/commit.rb b/app/models/ci/commit.rb index 46370034f9a..fde754a92a1 100644 --- a/app/models/ci/commit.rb +++ b/app/models/ci/commit.rb @@ -211,7 +211,7 @@ module Ci end def ci_yaml_file - gl_project.repository.blob_at(sha, '.gitlab-ci.yml') + gl_project.repository.blob_at(sha, '.gitlab-ci.yml').data rescue nil end -- cgit v1.2.1