Add blob_icon to conflict file JSON
This commit is contained in:
parent
e50e88b85c
commit
52eb523c9b
2 changed files with 8 additions and 2 deletions
|
@ -2,18 +2,20 @@ module Gitlab
|
||||||
module Conflict
|
module Conflict
|
||||||
class File
|
class File
|
||||||
include Gitlab::Routing.url_helpers
|
include Gitlab::Routing.url_helpers
|
||||||
|
include IconsHelper
|
||||||
|
|
||||||
class MissingResolution < StandardError
|
class MissingResolution < StandardError
|
||||||
end
|
end
|
||||||
|
|
||||||
CONTEXT_LINES = 3
|
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:)
|
def initialize(merge_file_result, conflict, merge_request:)
|
||||||
@merge_file_result = merge_file_result
|
@merge_file_result = merge_file_result
|
||||||
@their_path = conflict[:theirs][:path]
|
@their_path = conflict[:theirs][:path]
|
||||||
@our_path = conflict[:ours][:path]
|
@our_path = conflict[:ours][:path]
|
||||||
|
@our_mode = conflict[:ours][:mode]
|
||||||
@merge_request = merge_request
|
@merge_request = merge_request
|
||||||
@repository = merge_request.project.repository
|
@repository = merge_request.project.repository
|
||||||
end
|
end
|
||||||
|
@ -30,7 +32,6 @@ module Gitlab
|
||||||
new_file = resolve_lines(resolution).map(&:text).join("\n")
|
new_file = resolve_lines(resolution).map(&:text).join("\n")
|
||||||
|
|
||||||
oid = rugged.write(new_file, :blob)
|
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.add(path: our_path, oid: oid, mode: our_mode)
|
||||||
index.conflict_remove(our_path)
|
index.conflict_remove(our_path)
|
||||||
end
|
end
|
||||||
|
@ -150,6 +151,7 @@ module Gitlab
|
||||||
{
|
{
|
||||||
old_path: their_path,
|
old_path: their_path,
|
||||||
new_path: our_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,
|
blob_path: namespace_project_blob_path(merge_request.project.namespace,
|
||||||
merge_request.project,
|
merge_request.project,
|
||||||
::File.join(merge_request.diff_refs.head_sha, our_path)),
|
::File.join(merge_request.diff_refs.head_sha, our_path)),
|
||||||
|
|
|
@ -148,5 +148,9 @@ describe Gitlab::Conflict::File, lib: true do
|
||||||
expect(conflict_file.as_json[:blob_path]).
|
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")
|
to eq("/#{project.namespace.to_param}/#{merge_request.project.to_param}/blob/#{our_commit.oid}/files/ruby/regex.rb")
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue