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
fd2c3a3d
Commit
fd2c3a3d
authored
Oct 19, 2016
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring find_commits functionality
parent
f0c7e671
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
9 deletions
+8
-9
app/controllers/projects/commits_controller.rb
app/controllers/projects/commits_controller.rb
+1
-1
app/models/repository.rb
app/models/repository.rb
+6
-3
lib/gitlab/project_search_results.rb
lib/gitlab/project_search_results.rb
+1
-5
No files found.
app/controllers/projects/commits_controller.rb
View file @
fd2c3a3d
...
...
@@ -13,7 +13,7 @@ class Projects::CommitsController < Projects::ApplicationController
@commits
=
if
search
.
present?
@repository
.
find_commits_by_message
(
search
,
@ref
,
@path
,
@limit
,
@offset
)
.
compact
@repository
.
find_commits_by_message
(
search
,
@ref
,
@path
,
@limit
,
@offset
)
else
@repository
.
commits
(
@ref
,
path:
@path
,
limit:
@limit
,
offset:
@offset
)
end
...
...
app/models/repository.rb
View file @
fd2c3a3d
...
...
@@ -109,6 +109,10 @@ class Repository
end
def
find_commits_by_message
(
query
,
ref
=
nil
,
path
=
nil
,
limit
=
1000
,
offset
=
0
)
unless
exists?
&&
has_visible_content?
&&
query
.
present?
return
[]
end
ref
||=
root_ref
args
=
%W(
...
...
@@ -117,9 +121,8 @@ class Repository
)
args
=
args
.
concat
(
%W(--
#{
path
}
)
)
if
path
.
present?
git_log_results
=
Gitlab
::
Popen
.
popen
(
args
,
path_to_repo
).
first
.
lines
.
map
(
&
:chomp
)
commits
=
git_log_results
.
map
{
|
c
|
commit
(
c
)
}
commits
git_log_results
=
Gitlab
::
Popen
.
popen
(
args
,
path_to_repo
).
first
.
lines
git_log_results
.
map
{
|
c
|
commit
(
c
.
chomp
)
}.
compact
end
def
find_branch
(
name
,
fresh_repo:
true
)
...
...
lib/gitlab/project_search_results.rb
View file @
fd2c3a3d
...
...
@@ -73,11 +73,7 @@ module Gitlab
end
def
commits
if
project
.
empty_repo?
||
query
.
blank?
[]
else
project
.
repository
.
find_commits_by_message
(
query
).
compact
end
project
.
repository
.
find_commits_by_message
(
query
)
end
def
project_ids_relation
...
...
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