Skip to content
Snippets Groups Projects
Commit f69c22a8 authored by Vasilii Iakliushin's avatar Vasilii Iakliushin
Browse files

Remove feature flag `diff_line_syntax_highlighting`

Contributes to https://gitlab.com/gitlab-org/gitlab/-/issues/324159
parent e5dfb288
No related merge requests found
---
title: Remove feature flag "diff_line_syntax_highlighting"
merge_request:
author:
type: other
---
name: diff_line_syntax_highlighting
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56108
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/324159
milestone: '13.10'
type: development
group: group::source code
default_enabled: false
......@@ -86,14 +86,6 @@ def apply_marker_ranges_highlight(diff_line, rich_line, index)
def highlight_line(diff_line)
return unless diff_file && diff_file.diff_refs
if Feature.enabled?(:diff_line_syntax_highlighting, project, default_enabled: :yaml)
diff_line_highlighting(diff_line)
else
blob_highlighting(diff_line)
end
end
def diff_line_highlighting(diff_line)
rich_line = syntax_highlighter(diff_line).highlight(
diff_line.text(prefix: false),
context: { line_number: diff_line.line }
......@@ -118,44 +110,11 @@ def syntax_highlighter(diff_line)
)
end
# Deprecated: https://gitlab.com/gitlab-org/gitlab/-/issues/324159
# ------------------------------------------------------------------------
def blob_highlighting(diff_line)
rich_line =
if diff_line.unchanged? || diff_line.added?
new_lines[diff_line.new_pos - 1]&.html_safe
elsif diff_line.removed?
old_lines[diff_line.old_pos - 1]&.html_safe
end
# Only update text if line is found. This will prevent
# issues with submodules given the line only exists in diff content.
if rich_line
line_prefix = diff_line.text =~ /\A(.)/ ? Regexp.last_match(1) : ' '
"#{line_prefix}#{rich_line}".html_safe
end
end
# Deprecated: https://gitlab.com/gitlab-org/gitlab/-/issues/324638
# ------------------------------------------------------------------------
def inline_diffs
@inline_diffs ||= InlineDiff.for_lines(@raw_lines)
end
def old_lines
@old_lines ||= highlighted_blob_lines(diff_file.old_blob)
end
def new_lines
@new_lines ||= highlighted_blob_lines(diff_file.new_blob)
end
def highlighted_blob_lines(blob)
return [] unless blob
blob.load_all_data!
blob.present.highlight.lines
end
end
end
end
......@@ -73,10 +73,7 @@ def key
'highlighted-diff-files',
diffable.cache_key,
VERSION,
diff_options,
Feature.enabled?(:introduce_marker_ranges, diffable.project, default_enabled: :yaml),
Feature.enabled?(:use_marker_ranges, diffable.project, default_enabled: :yaml),
Feature.enabled?(:diff_line_syntax_highlighting, diffable.project, default_enabled: :yaml)
diff_options
].join(":")
end
end
......
......@@ -238,37 +238,7 @@
subject { cache.key }
it 'returns cache key' do
is_expected.to eq("highlighted-diff-files:#{cache.diffable.cache_key}:2:#{cache.diff_options}:true:true:true")
end
context 'when the `introduce_marker_ranges` feature flag is disabled' do
before do
stub_feature_flags(introduce_marker_ranges: false)
end
it 'returns the original version of the cache' do
is_expected.to eq("highlighted-diff-files:#{cache.diffable.cache_key}:2:#{cache.diff_options}:false:true:true")
end
end
context 'when the `use_marker_ranges` feature flag is disabled' do
before do
stub_feature_flags(use_marker_ranges: false)
end
it 'returns the original version of the cache' do
is_expected.to eq("highlighted-diff-files:#{cache.diffable.cache_key}:2:#{cache.diff_options}:true:false:true")
end
end
context 'when the `diff_line_syntax_highlighting` feature flag is disabled' do
before do
stub_feature_flags(diff_line_syntax_highlighting: false)
end
it 'returns the original version of the cache' do
is_expected.to eq("highlighted-diff-files:#{cache.diffable.cache_key}:2:#{cache.diff_options}:true:true:false")
end
is_expected.to eq("highlighted-diff-files:#{cache.diffable.cache_key}:2:#{cache.diff_options}")
end
end
end
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment