Skip to content

Commit

Permalink
Merge pull request #17218 from samford/livecheck/pypi-update-strategy…
Browse files Browse the repository at this point in the history
…-regex

Pypi: Update strategy regex
  • Loading branch information
MikeMcQuaid authored May 3, 2024
2 parents afe9ec9 + 78c7ad7 commit dfbf269
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Library/Homebrew/livecheck/strategy/pypi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def self.generate_input_values(url)
regex_suffix = Regexp.escape(suffix).gsub("\\-", "-")

# Example regex: `%r{href=.*?/packages.*?/example[._-]v?(\d+(?:\.\d+)*(?:[._-]post\d+)?)\.t}i`
regex_name = Regexp.escape(T.must(match[:package_name])).gsub("\\-", "-")
regex_name = Regexp.escape(T.must(match[:package_name])).gsub(/\\[_-]/, "[_-]")
values[:regex] =
%r{href=.*?/packages.*?/#{regex_name}[._-]v?(\d+(?:\.\d+)*(?:[._-]post\d+)?)#{regex_suffix}}i

Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/test/livecheck/strategy/pypi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
RSpec.describe Homebrew::Livecheck::Strategy::Pypi do
subject(:pypi) { described_class }

let(:pypi_url) { "https://files.pythonhosted.org/packages/ab/cd/efg/example-1.2.3.tar.gz" }
let(:pypi_url) { "https://files.pythonhosted.org/packages/ab/cd/efg/example-package-1.2.3.tar.gz" }
let(:non_pypi_url) { "https://brew.sh/test" }

let(:generated) do
{
url: "https://pypi.org/project/example/#files",
regex: %r{href=.*?/packages.*?/example[._-]v?(\d+(?:\.\d+)*(?:[._-]post\d+)?)\.t}i,
url: "https://pypi.org/project/example-package/#files",
regex: %r{href=.*?/packages.*?/example[_-]package[._-]v?(\d+(?:\.\d+)*(?:[._-]post\d+)?)\.t}i,
}
end

Expand Down

0 comments on commit dfbf269

Please sign in to comment.