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
f14466af
Commit
f14466af
authored
Dec 13, 2021
by
Zack Cuddy
Committed by
Natalia Tepluhina
Dec 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code Search - Git Blame Links
parent
d5f2020b
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
112 additions
and
18 deletions
+112
-18
app/assets/stylesheets/highlight/themes/dark.scss
app/assets/stylesheets/highlight/themes/dark.scss
+4
-2
app/assets/stylesheets/highlight/themes/monokai.scss
app/assets/stylesheets/highlight/themes/monokai.scss
+4
-2
app/assets/stylesheets/highlight/themes/none.scss
app/assets/stylesheets/highlight/themes/none.scss
+4
-2
app/assets/stylesheets/highlight/themes/solarized-dark.scss
app/assets/stylesheets/highlight/themes/solarized-dark.scss
+4
-2
app/assets/stylesheets/highlight/themes/solarized-light.scss
app/assets/stylesheets/highlight/themes/solarized-light.scss
+4
-2
app/assets/stylesheets/highlight/white_base.scss
app/assets/stylesheets/highlight/white_base.scss
+4
-2
app/assets/stylesheets/pages/search.scss
app/assets/stylesheets/pages/search.scss
+45
-0
app/views/search/results/_blob.html.haml
app/views/search/results/_blob.html.haml
+2
-1
app/views/search/results/_blob_data.html.haml
app/views/search/results/_blob_data.html.haml
+1
-1
app/views/search/results/_blob_highlight.html.haml
app/views/search/results/_blob_highlight.html.haml
+22
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/features/search/user_searches_for_code_spec.rb
spec/features/search/user_searches_for_code_spec.rb
+15
-4
No files found.
app/assets/stylesheets/highlight/themes/dark.scss
View file @
f14466af
...
@@ -94,7 +94,8 @@ $dark-il: #de935f;
...
@@ -94,7 +94,8 @@ $dark-il: #de935f;
}
}
.line-numbers
,
.line-numbers
,
.diff-line-num
{
.diff-line-num
,
.code-search-line
{
background-color
:
$dark-main-bg
;
background-color
:
$dark-main-bg
;
}
}
...
@@ -168,7 +169,8 @@ $dark-il: #de935f;
...
@@ -168,7 +169,8 @@ $dark-il: #de935f;
}
}
.diff-grid-left
:hover
,
.diff-grid-left
:hover
,
.diff-grid-right
:hover
{
.diff-grid-right
:hover
,
&
.code-search-line
:hover
{
.diff-line-num
:not
(
.empty-cell
)
{
.diff-line-num
:not
(
.empty-cell
)
{
@include
line-number-hover
;
@include
line-number-hover
;
}
}
...
...
app/assets/stylesheets/highlight/themes/monokai.scss
View file @
f14466af
...
@@ -95,7 +95,8 @@ $monokai-gh: #75715e;
...
@@ -95,7 +95,8 @@ $monokai-gh: #75715e;
}
}
.line-numbers
,
.line-numbers
,
.diff-line-num
{
.diff-line-num
,
.code-search-line
{
background-color
:
$monokai-bg
;
background-color
:
$monokai-bg
;
}
}
...
@@ -169,7 +170,8 @@ $monokai-gh: #75715e;
...
@@ -169,7 +170,8 @@ $monokai-gh: #75715e;
}
}
.diff-grid-left
:hover
,
.diff-grid-left
:hover
,
.diff-grid-right
:hover
{
.diff-grid-right
:hover
,
&
.code-search-line
:hover
{
.diff-line-num
:not
(
.empty-cell
)
{
.diff-line-num
:not
(
.empty-cell
)
{
@include
line-number-hover
;
@include
line-number-hover
;
}
}
...
...
app/assets/stylesheets/highlight/themes/none.scss
View file @
f14466af
...
@@ -16,7 +16,8 @@
...
@@ -16,7 +16,8 @@
}
}
.line-numbers
,
.line-numbers
,
.diff-line-num
{
.diff-line-num
,
.code-search-line
{
background-color
:
$gray-light
;
background-color
:
$gray-light
;
}
}
...
@@ -66,7 +67,8 @@
...
@@ -66,7 +67,8 @@
}
}
.diff-grid-left
:hover
,
.diff-grid-left
:hover
,
.diff-grid-right
:hover
{
.diff-grid-right
:hover
,
&
.code-search-line
:hover
{
.diff-line-num
:not
(
.empty-cell
)
{
.diff-line-num
:not
(
.empty-cell
)
{
@include
line-number-hover
;
@include
line-number-hover
;
}
}
...
...
app/assets/stylesheets/highlight/themes/solarized-dark.scss
View file @
f14466af
...
@@ -98,7 +98,8 @@ $solarized-dark-il: #2aa198;
...
@@ -98,7 +98,8 @@ $solarized-dark-il: #2aa198;
}
}
.line-numbers
,
.line-numbers
,
.diff-line-num
{
.diff-line-num
,
.code-search-line
{
background-color
:
$solarized-dark-line-bg
;
background-color
:
$solarized-dark-line-bg
;
}
}
...
@@ -148,7 +149,8 @@ $solarized-dark-il: #2aa198;
...
@@ -148,7 +149,8 @@ $solarized-dark-il: #2aa198;
}
}
.diff-grid-left
:hover
,
.diff-grid-left
:hover
,
.diff-grid-right
:hover
{
.diff-grid-right
:hover
,
&
.code-search-line
:hover
{
.diff-line-num
:not
(
.empty-cell
)
{
.diff-line-num
:not
(
.empty-cell
)
{
@include
line-number-hover
;
@include
line-number-hover
;
}
}
...
...
app/assets/stylesheets/highlight/themes/solarized-light.scss
View file @
f14466af
...
@@ -105,7 +105,8 @@ $solarized-light-il: #2aa198;
...
@@ -105,7 +105,8 @@ $solarized-light-il: #2aa198;
}
}
.line-numbers
,
.line-numbers
,
.diff-line-num
{
.diff-line-num
,
.code-search-line
{
background-color
:
$solarized-light-line-bg
;
background-color
:
$solarized-light-line-bg
;
}
}
...
@@ -168,7 +169,8 @@ $solarized-light-il: #2aa198;
...
@@ -168,7 +169,8 @@ $solarized-light-il: #2aa198;
}
}
.diff-grid-left
:hover
,
.diff-grid-left
:hover
,
.diff-grid-right
:hover
{
.diff-grid-right
:hover
,
&
.code-search-line
:hover
{
.diff-line-num
:not
(
.empty-cell
)
{
.diff-line-num
:not
(
.empty-cell
)
{
@include
line-number-hover
;
@include
line-number-hover
;
}
}
...
...
app/assets/stylesheets/highlight/white_base.scss
View file @
f14466af
...
@@ -82,7 +82,8 @@ $white-gc-bg: #eaf2f5;
...
@@ -82,7 +82,8 @@ $white-gc-bg: #eaf2f5;
}
}
.line-numbers
,
.line-numbers
,
.diff-line-num
{
.diff-line-num
,
.code-search-line
{
background-color
:
$gray-light
;
background-color
:
$gray-light
;
&
.conflict_marker
,
&
.conflict_marker
,
...
@@ -128,7 +129,8 @@ pre.code,
...
@@ -128,7 +129,8 @@ pre.code,
}
}
.diff-grid-left
:hover
,
.diff-grid-left
:hover
,
.diff-grid-right
:hover
{
.diff-grid-right
:hover
,
&
.code-search-line
:hover
{
.diff-line-num
:not
(
.empty-cell
)
:not
(
.conflict_marker_their
)
:not
(
.conflict_marker_our
)
{
.diff-line-num
:not
(
.empty-cell
)
:not
(
.conflict_marker_their
)
:not
(
.conflict_marker_our
)
{
@include
line-number-hover
;
@include
line-number-hover
;
}
}
...
...
app/assets/stylesheets/pages/search.scss
View file @
f14466af
...
@@ -321,6 +321,51 @@ input[type='checkbox']:hover {
...
@@ -321,6 +321,51 @@ input[type='checkbox']:hover {
}
}
}
}
// This overrides parts of the Project File View CSS
// We leverage most of the styling but broke off
// from how we were doing it in `shared/file_highlight`
#search-blob-content
{
.line_holder
{
pre
{
padding
:
0
;
// This overrides the existing style that will add space between each line.
}
svg
{
float
:
none
;
// We have more than one icon on this implementation and don't want to float them.
margin
:
0
;
// We will manage the margin with GitLab UI utility classes
}
.line-numbers
{
padding
:
0
;
// This overrides the existing style that will add space between each line.
min-width
:
6
.5rem
;
// Ensure our numbers fit
.diff-line-num
{
a
{
transition
:
none
;
// There will be a hover transition from theme, blue, darkened
}
}
}
&
:hover
{
svg
{
visibility
:
visible
;
// We want to show the icons when the any part of the line is hovered
}
}
// The icons only appear on hover
// So on mobile we can hide them and retake the space for the code blob
@include
media-breakpoint-down
(
sm
)
{
svg
{
display
:
none
;
}
.line-numbers
{
min-width
:
4rem
;
}
}
}
}
// Disable webkit input icons, link to solution: https://stackoverflow.com/questions/9421551/how-do-i-remove-all-default-webkit-search-field-styling
// Disable webkit input icons, link to solution: https://stackoverflow.com/questions/9421551/how-do-i-remove-all-default-webkit-search-field-styling
/* stylelint-disable property-no-vendor-prefix */
/* stylelint-disable property-no-vendor-prefix */
input
[
type
=
'search'
]
::-webkit-search-decoration
,
input
[
type
=
'search'
]
::-webkit-search-decoration
,
...
...
app/views/search/results/_blob.html.haml
View file @
f14466af
-
project
=
blob
.
project
-
project
=
blob
.
project
-
return
unless
project
-
return
unless
project
-
blob_link
=
project_blob_path
(
project
,
tree_join
(
repository_ref
(
project
),
blob
.
path
))
-
blob_link
=
project_blob_path
(
project
,
tree_join
(
repository_ref
(
project
),
blob
.
path
))
-
blame_link
=
project_blame_path
(
project
,
tree_join
(
repository_ref
(
project
),
blob
.
path
))
=
render
partial:
'search/results/blob_data'
,
locals:
{
blob:
blob
,
project:
project
,
path:
blob
.
path
,
blob_link:
blob_link
}
=
render
partial:
'search/results/blob_data'
,
locals:
{
blob:
blob
,
project:
project
,
path:
blob
.
path
,
blob_link:
blob_link
,
blame_link:
blame_link
}
app/views/search/results/_blob_data.html.haml
View file @
f14466af
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
-
if
blob
.
data
-
if
blob
.
data
-
if
blob
.
data
.
size
>
0
-
if
blob
.
data
.
size
>
0
.file-content.code.term
{
data:
{
qa_selector:
'file_text_content'
}
}
.file-content.code.term
{
data:
{
qa_selector:
'file_text_content'
}
}
=
render
's
hared/file_highlight'
,
blob:
blob
,
first_line_number:
blob
.
startline
,
blob_link:
blob
_link
,
highlight_line:
blob
.
highlight_line
=
render
's
earch/results/blob_highlight'
,
blob:
blob
,
first_line_number:
blob
.
startline
,
blob_link:
blob_link
,
blame_link:
blame
_link
,
highlight_line:
blob
.
highlight_line
-
else
-
else
.file-content.code
.file-content.code
.nothing-here-block
.nothing-here-block
...
...
app/views/search/results/_blob_highlight.html.haml
0 → 100644
View file @
f14466af
-
offset
=
defined?
(
first_line_number
)
?
first_line_number
:
1
-
highlight
=
defined?
(
highlight_line
)
&&
highlight_line
?
highlight_line
-
offset
:
nil
#search-blob-content
.file-content.code.js-syntax-highlight
{
class:
'gl-py-3!'
}
-
if
blob
.
present?
.blob-content
{
data:
{
blob_id:
blob
.
id
,
path:
blob
.
path
,
highlight_line:
highlight
,
qa_selector:
'file_content'
}
}
-
blob
.
present
.
highlight
.
lines
.
each_with_index
do
|
line
,
index
|
-
i
=
index
+
offset
.line_holder.code-search-line
.line-numbers
.gl-display-flex
%span
.diff-line-num.gl-pl-3
%a
.has-tooltip
{
href:
"#{blame_link}#L#{i}"
,
id:
"blame-L#{i}"
,
'data-line-number'
=>
i
,
title:
_
(
'View blame'
)
}
=
sprite_icon
(
'git'
)
%span
.diff-line-num.flex-grow-1.gl-pr-3
%a
{
href:
"#{blob_link}#L#{i}"
,
id:
"blob-L#{i}"
,
'data-line-number'
=>
i
,
class:
'gl-display-flex! gl-align-items-center gl-justify-content-end'
}
=
sprite_icon
(
'link'
,
css_class:
'gl-ml-3! gl-mr-1!'
)
=
i
%pre
.code.highlight
%code
=
line
.
html_safe
locale/gitlab.pot
View file @
f14466af
...
@@ -38570,6 +38570,9 @@ msgstr ""
...
@@ -38570,6 +38570,9 @@ msgstr ""
msgid "View all issues"
msgid "View all issues"
msgstr ""
msgstr ""
msgid "View blame"
msgstr ""
msgid "View blame prior to this change"
msgid "View blame prior to this change"
msgstr ""
msgstr ""
...
...
spec/features/search/user_searches_for_code_spec.rb
View file @
f14466af
...
@@ -40,14 +40,24 @@ RSpec.describe 'User searches for code' do
...
@@ -40,14 +40,24 @@ RSpec.describe 'User searches for code' do
include_examples
'top right search form'
include_examples
'top right search form'
include_examples
'search timeouts'
,
'blobs'
include_examples
'search timeouts'
,
'blobs'
it
'finds code'
do
it
'finds code and links to blob'
do
fill_in
(
'dashboard_search'
,
with:
'rspec'
)
find
(
'.btn-search'
).
click
expect
(
page
).
to
have_selector
(
'.results'
,
text:
'Update capybara, rspec-rails, poltergeist to recent versions'
)
find
(
"#blob-L3"
).
click
expect
(
current_url
).
to
match
(
%r{blob/master/.gitignore#L3}
)
end
it
'finds code and links to blame'
do
fill_in
(
'dashboard_search'
,
with:
'rspec'
)
fill_in
(
'dashboard_search'
,
with:
'rspec'
)
find
(
'.btn-search'
).
click
find
(
'.btn-search'
).
click
expect
(
page
).
to
have_selector
(
'.results'
,
text:
'Update capybara, rspec-rails, poltergeist to recent versions'
)
expect
(
page
).
to
have_selector
(
'.results'
,
text:
'Update capybara, rspec-rails, poltergeist to recent versions'
)
find
(
"#L3"
).
click
find
(
"#
blame-
L3"
).
click
expect
(
current_url
).
to
match
(
%r{master/.gitignore#L3}
)
expect
(
current_url
).
to
match
(
%r{
blame/
master/.gitignore#L3}
)
end
end
it
'search mutiple words with refs switching'
do
it
'search mutiple words with refs switching'
do
...
@@ -65,7 +75,8 @@ RSpec.describe 'User searches for code' do
...
@@ -65,7 +75,8 @@ RSpec.describe 'User searches for code' do
expect
(
page
).
to
have_selector
(
'.results'
,
text:
expected_result
)
expect
(
page
).
to
have_selector
(
'.results'
,
text:
expected_result
)
expect
(
find_field
(
'dashboard_search'
).
value
).
to
eq
(
search
)
expect
(
find_field
(
'dashboard_search'
).
value
).
to
eq
(
search
)
expect
(
find
(
"#L1502"
)[
:href
]).
to
match
(
%r{v1.0.0/files/markdown/ruby-style-guide.md#L1502}
)
expect
(
find
(
"#blob-L1502"
)[
:href
]).
to
match
(
%r{blob/v1.0.0/files/markdown/ruby-style-guide.md#L1502}
)
expect
(
find
(
"#blame-L1502"
)[
:href
]).
to
match
(
%r{blame/v1.0.0/files/markdown/ruby-style-guide.md#L1502}
)
end
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