diff options
author | Robert Speicher <robert@gitlab.com> | 2017-06-28 15:24:01 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-06-28 15:24:01 +0000 |
commit | 9ef6d028a12521c1c458680bccde24ccfdddcb65 (patch) | |
tree | 1d3c657d44e41bd424c509fce5c8ec76ac451752 | |
parent | ccc5bbcdc1155e8cad5c783ec2c5b7cc00629a63 (diff) | |
parent | 34f7c3bd1a189ff79205f75d8f8b45b1e6a43c15 (diff) | |
download | gitlab-ce-9ef6d028a12521c1c458680bccde24ccfdddcb65.tar.gz |
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
-rw-r--r-- | changelogs/unreleased/dm-dependency-linker-newlines.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/dependency_linker/base_linker.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb | 4 |
3 files changed, 10 insertions, 1 deletions
diff --git a/changelogs/unreleased/dm-dependency-linker-newlines.yml b/changelogs/unreleased/dm-dependency-linker-newlines.yml new file mode 100644 index 00000000000..5631095fcb7 --- /dev/null +++ b/changelogs/unreleased/dm-dependency-linker-newlines.yml @@ -0,0 +1,5 @@ +--- +title: Fix diff of requirements.txt file by not matching newlines as part of package + names +merge_request: +author: diff --git a/lib/gitlab/dependency_linker/base_linker.rb b/lib/gitlab/dependency_linker/base_linker.rb index 7bbd154eb03..d2360583741 100644 --- a/lib/gitlab/dependency_linker/base_linker.rb +++ b/lib/gitlab/dependency_linker/base_linker.rb @@ -52,7 +52,7 @@ module Gitlab # # Will link `user/repo` in `github: "user/repo"` or `:github => "user/repo"` def link_regex(regex, &url_proc) 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:| url = yield(text) diff --git a/spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb b/spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb index 7e32770f95d..64b233f3e68 100644 --- a/spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb +++ b/spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb @@ -87,5 +87,9 @@ describe Gitlab::DependencyLinker::RequirementsTxtLinker, lib: true 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')) 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 |