diff options
author | Douwe Maan <douwe@gitlab.com> | 2019-04-17 16:16:51 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2019-04-17 16:16:51 +0300 |
commit | 6a72ab22c824c17e311492888fc99473a5c89192 (patch) | |
tree | fc8d7f28e5b0eba1119b1fea4461699f216730ab /lib | |
parent | 3f3d2c066188acbe0724dc5cc24f0d57456ef6d6 (diff) | |
parent | 2fc4de6ab646f1975fb2b747d9743879367710e8 (diff) |
Merge branch 'sh-backport-list-commits-by-oid-rugged' into 'master'
Bring back Rugged implementation of ListCommitsByOid
See merge request gitlab-org/gitlab-ce!27441
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/git/rugged_impl/commit.rb | 20 | ||||
-rw-r--r-- | lib/gitlab/git/rugged_impl/repository.rb | 2 |
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/gitlab/git/rugged_impl/commit.rb b/lib/gitlab/git/rugged_impl/commit.rb index f6777dfa0c3..bce4fa14fb4 100644 --- a/lib/gitlab/git/rugged_impl/commit.rb +++ b/lib/gitlab/git/rugged_impl/commit.rb @@ -21,6 +21,17 @@ module Gitlab nil end + # 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. + def rugged_batch_by_oid(repo, oids) + oids.map { |oid| rugged_find(repo, oid) } + .compact + .map { |commit| decorate(repo, commit) } + end + override :find_commit def find_commit(repo, commit_id) if Feature.enabled?(:rugged_find_commit) @@ -29,6 +40,15 @@ module Gitlab super end end + + override :batch_by_oid + def batch_by_oid(repo, oids) + if Feature.enabled?(:rugged_list_commits_by_oid) + rugged_batch_by_oid(repo, oids) + else + super + end + end end extend ::Gitlab::Utils::Override diff --git a/lib/gitlab/git/rugged_impl/repository.rb b/lib/gitlab/git/rugged_impl/repository.rb index c0a91f59ab9..e91b0ddcd31 100644 --- a/lib/gitlab/git/rugged_impl/repository.rb +++ b/lib/gitlab/git/rugged_impl/repository.rb @@ -12,7 +12,7 @@ module Gitlab module Repository extend ::Gitlab::Utils::Override - FEATURE_FLAGS = %i(rugged_find_commit rugged_tree_entries rugged_tree_entry rugged_commit_is_ancestor rugged_commit_tree_entry).freeze + FEATURE_FLAGS = %i(rugged_find_commit rugged_tree_entries rugged_tree_entry rugged_commit_is_ancestor rugged_commit_tree_entry rugged_list_commits_by_oid).freeze def alternate_object_directories relative_object_directories.map { |d| File.join(path, d) } |