Fix intersection if a version is a prefix of another (#22941)
* Added test for version intersections when one is prefix of another * Fix version intersection for prefixes
This commit is contained in:
parent
6ab859fb45
commit
5cb5aac57e
@ -373,6 +373,9 @@ def test_intersect_with_containment():
|
|||||||
check_intersection('1.6:1.6.5', ':1.6.5', '1.6')
|
check_intersection('1.6:1.6.5', ':1.6.5', '1.6')
|
||||||
check_intersection('1.6:1.6.5', '1.6', ':1.6.5')
|
check_intersection('1.6:1.6.5', '1.6', ':1.6.5')
|
||||||
|
|
||||||
|
check_intersection('11.2', '11', '11.2')
|
||||||
|
check_intersection('11.2', '11.2', '11')
|
||||||
|
|
||||||
|
|
||||||
def test_union_with_containment():
|
def test_union_with_containment():
|
||||||
check_union(':1.6', '1.6.5', ':1.6')
|
check_union(':1.6', '1.6.5', ':1.6')
|
||||||
|
@ -372,8 +372,10 @@ def union(self, other):
|
|||||||
|
|
||||||
@coerced
|
@coerced
|
||||||
def intersection(self, other):
|
def intersection(self, other):
|
||||||
if self == other:
|
if self in other: # also covers `self == other`
|
||||||
return self
|
return self
|
||||||
|
elif other in self:
|
||||||
|
return other
|
||||||
else:
|
else:
|
||||||
return VersionList()
|
return VersionList()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user