Skip to content

Commit

Permalink
Support Python requirements with preceding "v" (#8229)
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Oct 18, 2023
1 parent fff2210 commit 63977df
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/lib/dependabot/python/requirement_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class RequirementParser
COMPARISON = /===|==|>=|<=|<|>|~=|!=/
VERSION = /([1-9][0-9]*!)?[0-9]+[a-zA-Z0-9\-_.*]*(\+[0-9a-zA-Z]+(\.[0-9a-zA-Z]+)*)?/

REQUIREMENT = /(?<comparison>#{COMPARISON})\s*\\?\s*(?<version>#{VERSION})/
REQUIREMENT = /(?<comparison>#{COMPARISON})\s*\\?\s*v?(?<version>#{VERSION})/
HASH = /--hash=(?<algorithm>.*?):(?<hash>.*?)(?=\s|\\|$)/
REQUIREMENTS = /#{REQUIREMENT}(\s*,\s*\\?\s*#{REQUIREMENT})*/
HASHES = /#{HASH}(\s*\\?\s*#{HASH})*/
Expand Down
8 changes: 8 additions & 0 deletions python/spec/dependabot/python/requirement_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ def parse(line)
end
end

context "with preceeding v" do
let(:line) { "luigi==v0.1.0" }
its([:name]) { is_expected.to eq "luigi" }
its([:requirements]) do
is_expected.to eq [{ comparison: "==", version: "0.1.0" }]
end
end

context "with a comment" do
let(:line) { "luigi==0.1.0 # some comment" }
its([:name]) { is_expected.to eq "luigi" }
Expand Down

0 comments on commit 63977df

Please sign in to comment.