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
Jérome Perrin
gitlab-ce
Commits
021cff67
Commit
021cff67
authored
Dec 31, 2014
by
marmis85
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Flatten the directory hierarchy while there is only one directory descendant
parent
ac158424
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
app/helpers/tree_helper.rb
app/helpers/tree_helper.rb
+10
-0
app/views/projects/tree/_tree_item.html.haml
app/views/projects/tree/_tree_item.html.haml
+2
-1
No files found.
app/helpers/tree_helper.rb
View file @
021cff67
...
...
@@ -113,6 +113,16 @@ module TreeHelper
tree_join
(
@ref
,
file
)
end
# returns the relative path of the first subdir that doesn't have only one directory descendand
def
flatten_tree
(
tree
)
subtree
=
Gitlab
::
Git
::
Tree
.
where
(
@repository
,
@commit
.
id
,
tree
.
path
)
if
subtree
.
count
==
1
&&
subtree
.
first
.
dir?
return
tree_join
(
tree
.
name
,
flatten_tree
(
subtree
.
first
))
else
return
tree
.
name
end
end
def
leave_edit_message
"Leave edit mode?
\n
All unsaved changes will be lost."
end
...
...
app/views/projects/tree/_tree_item.html.haml
View file @
021cff67
...
...
@@ -2,7 +2,8 @@
%td
.tree-item-file-name
=
tree_icon
(
type
)
%span
.str-truncated
=
link_to
tree_item
.
name
,
project_tree_path
(
@project
,
tree_join
(
@id
||
@commit
.
id
,
tree_item
.
name
))
-
path
=
flatten_tree
(
tree_item
)
=
link_to
path
,
project_tree_path
(
@project
,
tree_join
(
@id
||
@commit
.
id
,
path
))
%td
.tree_time_ago.cgray
=
render
'spinner'
%td
.hidden-xs.tree_commit
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