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
Léo-Paul Géneau
gitlab-ce
Commits
09763657
Commit
09763657
authored
Apr 04, 2018
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix links to subdirectories of a directory with a plus character in its path
parent
eaed588b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
1 deletion
+16
-1
app/helpers/tree_helper.rb
app/helpers/tree_helper.rb
+1
-1
changelogs/unreleased/dm-flatten-tree-plus-chars.yml
changelogs/unreleased/dm-flatten-tree-plus-chars.yml
+5
-0
spec/helpers/tree_helper_spec.rb
spec/helpers/tree_helper_spec.rb
+10
-0
No files found.
app/helpers/tree_helper.rb
View file @
09763657
...
...
@@ -123,7 +123,7 @@ module TreeHelper
# returns the relative path of the first subdir that doesn't have only one directory descendant
def
flatten_tree
(
root_path
,
tree
)
return
tree
.
flat_path
.
sub
(
%r{
\A
#{
root_path
}
/}
,
''
)
if
tree
.
flat_path
.
present?
return
tree
.
flat_path
.
sub
(
%r{
\A
#{
Regexp
.
escape
(
root_path
)
}
/}
,
''
)
if
tree
.
flat_path
.
present?
subtree
=
Gitlab
::
Git
::
Tree
.
where
(
@repository
,
@commit
.
id
,
tree
.
path
)
if
subtree
.
count
==
1
&&
subtree
.
first
.
dir?
...
...
changelogs/unreleased/dm-flatten-tree-plus-chars.yml
0 → 100644
View file @
09763657
---
title
:
Fix links to subdirectories of a directory with a plus character in its path
merge_request
:
author
:
type
:
fixed
spec/helpers/tree_helper_spec.rb
View file @
09763657
...
...
@@ -8,6 +8,7 @@ describe TreeHelper do
describe
'.render_tree'
do
before
do
@id
=
sha
@path
=
""
@project
=
project
@lfs_blob_ids
=
[]
end
...
...
@@ -61,6 +62,15 @@ describe TreeHelper do
end
end
end
context
'when the root path contains a plus character'
do
let
(
:root_path
)
{
'gtk/C++'
}
let
(
:tree_item
)
{
double
(
flat_path:
'gtk/C++/glade'
)
}
it
'returns the flattened path'
do
expect
(
subject
).
to
eq
(
'glade'
)
end
end
end
describe
'#commit_in_single_accessible_branch'
do
...
...
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