From bd36d3a3536f79c72d84060a0051f0f259e73cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20Carlb=C3=A4cker?= Date: Fri, 8 Dec 2017 00:27:11 +0000 Subject: [PATCH 1/2] Migrate Git::Repository#fsck to Gitaly --- lib/gitlab/git/repository.rb | 18 ++++++++++++++++-- lib/gitlab/gitaly_client/repository_service.rb | 11 +++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 129c077729aa44..5625b695796dee 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -1177,9 +1177,15 @@ def commit_index(user, branch_name, index, options) 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:) @@ -1327,6 +1333,14 @@ def configure_sparse_checkout(worktree_git_path, files) 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 b9e606592d7e62..a477d618f63aad 100644 --- a/lib/gitlab/gitaly_client/repository_service.rb +++ b/lib/gitlab/gitaly_client/repository_service.rb @@ -87,6 +87,17 @@ def fetch_source_branch(source_repository, source_branch, local_ref) 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 -- GitLab From ef536ab6889c6ac159f481aa3d8c987329e31cbd Mon Sep 17 00:00:00 2001 From: Ahmad Sherif Date: Tue, 12 Dec 2017 12:25:55 +0100 Subject: [PATCH 2/2] Bump GITALY_SERVER_VERSION to 0.59.0 --- GITALY_SERVER_VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index 46448c71b9dffc..cb6b534abe1bbe 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -0.57.0 +0.59.0 -- GitLab