summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-08-23 10:39:01 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-08-23 10:39:01 +0000
commitd546f7d36e6703bda430e2f50fe4e87a07ab48f8 (patch)
tree2f146ced371825eb0ac5e6450bd9c37e4fff9896 /lib
parent1f456ff3649e0a26785aaddf979bb8ce0d56f17a (diff)
parent258d5a50e63d5e29b6a3adc0a250727a8232695b (diff)
downloadgitlab-ce-d546f7d36e6703bda430e2f50fe4e87a07ab48f8.tar.gz
Merge branch 'gitaly-commit-patch' into 'master'
Incorporate DiffService.CommitPatch Gitaly RPC Closes gitaly#463 See merge request !13441
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/git/commit.rb8
-rw-r--r--lib/gitlab/gitaly_client/commit_service.rb10
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb
index a499bbc6266..5ee6669050c 100644
--- a/lib/gitlab/git/commit.rb
+++ b/lib/gitlab/git/commit.rb
@@ -271,7 +271,13 @@ module Gitlab
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/324
def to_diff
- rugged_diff_from_parent.patch
+ Gitlab::GitalyClient.migrate(:commit_patch) do |is_enabled|
+ if is_enabled
+ @repository.gitaly_commit_client.patch(id)
+ else
+ rugged_diff_from_parent.patch
+ end
+ end
end
# Returns a diff object for the changes from this commit's first parent.
diff --git a/lib/gitlab/gitaly_client/commit_service.rb b/lib/gitlab/gitaly_client/commit_service.rb
index 2d58fb0186e..8fb7341b2dc 100644
--- a/lib/gitlab/gitaly_client/commit_service.rb
+++ b/lib/gitlab/gitaly_client/commit_service.rb
@@ -194,6 +194,16 @@ module Gitlab
response.commit
end
+ def patch(revision)
+ request = Gitaly::CommitPatchRequest.new(
+ repository: @gitaly_repo,
+ revision: GitalyClient.encode(revision)
+ )
+ response = GitalyClient.call(@repository.storage, :diff_service, :commit_patch, request)
+
+ response.sum(&:data)
+ end
+
private
def commit_diff_request_params(commit, options = {})