From e88615166969912706e2ee9353e51ae10af7a909 Mon Sep 17 00:00:00 2001 From: Mario de la Ossa Date: Tue, 19 Mar 2019 13:24:23 -0600 Subject: [PATCH] Backport of avoid_es_loading_commits --- lib/gitlab/git/commit.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb index 491e4b47196..c8b36f11d80 100644 --- a/lib/gitlab/git/commit.rb +++ b/lib/gitlab/git/commit.rb @@ -184,11 +184,12 @@ module Gitlab end end - def initialize(repository, raw_commit, head = nil) + def initialize(repository, raw_commit, head = nil, lazy_load_parents: false) raise "Nil as raw commit passed" unless raw_commit @repository = repository @head = head + @lazy_load_parents = lazy_load_parents init_commit(raw_commit) end @@ -225,6 +226,12 @@ module Gitlab author_name != committer_name || author_email != committer_email end + def parent_ids + return @parent_ids unless @lazy_load_parents + + @parent_ids ||= @repository.commit(id).parent_ids + end + def parent_id parent_ids.first end