diff options
| author | Michael Chmielewski <code@mikec.123mail.org> | 2015-10-27 21:16:56 -0400 | 
|---|---|---|
| committer | Michael Chmielewski <code@mikec.123mail.org> | 2015-10-28 22:34:39 -0400 | 
| commit | b1f4aaa5e753e6e7cdefd84226839123df59b382 (patch) | |
| tree | 4012175075b2f914c5e8c0ed67d33951fa67ae4b | |
| parent | 8e8fb87d4091f05a75929d6daa3bbe6862e2dda1 (diff) | |
| download | gitlab-ce-b1f4aaa5e753e6e7cdefd84226839123df59b382.tar.gz | |
Trying to incorporate suggestions from comments on Merge Request 1661
| -rw-r--r-- | app/models/repository.rb | 9 | ||||
| -rw-r--r-- | lib/gitlab/project_search_results.rb | 2 | ||||
| -rw-r--r-- | spec/models/repository_spec.rb | 4 | 
3 files changed, 8 insertions, 7 deletions
| diff --git a/app/models/repository.rb b/app/models/repository.rb index 39451f7da7f..ed7ed9fd261 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -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) diff --git a/lib/gitlab/project_search_results.rb b/lib/gitlab/project_search_results.rb index 3bf98699bcb..54389f7d662 100644 --- a/lib/gitlab/project_search_results.rb +++ b/lib/gitlab/project_search_results.rb @@ -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 diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index a6973ea8fcb..26c92af31ed 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -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') } | 
