Lazy fetch parent commits for a commit
This commit is contained in:
parent
b8aa65d47c
commit
1e08d00032
|
@ -9,6 +9,7 @@ class Commit
|
||||||
include Mentionable
|
include Mentionable
|
||||||
include Referable
|
include Referable
|
||||||
include StaticModel
|
include StaticModel
|
||||||
|
include ::Gitlab::Utils::StrongMemoize
|
||||||
|
|
||||||
attr_mentionable :safe_message, pipeline: :single_line
|
attr_mentionable :safe_message, pipeline: :single_line
|
||||||
|
|
||||||
|
@ -225,11 +226,13 @@ class Commit
|
||||||
end
|
end
|
||||||
|
|
||||||
def parents
|
def parents
|
||||||
@parents ||= parent_ids.map { |id| project.commit(id) }
|
@parents ||= parent_ids.map { |oid| Commit.lazy(project, oid) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def parent
|
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
|
end
|
||||||
|
|
||||||
def notes
|
def notes
|
||||||
|
|
Loading…
Reference in New Issue