Module: Gitlab::Git::RuggedImpl::Commit::ClassMethods

Extended by:
Utils::Override
Includes:
UseRugged
Defined in:
lib/gitlab/git/rugged_impl/commit.rb

Instance Method Summary collapse

Methods included from Utils::Override

extended, extensions, included, method_added, override, prepended, queue_verification, verify!

Methods included from UseRugged

#execute_rugged_call, #rugged_enabled_through_feature_flag?, #rugged_feature_keys, #running_puma_with_multiple_threads?, #use_rugged?

Instance Method Details

#batch_by_oid(repo, oids) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/gitlab/git/rugged_impl/commit.rb', line 49

def batch_by_oid(repo, oids)
  if use_rugged?(repo, :rugged_list_commits_by_oid)
    execute_rugged_call(:rugged_batch_by_oid, repo, oids)
  else
    super
  end
end

#find_commit(repo, commit_id) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/gitlab/git/rugged_impl/commit.rb', line 40

def find_commit(repo, commit_id)
  if use_rugged?(repo, :rugged_find_commit)
    execute_rugged_call(:rugged_find, repo, commit_id)
  else
    super
  end
end

#rugged_batch_by_oid(repo, oids) ⇒ Object

This needs to return an array of Gitlab::Git:Commit objects instead of Rugged::Commit objects to ensure upstream models operate on a consistent interface. Unlike Gitlab::Git::Commit.find, Gitlab::Git::Commit.batch_by_oid doesn’t attempt to decorate the result.



30
31
32
33
34
35
36
37
# File 'lib/gitlab/git/rugged_impl/commit.rb', line 30

def rugged_batch_by_oid(repo, oids)
  oids.map { |oid| rugged_find(repo, oid) }
    .compact
    .map { |commit| decorate(repo, commit) }
# Match Gitaly's list_commits_by_oid behavior
rescue ::Gitlab::Git::Repository::NoRepository
  []
end

#rugged_find(repo, commit_id) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/gitlab/git/rugged_impl/commit.rb', line 17

def rugged_find(repo, commit_id)
  obj = repo.rev_parse_target(commit_id)

  obj.is_a?(::Rugged::Commit) ? obj : nil
rescue ::Rugged::Error
  nil
end