Class: Gitlab::GitalyClient::DiffBlobsStitcher

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/gitlab/gitaly_client/diff_blobs_stitcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(rpc_response) ⇒ DiffBlobsStitcher

Returns a new instance of DiffBlobsStitcher.



8
9
10
# File 'lib/gitlab/gitaly_client/diff_blobs_stitcher.rb', line 8

def initialize(rpc_response)
  @rpc_response = rpc_response
end

Instance Method Details

#eachObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gitlab/gitaly_client/diff_blobs_stitcher.rb', line 12

def each
  current_diff_blob = nil

  @rpc_response.each do |diff_blob_msg|
    if current_diff_blob.nil?
      diff_blobs_params = diff_blob_hash(diff_blob_msg)
      current_diff_blob = Gitlab::GitalyClient::DiffBlob.new(diff_blobs_params)
    else
      current_diff_blob.patch = "#{current_diff_blob.patch}#{diff_blob_msg.patch}"
      current_diff_blob.status = diff_blob_msg.status
    end

    if current_diff_blob.status == :STATUS_END_OF_PATCH
      yield current_diff_blob
      current_diff_blob = nil
    end
  end
end