Skip to content
Snippets Groups Projects
Commit 7a184617 authored by Valery Sizov's avatar Valery Sizov Committed by blackst0ne
Browse files

Refactoring find_commits functionality

parent 6fd561d2
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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(
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment