Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmad Sherif <me@ahmadsherif.com>2017-08-03 11:22:01 +0300
committerAhmad Sherif <me@ahmadsherif.com>2017-08-07 19:57:06 +0300
commitc0b41064ff1eb4c5465d3c2a9efa0a22b60c3f4c (patch)
treeab1536b60e649a4ffa116d54da7eeac0d8fdf254 /app/models/repository.rb
parentb12107a0b953b566cd58db30ae880800a4a695a6 (diff)
Migrate Repository#find_commits_by_message to Gitaly
Closes gitaly#443
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r--app/models/repository.rb39
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