summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMario de la Ossa <mariodelaossa@gmail.com>2019-03-19 13:24:23 -0600
committerMario de la Ossa <mariodelaossa@gmail.com>2019-03-19 13:24:23 -0600
commite88615166969912706e2ee9353e51ae10af7a909 (patch)
tree791192f51d6f82aa122f9d1cfeb4cdbd5e075032
parent12818c20430bec5b54903e19ff78b0575c61f05c (diff)
downloadgitlab-ce-e88615166969912706e2ee9353e51ae10af7a909.tar.gz
Backport of avoid_es_loading_commits
-rw-r--r--lib/gitlab/git/commit.rb9
1 files changed, 8 insertions, 1 deletions
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