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
c9c191b1
Commit
c9c191b1
authored
Mar 20, 2018
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-03-20
# Conflicts: # app/helpers/services_helper.rb [ci skip]
parents
27db2abb
216ead60
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
10 deletions
+30
-10
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+3
-3
app/helpers/services_helper.rb
app/helpers/services_helper.rb
+3
-0
changelogs/unreleased/44280-fix-code-search.yml
changelogs/unreleased/44280-fix-code-search.yml
+5
-0
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+1
-1
lib/gitlab/project_search_results.rb
lib/gitlab/project_search_results.rb
+1
-1
spec/lib/gitlab/project_search_results_spec.rb
spec/lib/gitlab/project_search_results_spec.rb
+17
-5
No files found.
app/helpers/application_helper.rb
View file @
c9c191b1
...
...
@@ -304,7 +304,7 @@ module ApplicationHelper
def
linkedin_url
(
user
)
name
=
user
.
linkedin
if
name
=~
%r{
\A
https?:
\/\/
(www
\.
)?linkedin
\.
com
\/
in
\
/
}
if
name
=~
%r{
\A
https?:
//(www
\.
)?linkedin
\.
com/in
/}
name
else
"https://www.linkedin.com/in/
#{
name
}
"
...
...
@@ -313,10 +313,10 @@ module ApplicationHelper
def
twitter_url
(
user
)
name
=
user
.
twitter
if
name
=~
%r{
\A
https?:
\/\/
(www
\.
)?twitter
\.
com
\
/
}
if
name
=~
%r{
\A
https?:
//(www
\.
)?twitter
\.
com
/}
name
else
"https://
www.
twitter.com/
#{
name
}
"
"https://twitter.com/
#{
name
}
"
end
end
...
...
app/helpers/services_helper.rb
View file @
c9c191b1
module
ServicesHelper
<<<<<<<
HEAD
prepend
EE
::
ServicesHelper
=======
>>>>>>>
upstream
/
master
def
service_event_field_name
(
event
)
event
=
event
.
pluralize
if
%w[merge_request issue confidential_issue]
.
include?
(
event
)
"
#{
event
}
_events"
...
...
changelogs/unreleased/44280-fix-code-search.yml
0 → 100644
View file @
c9c191b1
---
title
:
Fix search results stripping last endline when parsing the results
merge_request
:
17777
author
:
Jasper Maes
type
:
fixed
lib/gitlab/git/repository.rb
View file @
c9c191b1
...
...
@@ -1394,7 +1394,7 @@ module Gitlab
offset
=
2
args
=
%W(grep -i -I -n -z --before-context
#{
offset
}
--after-context
#{
offset
}
-E -e
#{
Regexp
.
escape
(
query
)
}
#{
ref
||
root_ref
}
)
run_git
(
args
).
first
.
scrub
.
split
(
/^--
$
/
)
run_git
(
args
).
first
.
scrub
.
split
(
/^--
\n
/
)
end
def
can_be_merged?
(
source_sha
,
target_branch
)
...
...
lib/gitlab/project_search_results.rb
View file @
c9c191b1
...
...
@@ -58,7 +58,7 @@ module Gitlab
data
=
""
startline
=
0
result
.
strip
.
each_line
.
each_with_index
do
|
line
,
index
|
result
.
each_line
.
each_with_index
do
|
line
,
index
|
prefix
||=
line
.
match
(
/^(?<ref>[^:]*):(?<filename>.*)\x00(?<startline>\d+)\x00/
)
&
.
tap
do
|
matches
|
ref
=
matches
[
:ref
]
filename
=
matches
[
:filename
]
...
...
spec/lib/gitlab/project_search_results_spec.rb
View file @
c9c191b1
...
...
@@ -83,19 +83,19 @@ describe Gitlab::ProjectSearchResults do
end
context
'when the matching filename contains a colon'
do
let
(
:search_result
)
{
"
\n
master:testdata/project::function1.yaml
\x00
1
\x00
---
\n
"
}
let
(
:search_result
)
{
"master:testdata/project::function1.yaml
\x00
1
\x00
---
\n
"
}
it
'returns a valid FoundBlob'
do
expect
(
subject
.
filename
).
to
eq
(
'testdata/project::function1.yaml'
)
expect
(
subject
.
basename
).
to
eq
(
'testdata/project::function1'
)
expect
(
subject
.
ref
).
to
eq
(
'master'
)
expect
(
subject
.
startline
).
to
eq
(
1
)
expect
(
subject
.
data
).
to
eq
(
'---'
)
expect
(
subject
.
data
).
to
eq
(
"---
\n
"
)
end
end
context
'when the matching content contains a number surrounded by colons'
do
let
(
:search_result
)
{
"
\n
master:testdata/foo.txt
\x00
1
\x00
blah:9:blah"
}
let
(
:search_result
)
{
"master:testdata/foo.txt
\x00
1
\x00
blah:9:blah"
}
it
'returns a valid FoundBlob'
do
expect
(
subject
.
filename
).
to
eq
(
'testdata/foo.txt'
)
...
...
@@ -106,6 +106,18 @@ describe Gitlab::ProjectSearchResults do
end
end
context
'when the search result ends with an empty line'
do
let
(
:results
)
{
project
.
repository
.
search_files_by_content
(
'Role models'
,
'master'
)
}
it
'returns a valid FoundBlob that ends with an empty line'
do
expect
(
subject
.
filename
).
to
eq
(
'files/markdown/ruby-style-guide.md'
)
expect
(
subject
.
basename
).
to
eq
(
'files/markdown/ruby-style-guide'
)
expect
(
subject
.
ref
).
to
eq
(
'master'
)
expect
(
subject
.
startline
).
to
eq
(
1
)
expect
(
subject
.
data
).
to
eq
(
"# Prelude
\n\n
> Role models are important. <br/>
\n
> -- Officer Alex J. Murphy / RoboCop
\n\n
"
)
end
end
context
'when the search returns non-ASCII data'
do
context
'with UTF-8'
do
let
(
:results
)
{
project
.
repository
.
search_files_by_content
(
'файл'
,
'master'
)
}
...
...
@@ -115,7 +127,7 @@ describe Gitlab::ProjectSearchResults do
expect
(
subject
.
basename
).
to
eq
(
'encoding/russian'
)
expect
(
subject
.
ref
).
to
eq
(
'master'
)
expect
(
subject
.
startline
).
to
eq
(
1
)
expect
(
subject
.
data
).
to
eq
(
'Хороший файл'
)
expect
(
subject
.
data
).
to
eq
(
"Хороший файл
\n
"
)
end
end
...
...
@@ -139,7 +151,7 @@ describe Gitlab::ProjectSearchResults do
expect
(
subject
.
basename
).
to
eq
(
'encoding/iso8859'
)
expect
(
subject
.
ref
).
to
eq
(
'master'
)
expect
(
subject
.
startline
).
to
eq
(
1
)
expect
(
subject
.
data
).
to
eq
(
"Äü
\n\n
foo"
)
expect
(
subject
.
data
).
to
eq
(
"Äü
\n\n
foo
\n
"
)
end
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