Backport of avoid_es_loading_commits

This commit is contained in:
Mario de la Ossa 2019-03-19 13:24:23 -06:00
parent 12818c2043
commit e886151669
No known key found for this signature in database
GPG Key ID: 20CA8F4C6A20761B
1 changed files with 8 additions and 1 deletions

View File

@ -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