From 5416d0e0837f69f35a3a9deaf947fd62e5293661 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Fri, 21 Oct 2016 16:22:43 +0800 Subject: Pass `@ref` along so we know which pipeline to show Closes #23615 --- app/models/commit.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index e64fd1e0c1b..02e06657306 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -225,6 +225,10 @@ class Commit ) end + def pipelines_for(ref) + project.pipelines.where(sha: sha, ref: ref) + end + def pipelines @pipeline ||= project.pipelines.where(sha: sha) end -- cgit v1.2.1 From b4ef158a63807c850c1a17c75d66cd166c309047 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 27 Oct 2016 00:48:32 +0800 Subject: 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 --- app/models/commit.rb | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'app/models/commit.rb') 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 -- cgit v1.2.1 From f4b9de38edb3152888cb8e9ea0f9e48a6f08dd26 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Fri, 28 Oct 2016 03:12:12 +0800 Subject: It's not used as a public API right now, feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7034#note_17522443 --- app/models/commit.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index 337b7445b46..20bb93f4663 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -51,7 +51,6 @@ class Commit end attr_accessor :raw - attr_reader :statuses def initialize(raw_commit, project) raise "Nil as raw commit passed" unless raw_commit @@ -236,12 +235,12 @@ class Commit end def status_for(ref) - if statuses.key?(ref) - statuses[ref] + if @statuses.key?(ref) + @statuses[ref] elsif ref - statuses[ref] = pipelines.where(ref: ref).status + @statuses[ref] = pipelines.where(ref: ref).status else - statuses[ref] = pipelines.status + @statuses[ref] = pipelines.status end end -- cgit v1.2.1 From 1ae557c106e94c20742d0788dc7eb604603faa08 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 3 Nov 2016 23:39:37 +0800 Subject: Merge status_for and status, feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7034#note_17742297 --- app/models/commit.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index 20bb93f4663..1fbda6f6acc 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -230,11 +230,7 @@ class Commit project.pipelines.where(sha: sha) end - def status - status_for(nil) - end - - def status_for(ref) + def status(ref = nil) if @statuses.key?(ref) @statuses[ref] elsif ref -- cgit v1.2.1 From 0902ba524f6bfa7f7f6d234378c8847b541d1586 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 3 Nov 2016 23:43:17 +0800 Subject: Initialize @statuses in status rather than constructor Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7034#note_17742312 --- app/models/commit.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index 1fbda6f6acc..9e7fde9503d 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -57,7 +57,6 @@ class Commit @raw = raw_commit @project = project - @statuses = {} end def id @@ -231,6 +230,8 @@ class Commit end def status(ref = nil) + @statuses ||= {} + if @statuses.key?(ref) @statuses[ref] elsif ref -- cgit v1.2.1