Commit 68c12e15 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'always-show-latest-pipeline-in-commit-box' into 'master'

Always show latest pipeline info in commit box

Closes #31378

See merge request !11038
parents eddeecf6 0a29bde4
...@@ -236,8 +236,8 @@ class Commit ...@@ -236,8 +236,8 @@ class Commit
project.pipelines.where(sha: sha) project.pipelines.where(sha: sha)
end end
def latest_pipeline def last_pipeline
pipelines.last @last_pipeline ||= pipelines.last
end end
def status(ref = nil) def status(ref = nil)
......
...@@ -61,19 +61,20 @@ ...@@ -61,19 +61,20 @@
%span.commit-info.branches %span.commit-info.branches
%i.fa.fa-spinner.fa-spin %i.fa.fa-spinner.fa-spin
- if @commit.status - if @commit.last_pipeline
- last_pipeline = @commit.last_pipeline
.well-segment.pipeline-info .well-segment.pipeline-info
.status-icon-container{ class: "ci-status-icon-#{@commit.status}" } .status-icon-container{ class: "ci-status-icon-#{@commit.status}" }
= link_to namespace_project_pipeline_path(@project.namespace, @project, @commit.latest_pipeline.id) do = link_to namespace_project_pipeline_path(@project.namespace, @project, last_pipeline.id) do
= ci_icon_for_status(@commit.status) = ci_icon_for_status(last_pipeline.status)
Pipeline Pipeline
= link_to "##{@commit.latest_pipeline.id}", namespace_project_pipeline_path(@project.namespace, @project, @commit.latest_pipeline.id), class: "monospace" = link_to "##{last_pipeline.id}", namespace_project_pipeline_path(@project.namespace, @project, last_pipeline.id), class: "monospace"
= ci_label_for_status(@commit.status) = ci_label_for_status(last_pipeline.status)
- if @commit.latest_pipeline.stages.any? - if last_pipeline.stages.any?
.mr-widget-pipeline-graph .mr-widget-pipeline-graph
= render 'shared/mini_pipeline_graph', pipeline: @commit.latest_pipeline, klass: 'js-commit-pipeline-graph' = render 'shared/mini_pipeline_graph', pipeline: last_pipeline, klass: 'js-commit-pipeline-graph'
in in
= time_interval_in_words @commit.pipelines.total_duration = time_interval_in_words last_pipeline.duration
:javascript :javascript
$(".commit-info.branches").load("#{branches_namespace_project_commit_path(@project.namespace, @project, @commit.id)}"); $(".commit-info.branches").load("#{branches_namespace_project_commit_path(@project.namespace, @project, @commit.id)}");
---
title: Always show the latest pipeline information in the commit box
merge_request: 11038
author:
...@@ -212,7 +212,7 @@ eos ...@@ -212,7 +212,7 @@ eos
end end
end end
describe '#latest_pipeline' do describe '#last_pipeline' do
let!(:first_pipeline) do let!(:first_pipeline) do
create(:ci_empty_pipeline, create(:ci_empty_pipeline,
project: project, project: project,
...@@ -226,8 +226,8 @@ eos ...@@ -226,8 +226,8 @@ eos
status: 'success') status: 'success')
end end
it 'returns latest pipeline' do it 'returns last pipeline' do
expect(commit.latest_pipeline).to eq second_pipeline expect(commit.last_pipeline).to eq second_pipeline
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment