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
Boxiang Sun
gitlab-ce
Commits
fb2f8be4
Commit
fb2f8be4
authored
Nov 03, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'olhado/gitlab-ce-commit-search'
parents
d0e74f49
28f6fba9
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
52 additions
and
6 deletions
+52
-6
CHANGELOG
CHANGELOG
+1
-0
app/assets/stylesheets/pages/commits.scss
app/assets/stylesheets/pages/commits.scss
+2
-0
app/controllers/search_controller.rb
app/controllers/search_controller.rb
+2
-2
app/models/repository.rb
app/models/repository.rb
+9
-0
app/views/layouts/_search.html.haml
app/views/layouts/_search.html.haml
+2
-0
app/views/search/_category.html.haml
app/views/search/_category.html.haml
+7
-0
app/views/search/results/_commits.html.haml
app/views/search/results/_commits.html.haml
+2
-0
lib/gitlab/project_search_results.rb
lib/gitlab/project_search_results.rb
+15
-1
lib/tasks/spinach.rake
lib/tasks/spinach.rake
+3
-3
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+9
-0
No files found.
CHANGELOG
View file @
fb2f8be4
...
@@ -18,6 +18,7 @@ v 8.2.0 (unreleased)
...
@@ -18,6 +18,7 @@ v 8.2.0 (unreleased)
- Use issue editor as cross reference comment author when issue is edited with a new mention.
- Use issue editor as cross reference comment author when issue is edited with a new mention.
- [API] Add ability to fetch the commit ID of the last commit that actually touched a file
- [API] Add ability to fetch the commit ID of the last commit that actually touched a file
- Add "New file" link to dropdown on project page
- Add "New file" link to dropdown on project page
- Include commit logs in project search
v 8.1.1
v 8.1.1
- Fix cloning Wiki repositories via HTTP (Stan Hu)
- Fix cloning Wiki repositories via HTTP (Stan Hu)
...
...
app/assets/stylesheets/pages/commits.scss
View file @
fb2f8be4
...
@@ -33,6 +33,8 @@
...
@@ -33,6 +33,8 @@
}
}
li
.commit
{
li
.commit
{
list-style
:
none
;
.commit-row-title
{
.commit-row-title
{
font-size
:
$list-font-size
;
font-size
:
$list-font-size
;
line-height
:
20px
;
line-height
:
20px
;
...
...
app/controllers/search_controller.rb
View file @
fb2f8be4
...
@@ -23,8 +23,8 @@ class SearchController < ApplicationController
...
@@ -23,8 +23,8 @@ class SearchController < ApplicationController
@search_results
=
@search_results
=
if
@project
if
@project
unless
%w(blobs notes issues merge_requests milestones wiki_blobs
)
.
unless
%w(blobs notes issues merge_requests milestones wiki_blobs
include?
(
@scope
)
commits)
.
include?
(
@scope
)
@scope
=
'blobs'
@scope
=
'blobs'
end
end
...
...
app/models/repository.rb
View file @
fb2f8be4
...
@@ -87,6 +87,15 @@ class Repository
...
@@ -87,6 +87,15 @@ class Repository
commits
commits
end
end
def
find_commits_by_message
(
query
)
# Limited to 1000 commits for now, could be parameterized?
args
=
%W(git log --pretty=%H --max-count 1000 --grep=
#{
query
}
)
git_log_results
=
Gitlab
::
Popen
.
popen
(
args
,
path_to_repo
).
first
.
lines
.
map
(
&
:chomp
)
commits
=
git_log_results
.
map
{
|
c
|
commit
(
c
)
}
commits
end
def
find_branch
(
name
)
def
find_branch
(
name
)
branches
.
find
{
|
branch
|
branch
.
name
==
name
}
branches
.
find
{
|
branch
|
branch
.
name
==
name
}
end
end
...
...
app/views/layouts/_search.html.haml
View file @
fb2f8be4
...
@@ -11,6 +11,8 @@
...
@@ -11,6 +11,8 @@
=
hidden_field_tag
:scope
,
'merge_requests'
=
hidden_field_tag
:scope
,
'merge_requests'
-
elsif
current_controller?
(
:wikis
)
-
elsif
current_controller?
(
:wikis
)
=
hidden_field_tag
:scope
,
'wiki_blobs'
=
hidden_field_tag
:scope
,
'wiki_blobs'
-
elsif
current_controller?
(
:commits
)
=
hidden_field_tag
:scope
,
'commits'
-
else
-
else
=
hidden_field_tag
:search_code
,
true
=
hidden_field_tag
:search_code
,
true
...
...
app/views/search/_category.html.haml
View file @
fb2f8be4
...
@@ -42,6 +42,13 @@
...
@@ -42,6 +42,13 @@
Wiki
Wiki
%span
.badge
%span
.badge
=
@search_results
.
wiki_blobs_count
=
@search_results
.
wiki_blobs_count
%li
{
class:
(
"active"
if
@scope
==
'commits'
)}
=
link_to
search_filter_path
(
scope:
'commits'
)
do
=
icon
(
'history fw'
)
%span
Commits
%span
.badge
=
@search_results
.
commits_count
-
elsif
@show_snippets
-
elsif
@show_snippets
%li
{
class:
(
"active"
if
@scope
==
'snippet_blobs'
)}
%li
{
class:
(
"active"
if
@scope
==
'snippet_blobs'
)}
...
...
app/views/search/results/_commits.html.haml
0 → 100644
View file @
fb2f8be4
.search-result-row
=
render
'projects/commits/commit'
,
project:
@project
,
commit:
commits
lib/gitlab/project_search_results.rb
View file @
fb2f8be4
...
@@ -20,6 +20,8 @@ module Gitlab
...
@@ -20,6 +20,8 @@ module Gitlab
Kaminari
.
paginate_array
(
blobs
).
page
(
page
).
per
(
per_page
)
Kaminari
.
paginate_array
(
blobs
).
page
(
page
).
per
(
per_page
)
when
'wiki_blobs'
when
'wiki_blobs'
Kaminari
.
paginate_array
(
wiki_blobs
).
page
(
page
).
per
(
per_page
)
Kaminari
.
paginate_array
(
wiki_blobs
).
page
(
page
).
per
(
per_page
)
when
'commits'
Kaminari
.
paginate_array
(
commits
).
page
(
page
).
per
(
per_page
)
else
else
super
super
end
end
...
@@ -27,7 +29,7 @@ module Gitlab
...
@@ -27,7 +29,7 @@ module Gitlab
def
total_count
def
total_count
@total_count
||=
issues_count
+
merge_requests_count
+
blobs_count
+
@total_count
||=
issues_count
+
merge_requests_count
+
blobs_count
+
notes_count
+
wiki_blobs_count
notes_count
+
wiki_blobs_count
+
commits_count
end
end
def
blobs_count
def
blobs_count
...
@@ -42,6 +44,10 @@ module Gitlab
...
@@ -42,6 +44,10 @@ module Gitlab
@wiki_blobs_count
||=
wiki_blobs
.
count
@wiki_blobs_count
||=
wiki_blobs
.
count
end
end
def
commits_count
@commits_count
||=
commits
.
count
end
private
private
def
blobs
def
blobs
...
@@ -70,6 +76,14 @@ module Gitlab
...
@@ -70,6 +76,14 @@ module Gitlab
Note
.
where
(
project_id:
limit_project_ids
).
user
.
search
(
query
).
order
(
'updated_at DESC'
)
Note
.
where
(
project_id:
limit_project_ids
).
user
.
search
(
query
).
order
(
'updated_at DESC'
)
end
end
def
commits
if
project
.
empty_repo?
||
query
.
blank?
[]
else
project
.
repository
.
find_commits_by_message
(
query
).
compact
end
end
def
limit_project_ids
def
limit_project_ids
[
project
.
id
]
[
project
.
id
]
end
end
...
...
lib/tasks/spinach.rake
View file @
fb2f8be4
...
@@ -5,7 +5,7 @@ namespace :spinach do
...
@@ -5,7 +5,7 @@ namespace :spinach do
task
:project
do
task
:project
do
cmds
=
[
cmds
=
[
%W(rake gitlab:setup)
,
%W(rake gitlab:setup)
,
%W(spinach --tags ~@admin,~@dashboard,~@profile,~@public,~@snippets)
,
%W(spinach --tags ~@admin,~@dashboard,~@profile,~@public,~@snippets
,~@commits
)
,
]
]
run_commands
(
cmds
)
run_commands
(
cmds
)
end
end
...
@@ -14,7 +14,7 @@ namespace :spinach do
...
@@ -14,7 +14,7 @@ namespace :spinach do
task
:other
do
task
:other
do
cmds
=
[
cmds
=
[
%W(rake gitlab:setup)
,
%W(rake gitlab:setup)
,
%W(spinach --tags @admin,@dashboard,@profile,@public,@snippets)
,
%W(spinach --tags @admin,@dashboard,@profile,@public,@snippets
,@commits
)
,
]
]
run_commands
(
cmds
)
run_commands
(
cmds
)
end
end
...
...
spec/models/repository_spec.rb
View file @
fb2f8be4
...
@@ -26,6 +26,15 @@ describe Repository do
...
@@ -26,6 +26,15 @@ describe Repository do
it
{
is_expected
.
to
eq
(
'c1acaa58bbcbc3eafe538cb8274ba387047b69f8'
)
}
it
{
is_expected
.
to
eq
(
'c1acaa58bbcbc3eafe538cb8274ba387047b69f8'
)
}
end
end
describe
:find_commits_by_message
do
subject
{
repository
.
find_commits_by_message
(
'submodule'
).
map
{
|
k
|
k
.
id
}
}
it
{
is_expected
.
to
include
(
'5937ac0a7beb003549fc5fd26fc247adbce4a52e'
)
}
it
{
is_expected
.
to
include
(
'6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9'
)
}
it
{
is_expected
.
to
include
(
'cfe32cf61b73a0d5e9f13e774abde7ff789b1660'
)
}
it
{
is_expected
.
not_to
include
(
'913c66a37b4a45b9769037c55c2d238bd0942d2e'
)
}
end
describe
:blob_at
do
describe
:blob_at
do
context
'blank sha'
do
context
'blank sha'
do
subject
{
repository
.
blob_at
(
Gitlab
::
Git
::
BLANK_SHA
,
'.gitignore'
)
}
subject
{
repository
.
blob_at
(
Gitlab
::
Git
::
BLANK_SHA
,
'.gitignore'
)
}
...
...
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