summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim Carlbäcker <kim.carlbacker@gmail.com>2017-12-08 00:27:11 +0000
committerRobert Speicher <robert@gitlab.com>2017-12-08 00:27:11 +0000
commit41b0c0e9be7a34d1255326904a234ae142d6c205 (patch)
treee5c13411d2825969d7b6c534b7204bbaa6283ca3
parent22666b78080a02951d4c6a732ca4b0b6e1beb4b7 (diff)
downloadgitlab-ce-41b0c0e9be7a34d1255326904a234ae142d6c205.tar.gz
Migrate Git::Repository#fsck to Gitaly
-rw-r--r--lib/gitlab/git/repository.rb18
-rw-r--r--lib/gitlab/gitaly_client/repository_service.rb11
2 files changed, 27 insertions, 2 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index 91dd2fbbdbc..73889328f36 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -1160,9 +1160,15 @@ module Gitlab
end
def fsck
- output, status = run_git(%W[--git-dir=#{path} fsck], nice: true)
+ gitaly_migrate(:git_fsck) do |is_enabled|
+ msg, status = if is_enabled
+ gitaly_fsck
+ else
+ shell_fsck
+ end
- raise GitError.new("Could not fsck repository:\n#{output}") unless status.zero?
+ raise GitError.new("Could not fsck repository: #{msg}") unless status.zero?
+ end
end
def rebase(user, rebase_id, branch:, branch_sha:, remote_repository:, remote_branch:)
@@ -1310,6 +1316,14 @@ module Gitlab
File.write(File.join(worktree_info_path, 'sparse-checkout'), files)
end
+ def gitaly_fsck
+ gitaly_repository_client.fsck
+ end
+
+ def shell_fsck
+ run_git(%W[--git-dir=#{path} fsck], nice: true)
+ end
+
def rugged_fetch_source_branch(source_repository, source_branch, local_ref)
with_repo_branch_commit(source_repository, source_branch) do |commit|
if commit
diff --git a/lib/gitlab/gitaly_client/repository_service.rb b/lib/gitlab/gitaly_client/repository_service.rb
index b9e606592d7..a477d618f63 100644
--- a/lib/gitlab/gitaly_client/repository_service.rb
+++ b/lib/gitlab/gitaly_client/repository_service.rb
@@ -87,6 +87,17 @@ module Gitlab
response.result
end
+
+ def fsck
+ request = Gitaly::FsckRequest.new(repository: @gitaly_repo)
+ response = GitalyClient.call(@storage, :repository_service, :fsck, request)
+
+ if response.error.empty?
+ return "", 0
+ else
+ return response.error.b, 1
+ end
+ end
end
end
end