diff --git a/lib/gitlab/conflict/file.rb b/lib/gitlab/conflict/file.rb index 16727e752bd4084b7cbaf4e650c2c52fe30b2fa1..1d63aec6903d5992c4967c0c68aa41d4dbae5e3b 100644 --- a/lib/gitlab/conflict/file.rb +++ b/lib/gitlab/conflict/file.rb @@ -2,18 +2,20 @@ module Gitlab module Conflict class File include Gitlab::Routing.url_helpers + include IconsHelper class MissingResolution < StandardError end CONTEXT_LINES = 3 - attr_reader :merge_file_result, :their_path, :our_path, :merge_request, :repository + attr_reader :merge_file_result, :their_path, :our_path, :our_mode, :merge_request, :repository def initialize(merge_file_result, conflict, merge_request:) @merge_file_result = merge_file_result @their_path = conflict[:theirs][:path] @our_path = conflict[:ours][:path] + @our_mode = conflict[:ours][:mode] @merge_request = merge_request @repository = merge_request.project.repository end @@ -30,7 +32,6 @@ module Gitlab new_file = resolve_lines(resolution).map(&:text).join("\n") oid = rugged.write(new_file, :blob) - our_mode = index.conflict_get(our_path)[:ours][:mode] index.add(path: our_path, oid: oid, mode: our_mode) index.conflict_remove(our_path) end @@ -150,6 +151,7 @@ module Gitlab { old_path: their_path, new_path: our_path, + blob_icon: file_type_icon_class('file', our_mode, our_path), blob_path: namespace_project_blob_path(merge_request.project.namespace, merge_request.project, ::File.join(merge_request.diff_refs.head_sha, our_path)), diff --git a/spec/lib/gitlab/conflict/file_spec.rb b/spec/lib/gitlab/conflict/file_spec.rb index a57ca70672b0a58277924d71a08a318cb3a299de..cf670b3182a5241e5d91a886e6e8fabead355a33 100644 --- a/spec/lib/gitlab/conflict/file_spec.rb +++ b/spec/lib/gitlab/conflict/file_spec.rb @@ -148,5 +148,9 @@ describe Gitlab::Conflict::File, lib: true do expect(conflict_file.as_json[:blob_path]). to eq("/#{project.namespace.to_param}/#{merge_request.project.to_param}/blob/#{our_commit.oid}/files/ruby/regex.rb") end + + it 'includes the blob icon for the file' do + expect(conflict_file.as_json[:blob_icon]).to eq('file-text-o') + end end end