diff options
author | Robert Speicher <robert@gitlab.com> | 2017-08-08 00:33:45 +0300 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-08-08 00:33:45 +0300 |
commit | 475f41acd4a8e0666736d40feb4d8945cf2c306a (patch) | |
tree | 73288e5750c8a212ad5394a2fb0f7090237a6289 /app | |
parent | 6085ce1352eee7b3e18b014f0f68719cae780da8 (diff) | |
parent | c0b41064ff1eb4c5465d3c2a9efa0a22b60c3f4c (diff) |
Merge branch 'feature/migrate-find-commits-by-message-to-gitaly' into 'master'
Migrate Repository#find_commits_by_message to Gitaly
Closes gitaly#443
See merge request !13268
Diffstat (limited to 'app')
-rw-r--r-- | app/models/repository.rb | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index f86a0869b01..3b5d0e00c70 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -130,17 +130,13 @@ class Repository return [] end - ref ||= root_ref - - args = %W( - log #{ref} --pretty=%H --skip #{offset} - --max-count #{limit} --grep=#{query} --regexp-ignore-case - ) - args = args.concat(%W(-- #{path})) if path.present? - - git_log_results = run_git(args).first.lines - - git_log_results.map { |c| commit(c.chomp) }.compact + raw_repository.gitaly_migrate(:commits_by_message) do |is_enabled| + if is_enabled + find_commits_by_message_by_gitaly(query, ref, path, limit, offset) + else + find_commits_by_message_by_shelling_out(query, ref, path, limit, offset) + end + end end def find_branch(name, fresh_repo: true) @@ -1184,4 +1180,25 @@ class Repository def circuit_breaker @circuit_breaker ||= Gitlab::Git::Storage::CircuitBreaker.for_storage(project.repository_storage) end + + def find_commits_by_message_by_shelling_out(query, ref, path, limit, offset) + ref ||= root_ref + + args = %W( + log #{ref} --pretty=%H --skip #{offset} + --max-count #{limit} --grep=#{query} --regexp-ignore-case + ) + args = args.concat(%W(-- #{path})) if path.present? + + git_log_results = run_git(args).first.lines + + git_log_results.map { |c| commit(c.chomp) }.compact + end + + def find_commits_by_message_by_gitaly(query, ref, path, limit, offset) + raw_repository + .gitaly_commit_client + .commits_by_message(query, revision: ref, path: path, limit: limit, offset: offset) + .map { |c| commit(c) } + end end |