diff options
author | Jonathan Schoeffling <jonathan.schoeffling@lmco.com> | 2015-06-15 01:04:20 +0300 |
---|---|---|
committer | Michael Chmielewski <code@mikec.123mail.org> | 2015-10-29 05:34:39 +0300 |
commit | 5a5069969ce8e9184e36abbb7623bf474d5869e9 (patch) | |
tree | ad20f6d4f79b67a26a6237e95e37b1af42517970 /app/models | |
parent | 8c9e1df98eb45e3305ab5badc6727580e84d36e0 (diff) |
Add support for searching commit log messages
Include the log messages of recent commits in project-level search
results, providing functionality similar to 'git log --grep'.
Update repository model rspec tests to validate the output of
Repository#commits_with_log_matching.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/repository.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index a3ba5f4c18a..39451f7da7f 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -87,6 +87,12 @@ 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 } + end + def find_branch(name) branches.find { |branch| branch.name == name } end |