summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2017-06-23 17:52:51 -0400
committerAlejandro Rodríguez <alejorro70@gmail.com>2017-07-18 16:20:27 -0400
commit25b01b4c8594e8260dd1c86523bb9989aefd1fda (patch)
treef9207e8b90233d1014573860594dcb6a62c10a5f /lib
parent90f8feae46ca49299dbe138a229a51c5294f88be (diff)
downloadgitlab-ce-25b01b4c8594e8260dd1c86523bb9989aefd1fda.tar.gz
Incorporate Gitaly's Commits#between RPC
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/git/commit.rb14
-rw-r--r--lib/gitlab/git/repository.rb16
-rw-r--r--lib/gitlab/gitaly_client/commit_service.rb15
3 files changed, 33 insertions, 12 deletions
diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb
index 1b9f3c57957..76a562f356e 100644
--- a/lib/gitlab/git/commit.rb
+++ b/lib/gitlab/git/commit.rb
@@ -98,7 +98,15 @@ module Gitlab
# Commit.between(repo, '29eda46b', 'master')
#
def between(repo, base, head)
- repo.commits_between(base, head).map do |commit|
+ commits = Gitlab::GitalyClient.migrate(:commits_between) do |is_enabled|
+ if is_enabled
+ repo.gitaly_commit_client.between(base, head)
+ else
+ repo.commits_between(base, head)
+ end
+ end
+
+ commits.map do |commit|
decorate(commit)
end
rescue Rugged::ReferenceError
@@ -376,12 +384,10 @@ module Gitlab
def init_from_gitaly(commit)
@raw_commit = commit
@id = commit.id
- # NOTE: For ease of parsing in Gitaly, we have only the subject of
- # the commit and not the full message.
# TODO: Once gitaly "takes over" Rugged consider separating the
# subject from the message to make it clearer when there's one
# available but not the other.
- @message = commit.subject.dup
+ @message = (commit.body.presence || commit.subject).dup
@authored_date = Time.at(commit.author.date.seconds)
@author_name = commit.author.name.dup
@author_email = commit.author.email.dup
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index c091bb9dcfe..63eebadff2e 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -807,6 +807,14 @@ module Gitlab
Gitlab::GitalyClient::Util.repository(@storage, @relative_path)
end
+ def gitaly_ref_client
+ @gitaly_ref_client ||= Gitlab::GitalyClient::RefService.new(self)
+ end
+
+ def gitaly_commit_client
+ @gitaly_commit_client ||= Gitlab::GitalyClient::CommitService.new(self)
+ end
+
private
# Gitaly note: JV: Trying to get rid of the 'filter' option so we can implement this with 'git'.
@@ -1105,14 +1113,6 @@ module Gitlab
end
end
- def gitaly_ref_client
- @gitaly_ref_client ||= Gitlab::GitalyClient::RefService.new(self)
- end
-
- def gitaly_commit_client
- @gitaly_commit_client ||= Gitlab::GitalyClient::CommitService.new(self)
- end
-
def gitaly_migrate(method, &block)
Gitlab::GitalyClient.migrate(method, &block)
rescue GRPC::NotFound => e
diff --git a/lib/gitlab/gitaly_client/commit_service.rb b/lib/gitlab/gitaly_client/commit_service.rb
index 470e3ac8779..8f5738fed06 100644
--- a/lib/gitlab/gitaly_client/commit_service.rb
+++ b/lib/gitlab/gitaly_client/commit_service.rb
@@ -65,6 +65,17 @@ module Gitlab
GitalyClient.call(@repository.storage, :commit_service, :count_commits, request).count
end
+ def between(from, to)
+ request = Gitaly::CommitsBetweenRequest.new(
+ repository: @gitaly_repo,
+ from: from,
+ to: to
+ )
+
+ response = GitalyClient.call(@repository.storage, :commit_service, :commits_between, request)
+ consume_commits_response(response)
+ end
+
private
def commit_diff_request_params(commit, options = {})
@@ -77,6 +88,10 @@ module Gitlab
paths: options.fetch(:paths, [])
}
end
+
+ def consume_commits_response(response)
+ response.flat_map { |r| r.commits }
+ end
end
end
end