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
87ee772f
Commit
87ee772f
authored
Dec 23, 2016
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix default_branch in lib/gitlab/elastic/project_search_results.rb
parent
1238b5e0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
16 deletions
+12
-16
app/views/search/results/_blob.html.haml
app/views/search/results/_blob.html.haml
+2
-3
lib/gitlab/elastic/project_search_results.rb
lib/gitlab/elastic/project_search_results.rb
+2
-7
lib/gitlab/file_finder.rb
lib/gitlab/file_finder.rb
+1
-1
spec/lib/gitlab/elastic/project_search_results_spec.rb
spec/lib/gitlab/elastic/project_search_results_spec.rb
+1
-1
spec/lib/gitlab/file_finder_spec.rb
spec/lib/gitlab/file_finder_spec.rb
+3
-2
spec/lib/gitlab/project_search_results_spec.rb
spec/lib/gitlab/project_search_results_spec.rb
+3
-2
No files found.
app/views/search/results/_blob.html.haml
View file @
87ee772f
...
...
@@ -6,8 +6,7 @@
-
blob
=
parse_search_result
(
blob
)
-
file_name
=
blob
.
filename
-
ref
=
@search_results
.
repository_ref
-
blob_link
=
namespace_project_blob_path
(
project
.
namespace
,
project
,
tree_join
(
ref
,
file_name
))
-
blob_link
=
namespace_project_blob_path
(
project
.
namespace
,
project
,
tree_join
(
blob
.
ref
,
file_name
))
.blob-result
.file-holder
.file-title
...
...
@@ -19,6 +18,6 @@
-
else
#{
project
.
name_with_namespace
}
:
%i
=
file_name
-
if
blob
-
if
blob
.
data
.file-content.code.term
=
render
'shared/file_highlight'
,
blob:
blob
,
first_line_number:
blob
.
startline
,
blob_link:
blob_link
lib/gitlab/elastic/project_search_results.rb
View file @
87ee772f
...
...
@@ -9,12 +9,7 @@ module Gitlab
def
initialize
(
current_user
,
query
,
project_id
,
repository_ref
=
nil
)
@current_user
=
current_user
@project
=
Project
.
find
(
project_id
)
@repository_ref
=
if
repository_ref
.
present?
repository_ref
else
nil
end
@repository_ref
=
repository_ref
.
presence
||
project
.
default_branch
@query
=
query
@public_and_internal_projects
=
false
end
...
...
@@ -121,7 +116,7 @@ module Gitlab
end
def
root_ref?
!
repository_ref
||
project
.
root_ref?
(
repository_ref
)
project
.
root_ref?
(
repository_ref
)
end
end
end
...
...
lib/gitlab/file_finder.rb
View file @
87ee772f
...
...
@@ -23,7 +23,7 @@ module Gitlab
end
project
.
repository
.
search_files_by_name
(
query
,
ref
).
first
(
BATCH_SIZE
).
each
do
|
filename
|
results
<<
[
filename
,
nil
]
unless
found_file_names
.
include?
(
filename
)
results
<<
[
filename
,
OpenStruct
.
new
(
ref:
ref
)
]
unless
found_file_names
.
include?
(
filename
)
end
results
.
sort_by
(
&
:first
)
...
...
spec/lib/gitlab/elastic/project_search_results_spec.rb
View file @
87ee772f
...
...
@@ -19,7 +19,7 @@ describe Gitlab::Elastic::ProjectSearchResults, lib: true do
subject
(
:results
)
{
described_class
.
new
(
user
,
query
,
project
.
id
,
''
)
}
it
{
expect
(
results
.
project
).
to
eq
(
project
)
}
it
{
expect
(
results
.
repository_ref
).
to
be_nil
}
it
{
expect
(
results
.
repository_ref
).
to
eq
(
'master'
)
}
it
{
expect
(
results
.
query
).
to
eq
(
'hello world'
)
}
end
...
...
spec/lib/gitlab/file_finder_spec.rb
View file @
87ee772f
...
...
@@ -5,9 +5,10 @@ describe Gitlab::FileFinder do
let
(
:finder
)
{
described_class
.
new
(
project
,
'master'
)
}
it
'finds files by name'
do
result
=
finder
.
find
(
'CHANGELOG'
).
first
filename
,
blob
=
finder
.
find
(
'CHANGELOG'
).
first
expect
(
result
).
to
match_array
([
'CHANGELOG'
,
nil
])
expect
(
filename
).
to
eq
(
'CHANGELOG'
)
expect
(
blob
.
ref
).
to
eq
(
'master'
)
end
it
'finds files by content'
do
...
...
spec/lib/gitlab/project_search_results_spec.rb
View file @
87ee772f
...
...
@@ -25,11 +25,12 @@ describe Gitlab::ProjectSearchResults, lib: true do
let
(
:results
)
{
described_class
.
new
(
user
,
project
,
'files'
).
objects
(
'blobs'
)
}
it
'finds by name'
do
expect
(
results
).
to
include
([
"files/images/wm.svg"
,
nil
])
blob
=
results
.
select
{
|
result
|
result
.
first
==
'files/images/wm.svg'
}.
flatten
.
last
expect
(
blob
).
to
be_a
(
OpenStruct
)
end
it
'finds by content'
do
blob
=
results
.
select
{
|
result
|
result
.
first
==
"CHANGELOG"
}.
flatten
.
last
blob
=
results
.
select
{
|
result
|
result
.
first
==
'CHANGELOG'
}.
flatten
.
last
expect
(
blob
.
filename
).
to
eq
(
"CHANGELOG"
)
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