summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAhmad Sherif <me@ahmadsherif.com>2017-07-31 19:38:36 +0200
committerAhmad Sherif <me@ahmadsherif.com>2017-08-03 19:26:46 +0200
commitf81c07eacc6c37092b13559dcaf479805138eb45 (patch)
tree15d38d9925f7dd3c659c944b8d33ab9b05f8b84d /lib
parent8f9b658e3a30e28189f5ef626d32661e08cf23aa (diff)
downloadgitlab-ce-f81c07eacc6c37092b13559dcaf479805138eb45.tar.gz
Migrate Repository#last_commit_for_path to Gitaly
Closes gitaly#433
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/git/repository.rb21
-rw-r--r--lib/gitlab/gitaly_client/commit_service.rb14
2 files changed, 27 insertions, 8 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index ffe2c8b91bb..734aed8fbc1 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -683,6 +683,14 @@ module Gitlab
@gitaly_repository_client ||= Gitlab::GitalyClient::RepositoryService.new(self)
end
+ def gitaly_migrate(method, &block)
+ Gitlab::GitalyClient.migrate(method, &block)
+ rescue GRPC::NotFound => e
+ raise NoRepository.new(e)
+ rescue GRPC::BadStatus => e
+ raise CommandError.new(e)
+ end
+
private
# Gitaly note: JV: Trying to get rid of the 'filter' option so we can implement this with 'git'.
@@ -998,6 +1006,11 @@ module Gitlab
end.sort_by(&:name)
end
+ def last_commit_for_path_by_rugged(sha, path)
+ sha = last_commit_id_for_path(sha, path)
+ commit(sha)
+ end
+
def tags_from_gitaly
gitaly_ref_client.tags
end
@@ -1017,14 +1030,6 @@ module Gitlab
raw_output.to_i
end
-
- def gitaly_migrate(method, &block)
- Gitlab::GitalyClient.migrate(method, &block)
- rescue GRPC::NotFound => e
- raise NoRepository.new(e)
- rescue GRPC::BadStatus => e
- raise CommandError.new(e)
- end
end
end
end
diff --git a/lib/gitlab/gitaly_client/commit_service.rb b/lib/gitlab/gitaly_client/commit_service.rb
index b1424a458e9..3f6c2c09418 100644
--- a/lib/gitlab/gitaly_client/commit_service.rb
+++ b/lib/gitlab/gitaly_client/commit_service.rb
@@ -97,6 +97,20 @@ module Gitlab
GitalyClient.call(@repository.storage, :commit_service, :count_commits, request).count
end
+ def last_commit_for_path(revision, path)
+ request = Gitaly::LastCommitForPathRequest.new(
+ repository: @gitaly_repo,
+ revision: revision.force_encoding(Encoding::ASCII_8BIT),
+ path: path.to_s.force_encoding(Encoding::ASCII_8BIT)
+ )
+
+ gitaly_commit = GitalyClient.call(@repository.storage, :commit_service, :last_commit_for_path, request).commit
+ return unless gitaly_commit
+
+ commit = GitalyClient::Commit.new(@repository, gitaly_commit)
+ Gitlab::Git::Commit.new(commit)
+ end
+
def between(from, to)
request = Gitaly::CommitsBetweenRequest.new(
repository: @gitaly_repo,