From e69a7b95df4aea964878086157487379705c9a8c Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 3 May 2017 00:10:17 +0800 Subject: Always show latest pipeline info in commit box --- app/models/commit.rb | 2 +- app/views/projects/commit/_commit_box.html.haml | 17 +++++++++-------- .../always-show-latest-pipeline-in-commit-box.yml | 4 ++++ 3 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 changelogs/unreleased/always-show-latest-pipeline-in-commit-box.yml diff --git a/app/models/commit.rb b/app/models/commit.rb index bb4cb8efd15..e37c2d6bbd6 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -237,7 +237,7 @@ class Commit end def latest_pipeline - pipelines.last + @latest_pipeline ||= pipelines.last end def status(ref = nil) diff --git a/app/views/projects/commit/_commit_box.html.haml b/app/views/projects/commit/_commit_box.html.haml index f604d6e5fbb..7d9a8990591 100644 --- a/app/views/projects/commit/_commit_box.html.haml +++ b/app/views/projects/commit/_commit_box.html.haml @@ -61,19 +61,20 @@ %span.commit-info.branches %i.fa.fa-spinner.fa-spin - - if @commit.status + - if @commit.latest_pipeline + - latest_pipeline = @commit.latest_pipeline .well-segment.pipeline-info .status-icon-container{ class: "ci-status-icon-#{@commit.status}" } - = link_to namespace_project_pipeline_path(@project.namespace, @project, @commit.latest_pipeline.id) do - = ci_icon_for_status(@commit.status) + = link_to namespace_project_pipeline_path(@project.namespace, @project, latest_pipeline.id) do + = ci_icon_for_status(latest_pipeline.status) Pipeline - = link_to "##{@commit.latest_pipeline.id}", namespace_project_pipeline_path(@project.namespace, @project, @commit.latest_pipeline.id), class: "monospace" - = ci_label_for_status(@commit.status) - - if @commit.latest_pipeline.stages.any? + = link_to "##{latest_pipeline.id}", namespace_project_pipeline_path(@project.namespace, @project, latest_pipeline.id), class: "monospace" + = ci_label_for_status(latest_pipeline.status) + - if latest_pipeline.stages.any? .mr-widget-pipeline-graph - = render 'shared/mini_pipeline_graph', pipeline: @commit.latest_pipeline, klass: 'js-commit-pipeline-graph' + = render 'shared/mini_pipeline_graph', pipeline: latest_pipeline, klass: 'js-commit-pipeline-graph' in - = time_interval_in_words @commit.pipelines.total_duration + = time_interval_in_words latest_pipeline.duration :javascript $(".commit-info.branches").load("#{branches_namespace_project_commit_path(@project.namespace, @project, @commit.id)}"); diff --git a/changelogs/unreleased/always-show-latest-pipeline-in-commit-box.yml b/changelogs/unreleased/always-show-latest-pipeline-in-commit-box.yml new file mode 100644 index 00000000000..6aa0c89f6f7 --- /dev/null +++ b/changelogs/unreleased/always-show-latest-pipeline-in-commit-box.yml @@ -0,0 +1,4 @@ +--- +title: Always show the latest pipeline information in the commit box +merge_request: 11038 +author: -- cgit v1.2.1 From 0a29bde4a1c2c77c49c3fa28ca3f059ba3d3b7d5 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 3 May 2017 01:40:20 +0800 Subject: Rename latest_pipeline to last_pipeline As it might be confusing that it's not the same as Pipeline#latest Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11038#note_28677090 --- app/models/commit.rb | 4 ++-- app/views/projects/commit/_commit_box.html.haml | 18 +++++++++--------- spec/models/commit_spec.rb | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/models/commit.rb b/app/models/commit.rb index e37c2d6bbd6..88a015cdb77 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -236,8 +236,8 @@ class Commit project.pipelines.where(sha: sha) end - def latest_pipeline - @latest_pipeline ||= pipelines.last + def last_pipeline + @last_pipeline ||= pipelines.last end def status(ref = nil) diff --git a/app/views/projects/commit/_commit_box.html.haml b/app/views/projects/commit/_commit_box.html.haml index 7d9a8990591..64adb70cb81 100644 --- a/app/views/projects/commit/_commit_box.html.haml +++ b/app/views/projects/commit/_commit_box.html.haml @@ -61,20 +61,20 @@ %span.commit-info.branches %i.fa.fa-spinner.fa-spin - - if @commit.latest_pipeline - - latest_pipeline = @commit.latest_pipeline + - if @commit.last_pipeline + - last_pipeline = @commit.last_pipeline .well-segment.pipeline-info .status-icon-container{ class: "ci-status-icon-#{@commit.status}" } - = link_to namespace_project_pipeline_path(@project.namespace, @project, latest_pipeline.id) do - = ci_icon_for_status(latest_pipeline.status) + = link_to namespace_project_pipeline_path(@project.namespace, @project, last_pipeline.id) do + = ci_icon_for_status(last_pipeline.status) Pipeline - = link_to "##{latest_pipeline.id}", namespace_project_pipeline_path(@project.namespace, @project, latest_pipeline.id), class: "monospace" - = ci_label_for_status(latest_pipeline.status) - - if latest_pipeline.stages.any? + = link_to "##{last_pipeline.id}", namespace_project_pipeline_path(@project.namespace, @project, last_pipeline.id), class: "monospace" + = ci_label_for_status(last_pipeline.status) + - if last_pipeline.stages.any? .mr-widget-pipeline-graph - = render 'shared/mini_pipeline_graph', pipeline: latest_pipeline, klass: 'js-commit-pipeline-graph' + = render 'shared/mini_pipeline_graph', pipeline: last_pipeline, klass: 'js-commit-pipeline-graph' in - = time_interval_in_words latest_pipeline.duration + = time_interval_in_words last_pipeline.duration :javascript $(".commit-info.branches").load("#{branches_namespace_project_commit_path(@project.namespace, @project, @commit.id)}"); diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index ce31c8ed94c..08b2169fea7 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -212,7 +212,7 @@ eos end end - describe '#latest_pipeline' do + describe '#last_pipeline' do let!(:first_pipeline) do create(:ci_empty_pipeline, project: project, @@ -226,8 +226,8 @@ eos status: 'success') end - it 'returns latest pipeline' do - expect(commit.latest_pipeline).to eq second_pipeline + it 'returns last pipeline' do + expect(commit.last_pipeline).to eq second_pipeline end end -- cgit v1.2.1