Merge branch 'dm-dependency-linker-newlines' into 'master'
Fix diff of requirements.txt file by not matching newlines as part of package names Closes #34321 See merge request !12495
This commit is contained in:
commit
9ef6d028a1
3 changed files with 10 additions and 1 deletions
5
changelogs/unreleased/dm-dependency-linker-newlines.yml
Normal file
5
changelogs/unreleased/dm-dependency-linker-newlines.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Fix diff of requirements.txt file by not matching newlines as part of package
|
||||||
|
names
|
||||||
|
merge_request:
|
||||||
|
author:
|
|
@ -52,7 +52,7 @@ module Gitlab
|
||||||
# # Will link `user/repo` in `github: "user/repo"` or `:github => "user/repo"`
|
# # Will link `user/repo` in `github: "user/repo"` or `:github => "user/repo"`
|
||||||
def link_regex(regex, &url_proc)
|
def link_regex(regex, &url_proc)
|
||||||
highlighted_lines.map!.with_index do |rich_line, i|
|
highlighted_lines.map!.with_index do |rich_line, i|
|
||||||
marker = StringRegexMarker.new(plain_lines[i], rich_line.html_safe)
|
marker = StringRegexMarker.new(plain_lines[i].chomp, rich_line.html_safe)
|
||||||
|
|
||||||
marker.mark(regex, group: :name) do |text, left:, right:|
|
marker.mark(regex, group: :name) do |text, left:, right:|
|
||||||
url = yield(text)
|
url = yield(text)
|
||||||
|
|
|
@ -87,5 +87,9 @@ describe Gitlab::DependencyLinker::RequirementsTxtLinker, lib: true do
|
||||||
it 'links URLs' do
|
it 'links URLs' do
|
||||||
expect(subject).to include(link('http://wxpython.org/Phoenix/snapshot-builds/wxPython_Phoenix-3.0.3.dev1820+49a8884-cp34-none-win_amd64.whl', 'http://wxpython.org/Phoenix/snapshot-builds/wxPython_Phoenix-3.0.3.dev1820+49a8884-cp34-none-win_amd64.whl'))
|
expect(subject).to include(link('http://wxpython.org/Phoenix/snapshot-builds/wxPython_Phoenix-3.0.3.dev1820+49a8884-cp34-none-win_amd64.whl', 'http://wxpython.org/Phoenix/snapshot-builds/wxPython_Phoenix-3.0.3.dev1820+49a8884-cp34-none-win_amd64.whl'))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does not contain link with a newline as package name' do
|
||||||
|
expect(subject).not_to include(link("\n", "https://pypi.python.org/pypi/\n"))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue