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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
a539e03d
Commit
a539e03d
authored
Jan 15, 2018
by
Andrew McCallum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Account for query of only forward slash(es).
parent
7ce732fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
app/models/repository.rb
app/models/repository.rb
+2
-2
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+7
-0
No files found.
app/models/repository.rb
View file @
a539e03d
...
@@ -938,10 +938,10 @@ class Repository
...
@@ -938,10 +938,10 @@ class Repository
end
end
def
search_files_by_name
(
query
,
ref
)
def
search_files_by_name
(
query
,
ref
)
return
[]
if
empty?
||
query
.
blank?
safe_query
=
query
.
sub
(
/^\/*/
,
""
)
safe_query
=
query
.
sub
(
/^\/*/
,
""
)
return
[]
if
empty?
||
safe_query
.
blank?
args
=
%W(ls-tree --full-tree -r
#{
ref
||
root_ref
}
--name-status |
#{
Regexp
.
escape
(
safe_query
)
}
)
args
=
%W(ls-tree --full-tree -r
#{
ref
||
root_ref
}
--name-status |
#{
Regexp
.
escape
(
safe_query
)
}
)
run_git
(
args
).
first
.
lines
.
map
(
&
:strip
)
run_git
(
args
).
first
.
lines
.
map
(
&
:strip
)
...
...
spec/models/repository_spec.rb
View file @
a539e03d
...
@@ -670,9 +670,16 @@ describe Repository do
...
@@ -670,9 +670,16 @@ describe Repository do
it
'ignores leading slashes'
do
it
'ignores leading slashes'
do
results
=
repository
.
search_files_by_name
(
'/files'
,
'master'
)
results
=
repository
.
search_files_by_name
(
'/files'
,
'master'
)
expect
(
results
.
first
).
to
eq
(
'files/html/500.html'
)
expect
(
results
.
first
).
to
eq
(
'files/html/500.html'
)
end
end
it
'properly handles when query is only slashes'
do
results
=
repository
.
search_files_by_name
(
'//'
,
'master'
)
expect
(
results
).
to
match_array
([])
end
it
'properly handles when query is not present'
do
it
'properly handles when query is not present'
do
results
=
repository
.
search_files_by_name
(
''
,
'master'
)
results
=
repository
.
search_files_by_name
(
''
,
'master'
)
...
...
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