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 ...@@ -87,10 +87,11 @@ class Repository
commits commits
end end
def commits_with_log_matching(query) def find_commits_with_matching_log(query)
list = Gitlab::Git::Commit.where(repo: raw_repository, limit: 1000) # Limited to 1000 commits for now, could be parameterized?
list = Commit.decorate(list, @project) if list.present? args = %W(git log --pretty=%H --max-count 1000 --grep=#{query})
list.select! { |c| c.message.match /#{query}/i }
Gitlab::Popen.popen(args, path_to_repo)
end end
def find_branch(name) def find_branch(name)
......
...@@ -77,7 +77,7 @@ module Gitlab ...@@ -77,7 +77,7 @@ module Gitlab
end end
def commits def commits
project.repository.commits_with_log_matching(query) project.repository.find_commits_with_matching_log(query)
end end
def limit_project_ids def limit_project_ids
......
...@@ -26,8 +26,8 @@ describe Repository do ...@@ -26,8 +26,8 @@ describe Repository do
it { is_expected.to eq('c1acaa58bbcbc3eafe538cb8274ba387047b69f8') } it { is_expected.to eq('c1acaa58bbcbc3eafe538cb8274ba387047b69f8') }
end end
describe :commits_with_log_matching do describe :find_commits_with_matching_log do
subject { repository.commits_with_log_matching('submodule').map{|k| k.id} } subject { repository.find_commits_with_matching_log('submodule').map{|k| k.id} }
it { is_expected.to include('5937ac0a7beb003549fc5fd26fc247adbce4a52e') } it { is_expected.to include('5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
it { is_expected.to include('6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') } 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