API: Fix recursive flag not working with Rugged get_tree_entries flag

Attempting to use the API endpoint
/projects/:id/repository/tree?recursive=true would only return a subset
of the results since the full recursive list wasn't actually being
returned.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/61979
This commit is contained in:
Stan Hu 2019-05-20 11:41:50 -07:00
parent cddf9b875a
commit c1827f1c50
3 changed files with 10 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
title: Fix Rugged get_tree_entries recursive flag not working
merge_request: 28494
author:
type: fixed

View file

@ -43,6 +43,8 @@ module Gitlab
ordered_entries.concat(tree_entries_from_rugged(repository, sha, entry.path, true)) ordered_entries.concat(tree_entries_from_rugged(repository, sha, entry.path, true))
end end
end end
ordered_entries
end end
def rugged_populate_flat_path(repository, sha, path, entries) def rugged_populate_flat_path(repository, sha, path, entries)

View file

@ -19,7 +19,9 @@ describe Gitlab::Git::Tree, :seed_helper do
it 'returns a list of tree objects' do it 'returns a list of tree objects' do
entries = described_class.where(repository, SeedRepo::Commit::ID, 'files', true) entries = described_class.where(repository, SeedRepo::Commit::ID, 'files', true)
expect(entries.count).to be >= 5 expect(entries.map(&:path)).to include('files/html',
'files/markdown/ruby-style-guide.md')
expect(entries.count).to be >= 10
expect(entries).to all(be_a(Gitlab::Git::Tree)) expect(entries).to all(be_a(Gitlab::Git::Tree))
end end