Commit 28883d8e authored by Stan Hu's avatar Stan Hu

Remove old code in TreeHelper#flatten_tree

parent 2c4cb7a6
...@@ -136,18 +136,9 @@ module TreeHelper ...@@ -136,18 +136,9 @@ module TreeHelper
end end
# returns the relative path of the first subdir that doesn't have only one directory descendant # returns the relative path of the first subdir that doesn't have only one directory descendant
# rubocop: disable CodeReuse/ActiveRecord
def flatten_tree(root_path, tree) def flatten_tree(root_path, tree)
return tree.flat_path.sub(%r{\A#{Regexp.escape(root_path)}/}, '') if tree.flat_path.present? tree.flat_path.sub(%r{\A#{Regexp.escape(root_path)}/}, '')
subtree = Gitlab::Git::Tree.where(@repository, @commit.id, tree.path)
if subtree.count == 1 && subtree.first.dir?
return tree_join(tree.name, flatten_tree(root_path, subtree.first))
else
return tree.name
end
end end
# rubocop: enable CodeReuse/ActiveRecord
def selected_branch def selected_branch
@branch_name || tree_edit_branch @branch_name || tree_edit_branch
......
...@@ -33,9 +33,11 @@ module Gitlab ...@@ -33,9 +33,11 @@ module Gitlab
end end
end end
# This is an optimization to reduce N+1 queries for Gitaly. It's # This was an optimization to reduce N+1 queries for Gitaly
# currently done in TreeHelper#flatten_tree, but to emulate Gitaly # (https://gitlab.com/gitlab-org/gitaly/issues/530). It
# as much as possible we populate the value here. # used to be done lazily in the view via
# TreeHelper#flatten_tree, so it's possible there's a
# performance impact by loading this eagerly.
rugged_populate_flat_path(repository, sha, path, ordered_entries) rugged_populate_flat_path(repository, sha, path, ordered_entries)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment