summaryrefslogtreecommitdiff
path: root/app/helpers/diff_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers/diff_helper.rb')
-rw-r--r--app/helpers/diff_helper.rb30
1 files changed, 27 insertions, 3 deletions
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb
index 7c254e069f6..d6d06434590 100644
--- a/app/helpers/diff_helper.rb
+++ b/app/helpers/diff_helper.rb
@@ -64,15 +64,17 @@ module DiffHelper
else
# `sub` and substring-ing would destroy HTML-safeness of `line`
if line.start_with?('+', '-', ' ')
- line.dup.tap do |line|
- line[0] = ''
- end
+ line[1, line.length]
else
line
end
end
end
+ def diff_link_number(line_type, match, text)
+ line_type == match ? " " : text
+ end
+
def parallel_diff_discussions(left, right, diff_file)
return unless @grouped_diff_discussions
@@ -201,6 +203,14 @@ module DiffHelper
set_secure_cookie(:diff_view, params.delete(:view), type: CookiesHelper::COOKIE_TYPE_PERMANENT) if params[:view].present?
end
+ def unified_diff_lines_view_type(project)
+ if Feature.enabled?(:unified_diff_lines, project, default_enabled: true)
+ 'inline'
+ else
+ diff_view
+ end
+ end
+
private
def diff_btn(title, name, selected)
@@ -250,4 +260,18 @@ module DiffHelper
"...#{path[-(max - 3)..-1]}"
end
+
+ def code_navigation_path(diffs)
+ Gitlab::CodeNavigationPath.new(merge_request.project, diffs.diff_refs&.head_sha)
+ end
+
+ def conflicts
+ return unless options[:merge_ref_head_diff]
+
+ conflicts_service = MergeRequests::Conflicts::ListService.new(merge_request) # rubocop:disable CodeReuse/ServiceClass
+
+ return unless conflicts_service.can_be_resolved_in_ui?
+
+ conflicts_service.conflicts.files.index_by(&:our_path)
+ end
end