summaryrefslogtreecommitdiff
path: root/app/models/commit.rb
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-10-27 00:48:32 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-10-27 00:58:40 +0800
commitb4ef158a63807c850c1a17c75d66cd166c309047 (patch)
tree2de3bf0a9e3d7e84a7922cfceea20ccee86343fe /app/models/commit.rb
parent7cdb238ac507b85a606e0e64c71373c2fc37254c (diff)
downloadgitlab-ce-b4ef158a63807c850c1a17c75d66cd166c309047.tar.gz
Still show status from pipelines, see:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7034#note_17397201 https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7034#note_17397461 https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6801#note_17468470 https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7034#note_17482654
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r--app/models/commit.rb21
1 files changed, 14 insertions, 7 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 02e06657306..337b7445b46 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -51,12 +51,14 @@ class Commit
end
attr_accessor :raw
+ attr_reader :statuses
def initialize(raw_commit, project)
raise "Nil as raw commit passed" unless raw_commit
@raw = raw_commit
@project = project
+ @statuses = {}
end
def id
@@ -225,17 +227,22 @@ class Commit
)
end
- def pipelines_for(ref)
- project.pipelines.where(sha: sha, ref: ref)
- end
-
def pipelines
- @pipeline ||= project.pipelines.where(sha: sha)
+ project.pipelines.where(sha: sha)
end
def status
- return @status if defined?(@status)
- @status ||= pipelines.status
+ status_for(nil)
+ end
+
+ def status_for(ref)
+ if statuses.key?(ref)
+ statuses[ref]
+ elsif ref
+ statuses[ref] = pipelines.where(ref: ref).status
+ else
+ statuses[ref] = pipelines.status
+ end
end
def revert_branch_name