Commit b1f4aaa5 authored by Michael Chmielewski's avatar Michael Chmielewski

Trying to incorporate suggestions from comments on Merge Request 1661

parent 8e8fb87d
......@@ -87,10 +87,11 @@ class Repository
commits
end
def commits_with_log_matching(query)
list = Gitlab::Git::Commit.where(repo: raw_repository, limit: 1000)
list = Commit.decorate(list, @project) if list.present?
list.select! { |c| c.message.match /#{query}/i }
def find_commits_with_matching_log(query)
# Limited to 1000 commits for now, could be parameterized?
args = %W(git log --pretty=%H --max-count 1000 --grep=#{query})
Gitlab::Popen.popen(args, path_to_repo)
end
def find_branch(name)
......
......@@ -77,7 +77,7 @@ module Gitlab
end
def commits
project.repository.commits_with_log_matching(query)
project.repository.find_commits_with_matching_log(query)
end
def limit_project_ids
......
......@@ -26,8 +26,8 @@ describe Repository do
it { is_expected.to eq('c1acaa58bbcbc3eafe538cb8274ba387047b69f8') }
end
describe :commits_with_log_matching do
subject { repository.commits_with_log_matching('submodule').map{|k| k.id} }
describe :find_commits_with_matching_log do
subject { repository.find_commits_with_matching_log('submodule').map{|k| k.id} }
it { is_expected.to include('5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
it { is_expected.to include('6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment