Skip to content
Snippets Groups Projects
Unverified Commit 1e08d000 authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg
Browse files

Lazy fetch parent commits for a commit

parent b8aa65d4
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -9,6 +9,7 @@ class Commit
include Mentionable
include Referable
include StaticModel
include ::Gitlab::Utils::StrongMemoize
 
attr_mentionable :safe_message, pipeline: :single_line
 
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment