From aff5c9f3e5ecdd9eee2b2b60ab6367da878582fc Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Fri, 16 Jun 2017 15:00:58 +0100 Subject: Add table for merge request commits This is an ID-less table with just three columns: an association to the merge request diff the commit belongs to, the relative order of the commit within the merge request diff, and the commit SHA itself. Previously we stored much more information about the commits, so that we could display them even when they were deleted from the repo. Since 8.0, we ensure that those commits are kept around for as long as the target repo itself is, so we don't need to duplicate that data in the database. --- app/models/commit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index 20206d57c4c..c7f62617c4c 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -138,7 +138,7 @@ class Commit safe_message.split("\n", 2)[1].try(:chomp) end - + def description? description.present? end -- cgit v1.2.1 From aada5273fa260cbd2441e8f1a0c95d951b4977fc Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 18 Jul 2017 01:18:20 +0800 Subject: Use RequestStoreWrap for Commit#author We also try to use instance variable to cache the result if RequestStore is not available, so we could keep the same logic, using the same cache key. Also introduce a way to specify method specific cache key --- app/models/commit.rb | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index c7f62617c4c..337236b30d5 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -1,5 +1,6 @@ class Commit extend ActiveModel::Naming + extend Gitlab::Cache::RequestStoreWrap include ActiveModel::Conversion include Noteable @@ -169,19 +170,9 @@ class Commit end def author - if RequestStore.active? - key = "commit_author:#{author_email.downcase}" - # nil is a valid value since no author may exist in the system - if RequestStore.store.key?(key) - @author = RequestStore.store[key] - else - @author = find_author_by_any_email - RequestStore.store[key] = @author - end - else - @author ||= find_author_by_any_email - end + User.find_by_any_email(author_email.downcase) end + request_store_wrap(:author) { author_email.downcase } def committer @committer ||= User.find_by_any_email(committer_email.downcase) @@ -368,10 +359,6 @@ class Commit end end - def find_author_by_any_email - User.find_by_any_email(author_email.downcase) - end - def repo_changes changes = { added: [], modified: [], removed: [] } -- cgit v1.2.1 From a89f18bf2c1421460fcb3f42aac538df51660912 Mon Sep 17 00:00:00 2001 From: Andrew Newdigate Date: Tue, 18 Jul 2017 07:59:36 +0000 Subject: Renamed Gitaly services --- app/models/commit.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index c7f62617c4c..21b906e1110 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -322,7 +322,7 @@ class Commit def raw_diffs(*args) if Gitlab::GitalyClient.feature_enabled?(:commit_raw_diffs) - Gitlab::GitalyClient::Commit.new(project.repository).diff_from_parent(self, *args) + Gitlab::GitalyClient::CommitService.new(project.repository).diff_from_parent(self, *args) else raw.diffs(*args) end @@ -331,7 +331,7 @@ class Commit def raw_deltas @deltas ||= Gitlab::GitalyClient.migrate(:commit_deltas) do |is_enabled| if is_enabled - Gitlab::GitalyClient::Commit.new(project.repository).commit_deltas(self) + Gitlab::GitalyClient::CommitService.new(project.repository).commit_deltas(self) else raw.deltas end -- cgit v1.2.1 From ffc5b29bd0f02676bdc05ec6185d115d6705cd8f Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 18 Jul 2017 17:48:48 +0800 Subject: Follow feedback on the merge request --- app/models/commit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index 337236b30d5..66c6ae4dacf 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -1,6 +1,6 @@ class Commit extend ActiveModel::Naming - extend Gitlab::Cache::RequestStoreWrap + extend Gitlab::Cache::RequestCache include ActiveModel::Conversion include Noteable -- cgit v1.2.1 From 3922b803290ecccdb232c2c150ee249ba2b57c97 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 18 Jul 2017 18:04:20 +0800 Subject: Rename the methods to make it fit with current name --- app/models/commit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index 66c6ae4dacf..50790a710bb 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -172,7 +172,7 @@ class Commit def author User.find_by_any_email(author_email.downcase) end - request_store_wrap(:author) { author_email.downcase } + request_cache(:author) { author_email.downcase } def committer @committer ||= User.find_by_any_email(committer_email.downcase) -- cgit v1.2.1