Skip to content
Snippets Groups Projects
Commit 3fe18525 authored by Stan Hu's avatar Stan Hu Committed by Rémy Coutable
Browse files

Trim extra displayed carriage returns in diffs and files with CRLFs

Closes #20440
parent e91fe755
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -44,6 +44,7 @@ v 8.10.3 (unreleased)
- Properly abort a merge when merge conflicts occur
- Ignore invalid IPs in X-Forwarded-For when trusted proxies are configured.
- Fix Import/Export issue importing milestones and labels not associated properly
- Trim extra displayed carriage returns in diffs and files with CRLFs
 
v 8.10.2
- User can now search branches by name. !5144
Loading
Loading
Loading
Loading
@@ -18,7 +18,7 @@ module Rouge
is_first = false
 
yield %(<span id="LC#{@line_number}" class="line">)
line.each { |token, value| yield span(token, value) }
line.each { |token, value| yield span(token, value.chomp) }
yield %(</span>)
 
@line_number += 1
Loading
Loading
Loading
Loading
@@ -17,6 +17,18 @@ describe Gitlab::Highlight, lib: true do
expect(lines[21]).to eq(%Q{<span id="LC22" class="line"> <span class="k">unless</span> <span class="no">File</span><span class="p">.</span><span class="nf">directory?</span><span class="p">(</span><span class="n">path</span><span class="p">)</span></span>\n})
expect(lines[26]).to eq(%Q{<span id="LC27" class="line"> <span class="vi">@cmd_status</span> <span class="o">=</span> <span class="mi">0</span></span>\n})
end
describe 'with CRLF' do
let(:branch) { 'crlf-diff' }
let(:blob) { repository.blob_at_branch(branch, path) }
let(:lines) do
Gitlab::Highlight.highlight_lines(project.repository, 'crlf-diff-test', 'files/whitespace')
end
it 'strips extra LFs' do
expect(lines[0]).to eq("<span id=\"LC1\" class=\"line\">test </span>")
end
end
end
 
describe 'custom highlighting from .gitattributes' do
Loading
Loading
Loading
Loading
@@ -21,7 +21,8 @@ module TestEnv
'expand-collapse-diffs' => '4842455',
'expand-collapse-files' => '025db92',
'expand-collapse-lines' => '238e82d',
'video' => '8879059'
'video' => '8879059',
'crlf-diff' => '5938907'
}
 
# gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment