Skip to content

Commit

Permalink
Merge pull request #9280 from smokris/pip-freeze-url-format
Browse files Browse the repository at this point in the history
Support pip freeze URL format
  • Loading branch information
cthorn42 authored Mar 18, 2024
2 parents 1a53bf7 + 207a7dc commit 9a03c3e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/puppet/provider/package/pip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,12 @@ def self.instances(target_command = nil)

# Parse lines of output from `pip freeze`, which are structured as:
# _package_==_version_ or _package_===_version_
# or _package_ @ someURL@_version_
def self.parse(line)
if line.chomp =~ /^([^=]+)===?([^=]+)$/
{ :ensure => Regexp.last_match(2), :name => Regexp.last_match(1), :provider => name }
elsif line.chomp =~ /^([^@]+) @ [^@]+@(.+)$/
{ :ensure => Regexp.last_match(2), :name => Regexp.last_match(1), :provider => name }
end
end

Expand Down
8 changes: 8 additions & 0 deletions spec/unit/provider/package/pip_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
})
end

it "should correctly parse URL format" do
expect(described_class.parse("real_package @ git+https://github.com/example/test.git@6b4e203b66c1de7345984882e2b13bf87c700095")).to eq({
:ensure => "6b4e203b66c1de7345984882e2b13bf87c700095",
:name => "real_package",
:provider => :pip,
})
end

it "should return nil on invalid input" do
expect(described_class.parse("foo")).to eq(nil)
end
Expand Down

0 comments on commit 9a03c3e

Please sign in to comment.