mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
utils/pypi: return nil for non-pypi-packages from url
This commit is contained in:
parent
9298e4959b
commit
22a3025f6e
@ -172,5 +172,13 @@ describe PyPI do
|
|||||||
it "updates url to new version" do
|
it "updates url to new version" do
|
||||||
expect(described_class.update_pypi_url(old_package_url, "5.29.0")).to eq package_url
|
expect(described_class.update_pypi_url(old_package_url, "5.29.0")).to eq package_url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns nil for invalid versions" do
|
||||||
|
expect(described_class.update_pypi_url(old_package_url, "0.0.0")).to eq nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns nil for non-pypi urls" do
|
||||||
|
expect(described_class.update_pypi_url("https://brew.sh/foo-1.0.tgz", "1.1")).to eq nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -110,8 +110,12 @@ module PyPI
|
|||||||
def update_pypi_url(url, version)
|
def update_pypi_url(url, version)
|
||||||
package = Package.new url, is_url: true
|
package = Package.new url, is_url: true
|
||||||
|
|
||||||
|
return unless package.valid_pypi_package?
|
||||||
|
|
||||||
_, url = package.pypi_info(version: version)
|
_, url = package.pypi_info(version: version)
|
||||||
url
|
url
|
||||||
|
rescue ArgumentError
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return true if resources were checked (even if no change).
|
# Return true if resources were checked (even if no change).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user