summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2019-03-20 13:10:41 +0000
committerNick Thomas <nick@gitlab.com>2019-03-20 13:10:41 +0000
commit9266901e500158624035e5985be7e3d7ea76e03a (patch)
treecc9aa282e7b5c4a9c939ec48bba3192bfb4f6b69 /lib
parent2269710ba5e82d71d24df8713b23b6b7b164d372 (diff)
parente88615166969912706e2ee9353e51ae10af7a909 (diff)
downloadgitlab-ce-9266901e500158624035e5985be7e3d7ea76e03a.tar.gz
Merge branch 'ce-avoid_es_loading_commits' into 'master'
Backport of avoid_es_loading_commits See merge request gitlab-org/gitlab-ce!26301
Diffstat (limited to 'lib')
-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 e5bbd500e98..88ff9fbceb4 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