Class: Gitlab::Git::Conflict::Resolver

Inherits:
Object
  • Object
show all
Includes:
WrapsGitalyErrors
Defined in:
lib/gitlab/git/conflict/resolver.rb

Constant Summary collapse

ConflictSideMissing =
Class.new(StandardError)
ResolutionError =
Class.new(StandardError)

Instance Method Summary collapse

Methods included from WrapsGitalyErrors

#wrapped_gitaly_errors

Constructor Details

#initialize(target_repository, our_commit_oid, their_commit_oid) ⇒ Resolver

Returns a new instance of Resolver.


12
13
14
15
16
# File 'lib/gitlab/git/conflict/resolver.rb', line 12

def initialize(target_repository, our_commit_oid, their_commit_oid)
  @target_repository = target_repository
  @our_commit_oid = our_commit_oid
  @their_commit_oid = their_commit_oid
end

Instance Method Details

#conflict_for_path(conflicts, old_path, new_path) ⇒ Object


34
35
36
37
38
# File 'lib/gitlab/git/conflict/resolver.rb', line 34

def conflict_for_path(conflicts, old_path, new_path)
  conflicts.find do |conflict|
    conflict.their_path == old_path && conflict.our_path == new_path
  end
end

#conflictsObject


18
19
20
21
22
23
24
25
26
# File 'lib/gitlab/git/conflict/resolver.rb', line 18

def conflicts
  @conflicts ||= wrapped_gitaly_errors do
    gitaly_conflicts_client(@target_repository).list_conflict_files.to_a
  end
rescue GRPC::FailedPrecondition => e
  raise Gitlab::Git::Conflict::Resolver::ConflictSideMissing.new(e.message)
rescue GRPC::BadStatus => e
  raise Gitlab::Git::CommandError.new(e)
end

#resolve_conflicts(source_repository, resolution, source_branch:, target_branch:) ⇒ Object


28
29
30
31
32
# File 'lib/gitlab/git/conflict/resolver.rb', line 28

def resolve_conflicts(source_repository, resolution, source_branch:, target_branch:)
  wrapped_gitaly_errors do
    gitaly_conflicts_client(source_repository).resolve_conflicts(@target_repository, resolution, source_branch, target_branch)
  end
end