Skip to content

Commit

Permalink
Merge pull request #9311 from joshcooper/backport_9280
Browse files Browse the repository at this point in the history
[Backport 7.x] Support pip freeze URL format
  • Loading branch information
tvpartytonight committed Apr 2, 2024
2 parents 6b24346 + 28c5881 commit f57e31e
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
Expand Up @@ -99,9 +99,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 => $2, :name => $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
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 f57e31e

Please sign in to comment.