diff options
author | Alejandro RodrÃguez <alejorro70@gmail.com> | 2017-12-27 16:49:05 -0300 |
---|---|---|
committer | Alejandro RodrÃguez <alejorro70@gmail.com> | 2018-01-02 16:22:02 -0300 |
commit | 65e3a1e9e9a316a2bbbcd49e22b858b8b1bd9890 (patch) | |
tree | 37aed42681aad3d05aa646c05140a712bd4d5beb /lib/gitlab/git/conflict | |
parent | 0aa87bbe13ca74a791bf5c70a12d8e7f6876fd5a (diff) | |
download | gitlab-ce-65e3a1e9e9a316a2bbbcd49e22b858b8b1bd9890.tar.gz |
Simplify conflict resolution interface and codegitaly-conflict-resolver
- Add a Gitlab::Git::Conflict::Resolution class to encapsulate
resolution data
- Simplify conflict file collection assembly
Diffstat (limited to 'lib/gitlab/git/conflict')
-rw-r--r-- | lib/gitlab/git/conflict/file.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/git/conflict/resolution.rb | 15 | ||||
-rw-r--r-- | lib/gitlab/git/conflict/resolver.rb | 14 |
3 files changed, 25 insertions, 8 deletions
diff --git a/lib/gitlab/git/conflict/file.rb b/lib/gitlab/git/conflict/file.rb index b2a625e08fa..2a9cf10a068 100644 --- a/lib/gitlab/git/conflict/file.rb +++ b/lib/gitlab/git/conflict/file.rb @@ -2,7 +2,9 @@ module Gitlab module Git module Conflict class File - attr_reader :content, :their_path, :our_path, :our_mode, :repository, :commit_oid + attr_reader :their_path, :our_path, :our_mode, :repository, :commit_oid + + attr_accessor :content def initialize(repository, commit_oid, conflict, content) @repository = repository diff --git a/lib/gitlab/git/conflict/resolution.rb b/lib/gitlab/git/conflict/resolution.rb new file mode 100644 index 00000000000..ab9be683e15 --- /dev/null +++ b/lib/gitlab/git/conflict/resolution.rb @@ -0,0 +1,15 @@ +module Gitlab + module Git + module Conflict + class Resolution + attr_reader :user, :files, :commit_message + + def initialize(user, files, commit_message) + @user = user + @files = files + @commit_message = commit_message + end + end + end + end +end diff --git a/lib/gitlab/git/conflict/resolver.rb b/lib/gitlab/git/conflict/resolver.rb index 48e672ad3fb..74c9874d590 100644 --- a/lib/gitlab/git/conflict/resolver.rb +++ b/lib/gitlab/git/conflict/resolver.rb @@ -27,12 +27,12 @@ module Gitlab raise Gitlab::Git::CommandError.new(e) end - def resolve_conflicts(source_repository, user, files, source_branch:, target_branch:, commit_message:) + def resolve_conflicts(source_repository, resolution, source_branch:, target_branch:) source_repository.gitaly_migrate(:conflicts_resolve_conflicts) do |is_enabled| if is_enabled - gitaly_conflicts_client(source_repository).resolve_conflicts(@target_repository, user, files, source_branch, target_branch, commit_message) + gitaly_conflicts_client(source_repository).resolve_conflicts(@target_repository, resolution, source_branch, target_branch) else - rugged_resolve_conflicts(source_repository, user, files, source_branch, target_branch, commit_message) + rugged_resolve_conflicts(source_repository, resolution, source_branch, target_branch) end end end @@ -87,12 +87,12 @@ module Gitlab conflict_files(@target_repository, target_index) end - def rugged_resolve_conflicts(source_repository, user, files, source_branch, target_branch, commit_message) + def rugged_resolve_conflicts(source_repository, resolution, source_branch, target_branch) source_repository.with_repo_branch_commit(@target_repository, target_branch) do index = source_repository.rugged.merge_commits(@our_commit_oid, @their_commit_oid) conflicts = conflict_files(source_repository, index) - files.each do |file_params| + resolution.files.each do |file_params| conflict_file = conflict_for_path(conflicts, file_params[:old_path], file_params[:new_path]) write_resolved_file_to_index(source_repository, index, conflict_file, file_params) @@ -105,11 +105,11 @@ module Gitlab end commit_params = { - message: commit_message, + message: resolution.commit_message, parents: [@our_commit_oid, @their_commit_oid] } - source_repository.commit_index(user, source_branch, index, commit_params) + source_repository.commit_index(resolution.user, source_branch, index, commit_params) end end end |