From 11e22835ed7a003c7b31856d1dbad9b8fa22d37f Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Fri, 23 Jun 2017 13:07:29 -0500 Subject: [PATCH] Don't match tilde and exclamation mark as part of requirements.txt package name --- changelogs/unreleased/dm-requirements-txt-tilde.yml | 5 +++++ lib/gitlab/dependency_linker/requirements_txt_linker.rb | 2 +- .../gitlab/dependency_linker/requirements_txt_linker_spec.rb | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/dm-requirements-txt-tilde.yml diff --git a/changelogs/unreleased/dm-requirements-txt-tilde.yml b/changelogs/unreleased/dm-requirements-txt-tilde.yml new file mode 100644 index 00000000000..ddb5325ddd5 --- /dev/null +++ b/changelogs/unreleased/dm-requirements-txt-tilde.yml @@ -0,0 +1,5 @@ +--- +title: Don't match tilde and exclamation mark as part of requirements.txt package + name +merge_request: +author: diff --git a/lib/gitlab/dependency_linker/requirements_txt_linker.rb b/lib/gitlab/dependency_linker/requirements_txt_linker.rb index 2e197e5cd94..9c9620bc36a 100644 --- a/lib/gitlab/dependency_linker/requirements_txt_linker.rb +++ b/lib/gitlab/dependency_linker/requirements_txt_linker.rb @@ -6,7 +6,7 @@ module Gitlab private def link_dependencies - link_regex(/^(?(?![a-z+]+:)[^#.-][^ ><=;\[]+)/) do |name| + link_regex(/^(?(?![a-z+]+:)[^#.-][^ ><=~!;\[]+)/) do |name| "https://pypi.python.org/pypi/#{name}" end 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 4da8821726c..7e32770f95d 100644 --- a/spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb +++ b/spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb @@ -54,6 +54,8 @@ describe Gitlab::DependencyLinker::RequirementsTxtLinker, lib: true do Sphinx>=1.3 docutils>=0.7 markupsafe + pytest~=3.0 + foop!=3.0 CONTENT end @@ -78,6 +80,8 @@ describe Gitlab::DependencyLinker::RequirementsTxtLinker, lib: true do expect(subject).to include(link('Sphinx', 'https://pypi.python.org/pypi/Sphinx')) expect(subject).to include(link('docutils', 'https://pypi.python.org/pypi/docutils')) expect(subject).to include(link('markupsafe', 'https://pypi.python.org/pypi/markupsafe')) + expect(subject).to include(link('pytest', 'https://pypi.python.org/pypi/pytest')) + expect(subject).to include(link('foop', 'https://pypi.python.org/pypi/foop')) end it 'links URLs' do