ebf98f27c4
Enables frozen string for the following: * lib/gitlab/fogbugz_import/**/*.rb * lib/gitlab/gfm/**/*.rb * lib/gitlab/git/**/*.rb * lib/gitlab/gitaly_client/**/*.rb * lib/gitlab/gitlab_import/**/*.rb * lib/gitlab/google_code_import/**/*.rb * lib/gitlab/gpg/**/*.rb * lib/gitlab/grape_logging/**/*.rb * lib/gitlab/graphql/**/*.rb * lib/gitlab/graphs/**/*.rb * lib/gitlab/hashed_storage/**/*.rb * lib/gitlab/health_checks/**/*.rb Partially address gitlab-org/gitlab-ce#47424.
49 lines
1.2 KiB
Ruby
49 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Gitlab
|
|
module GitalyClient
|
|
class ConflictFilesStitcher
|
|
include Enumerable
|
|
|
|
def initialize(rpc_response)
|
|
@rpc_response = rpc_response
|
|
end
|
|
|
|
def each
|
|
current_file = nil
|
|
|
|
@rpc_response.each do |msg|
|
|
msg.files.each do |gitaly_file|
|
|
if gitaly_file.header
|
|
yield current_file if current_file
|
|
|
|
current_file = file_from_gitaly_header(gitaly_file.header)
|
|
else
|
|
current_file.raw_content = "#{current_file.raw_content}#{gitaly_file.content}"
|
|
end
|
|
end
|
|
end
|
|
|
|
yield current_file if current_file
|
|
end
|
|
|
|
private
|
|
|
|
def file_from_gitaly_header(header)
|
|
Gitlab::Git::Conflict::File.new(
|
|
Gitlab::GitalyClient::Util.git_repository(header.repository),
|
|
header.commit_oid,
|
|
conflict_from_gitaly_file_header(header),
|
|
''
|
|
)
|
|
end
|
|
|
|
def conflict_from_gitaly_file_header(header)
|
|
{
|
|
ours: { path: header.our_path, mode: header.our_mode },
|
|
theirs: { path: header.their_path }
|
|
}
|
|
end
|
|
end
|
|
end
|
|
end
|