diff options
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r-- | app/models/repository.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index c9b36bd8170..9266ba27f0a 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -87,6 +87,15 @@ class Repository commits end + def find_commits_by_message(query) + # Limited to 1000 commits for now, could be parameterized? + args = %W(git log --pretty=%H --max-count 1000 --grep=#{query}) + + git_log_results = Gitlab::Popen.popen(args, path_to_repo).first.lines.map(&:chomp) + commits = git_log_results.map { |c| commit(c) } + commits + end + def find_branch(name) branches.find { |branch| branch.name == name } end |