From 18a71c47603d703de73c46fef4889887f685bebe Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Mon, 7 Nov 2016 23:44:11 +0800 Subject: Show commit status from latest pipeline Rather than compound status from all pipelines. Closes #20560 --- app/models/commit.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index 9e7fde9503d..2134ba2d75f 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -232,13 +232,15 @@ class Commit def status(ref = nil) @statuses ||= {} - if @statuses.key?(ref) - @statuses[ref] - elsif ref - @statuses[ref] = pipelines.where(ref: ref).status - else - @statuses[ref] = pipelines.status - end + return @statuses[ref] if @statuses.key?(ref) + + latest_pipeline = if ref + pipelines.latest_for(ref) + else + pipelines.latest + end.first + + @statuses[ref] = latest_pipeline.try(:status) end def revert_branch_name -- cgit v1.2.1