utils/pypi: make package name comparison case-insensitive
This commit is contained in:
parent
58f279c72a
commit
4bfb390577
@ -22,6 +22,7 @@ describe PyPI do
|
|||||||
let(:package_with_different_version) { described_class.new("snakemake==5.29.0") }
|
let(:package_with_different_version) { described_class.new("snakemake==5.29.0") }
|
||||||
let(:package_with_extra) { described_class.new("snakemake[foo]") }
|
let(:package_with_extra) { described_class.new("snakemake[foo]") }
|
||||||
let(:package_with_extra_and_version) { described_class.new("snakemake[foo]==5.28.0") }
|
let(:package_with_extra_and_version) { described_class.new("snakemake[foo]==5.28.0") }
|
||||||
|
let(:package_with_different_capitalization) { described_class.new("SNAKEMAKE") }
|
||||||
let(:package_from_url) { described_class.new(package_url, is_url: true) }
|
let(:package_from_url) { described_class.new(package_url, is_url: true) }
|
||||||
let(:other_package) { described_class.new("virtualenv==20.2.0") }
|
let(:other_package) { described_class.new("virtualenv==20.2.0") }
|
||||||
|
|
||||||
@ -146,6 +147,10 @@ describe PyPI do
|
|||||||
it "returns true for the same package with different versions" do
|
it "returns true for the same package with different versions" do
|
||||||
expect(package_with_version.same_package?(package_with_different_version)).to eq true
|
expect(package_with_version.same_package?(package_with_different_version)).to eq true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns true for the same package with different capitalization" do
|
||||||
|
expect(package.same_package?(package_with_different_capitalization)).to eq true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "<=>" do
|
describe "<=>" do
|
||||||
|
|||||||
@ -91,7 +91,7 @@ module PyPI
|
|||||||
|
|
||||||
sig { params(other: Package).returns(T::Boolean) }
|
sig { params(other: Package).returns(T::Boolean) }
|
||||||
def same_package?(other)
|
def same_package?(other)
|
||||||
@name.tr("_", "-") == other.name.tr("_", "-")
|
@name.downcase.tr("_", "-") == other.name.downcase.tr("_", "-")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Compare only names so we can use .include? on a Package array
|
# Compare only names so we can use .include? on a Package array
|
||||||
@ -231,7 +231,7 @@ module PyPI
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Remove extra packages that may be included in pipgrip output
|
# Remove extra packages that may be included in pipgrip output
|
||||||
exclude_list = %W[#{main_package.name.downcase} argparse pip setuptools wheel wsgiref].map { |p| Package.new p }
|
exclude_list = %W[#{main_package.name} argparse pip setuptools wheel wsgiref].map { |p| Package.new p }
|
||||||
found_packages.delete_if { |package| exclude_list.include? package }
|
found_packages.delete_if { |package| exclude_list.include? package }
|
||||||
|
|
||||||
new_resource_blocks = ""
|
new_resource_blocks = ""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user