Class: Gitlab::GitalyClient::ConflictFilesStitcher

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rpc_response, gitaly_repo) ⇒ ConflictFilesStitcher

Returns a new instance of ConflictFilesStitcher.


10
11
12
13
# File 'lib/gitlab/gitaly_client/conflict_files_stitcher.rb', line 10

def initialize(rpc_response, gitaly_repo)
  @rpc_response = rpc_response
  @gitaly_repo = gitaly_repo
end

Instance Attribute Details

#gitaly_repoObject (readonly)

Returns the value of attribute gitaly_repo


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

def gitaly_repo
  @gitaly_repo
end

Instance Method Details

#each {|current_file| ... } ⇒ Object

Yields:

  • (current_file)

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/gitlab/gitaly_client/conflict_files_stitcher.rb', line 15

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