Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-03-06 19:25:53 +0300
committerDouwe Maan <douwe@gitlab.com>2018-03-06 19:25:53 +0300
commit9a8f5a2b605f85ace3c81a32cf1855f79cabde43 (patch)
treeb3450a3454cb73e8da6a81395c5a9dff588b7f4c /app
parent9cdaa452fd22974faaa34ea3a78495dc01ca5fd6 (diff)
parent1e08d00032c1160202567dacdf24c3b47458d86c (diff)
Merge branch 'zj-lazy-parents' into 'master'
Lazy fetch parent commits for a commit See merge request gitlab-org/gitlab-ce!17559
Diffstat (limited to 'app')
-rw-r--r--app/models/commit.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index b9106309142..cceae5efb72 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -9,6 +9,7 @@ class Commit
include Mentionable
include Referable
include StaticModel
+ include ::Gitlab::Utils::StrongMemoize
attr_mentionable :safe_message, pipeline: :single_line
@@ -225,11 +226,13 @@ class Commit
end
def parents
- @parents ||= parent_ids.map { |id| project.commit(id) }
+ @parents ||= parent_ids.map { |oid| Commit.lazy(project, oid) }
end
def parent
- @parent ||= project.commit(self.parent_id) if self.parent_id
+ strong_memoize(:parent) do
+ project.commit_by(oid: self.parent_id) if self.parent_id
+ end
end
def notes