Trying to incorporate suggestions from comments on Merge Request 1661

This commit is contained in:
Michael Chmielewski 2015-10-27 21:16:56 -04:00
parent 8e8fb87d40
commit b1f4aaa5e7
3 changed files with 8 additions and 7 deletions

View File

@ -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)

View File

@ -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

View File

@ -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') }