Class: Gitlab::Git::Conflict::Resolver
- Inherits:
-
Object
- Object
- Gitlab::Git::Conflict::Resolver
- 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
- #conflict_for_path(conflicts, old_path, new_path) ⇒ Object
- #conflicts ⇒ Object
-
#initialize(target_repository, our_commit_oid, their_commit_oid, allow_tree_conflicts: false) ⇒ Resolver
constructor
A new instance of Resolver.
- #resolve_conflicts(source_repository, resolution, source_branch:, target_branch:) ⇒ Object
Methods included from WrapsGitalyErrors
Constructor Details
#initialize(target_repository, our_commit_oid, their_commit_oid, allow_tree_conflicts: false) ⇒ Resolver
Returns a new instance of Resolver.
12 13 14 15 16 17 |
# File 'lib/gitlab/git/conflict/resolver.rb', line 12 def initialize(target_repository, our_commit_oid, their_commit_oid, allow_tree_conflicts: false) @target_repository = target_repository @our_commit_oid = our_commit_oid @their_commit_oid = their_commit_oid @allow_tree_conflicts = allow_tree_conflicts end |
Instance Method Details
#conflict_for_path(conflicts, old_path, new_path) ⇒ Object
35 36 37 38 39 |
# File 'lib/gitlab/git/conflict/resolver.rb', line 35 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 |
#conflicts ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/gitlab/git/conflict/resolver.rb', line 19 def conflicts @conflicts ||= wrapped_gitaly_errors do gitaly_conflicts_client(@target_repository).list_conflict_files(allow_tree_conflicts: @allow_tree_conflicts).to_a rescue GRPC::FailedPrecondition => e raise Gitlab::Git::Conflict::Resolver::ConflictSideMissing, e. end rescue GRPC::BadStatus => e raise Gitlab::Git::CommandError, e end |
#resolve_conflicts(source_repository, resolution, source_branch:, target_branch:) ⇒ Object
29 30 31 32 33 |
# File 'lib/gitlab/git/conflict/resolver.rb', line 29 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 |