GitLab steht wegen Wartungsarbeiten am Montag, den 10. Mai, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

Commit a19d79e8 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'gitaly-795-migrate-repository-fsck' into 'master'

Migrate Git::Repository#fsck to Gitaly

Closes gitaly#795

See merge request gitlab-org/gitlab-ce!15731
parents 22666b78 41b0c0e9
...@@ -1160,9 +1160,15 @@ def commit_index(user, branch_name, index, options) ...@@ -1160,9 +1160,15 @@ def commit_index(user, branch_name, index, options)
end end
def fsck 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 end
def rebase(user, rebase_id, branch:, branch_sha:, remote_repository:, remote_branch:) def rebase(user, rebase_id, branch:, branch_sha:, remote_repository:, remote_branch:)
...@@ -1310,6 +1316,14 @@ def configure_sparse_checkout(worktree_git_path, files) ...@@ -1310,6 +1316,14 @@ def configure_sparse_checkout(worktree_git_path, files)
File.write(File.join(worktree_info_path, 'sparse-checkout'), files) File.write(File.join(worktree_info_path, 'sparse-checkout'), files)
end 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) def rugged_fetch_source_branch(source_repository, source_branch, local_ref)
with_repo_branch_commit(source_repository, source_branch) do |commit| with_repo_branch_commit(source_repository, source_branch) do |commit|
if commit if commit
......
...@@ -87,6 +87,17 @@ def fetch_source_branch(source_repository, source_branch, local_ref) ...@@ -87,6 +87,17 @@ def fetch_source_branch(source_repository, source_branch, local_ref)
response.result response.result
end 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 end
end end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment