Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
28883d8e
Commit
28883d8e
authored
Mar 06, 2019
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove old code in TreeHelper#flatten_tree
parent
2c4cb7a6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
13 deletions
+6
-13
app/helpers/tree_helper.rb
app/helpers/tree_helper.rb
+1
-10
lib/gitlab/git/rugged_impl/tree.rb
lib/gitlab/git/rugged_impl/tree.rb
+5
-3
No files found.
app/helpers/tree_helper.rb
View file @
28883d8e
...
@@ -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
...
...
lib/gitlab/git/rugged_impl/tree.rb
View file @
28883d8e
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment