Skip to content

Commit

Permalink
Fix method name typo
Browse files Browse the repository at this point in the history
Fix NoMethodError when using a union (||) of comparator sets. Add test to cover
that case and update comments.

Note SemanticPuppet incorrectly merges comparators sets with prerelease
versions. So it should consider 1.0.0 to be included in the range, but it is not
currently.
  • Loading branch information
joshcooper committed Jan 6, 2025
1 parent 66f73a5 commit 9f9b71c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/semantic_puppet/version_range.rb
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ def upper_bound?

# Merge two ranges so that the result matches the intersection of all matching versions.
#
# @param range [AbastractRange] the range to intersect with
# @return [AbastractRange,nil] the intersection between the ranges
# @param range [AbstractRange] the range to intersect with
# @return [AbstractRange,nil] the intersection between the ranges
#
# @api private
def intersection(range)
Expand Down Expand Up @@ -474,7 +474,7 @@ def merge(other)
excl_end = other.exclude_end?
else
max = self.end
excl_end = exclude_end && other.exclude_end?
excl_end = exclude_end? && other.exclude_end?
end

MinMaxRange.create(excl_begin ? GtRange.new(min) : GtEqRange.new(min), excl_end ? LtRange.new(max) : LtEqRange.new(max))
Expand All @@ -499,7 +499,7 @@ def merge(other)
# Checks if this matcher accepts a prerelease with the same major, minor, patch triple as the given version. Only matchers
# where this has been explicitly stated will respond `true` to this method
#
# @return [Boolean] `true` if this matcher accepts a prerelase with the tuple from the given version
# @return [Boolean] `true` if this matcher accepts a prerelease with the tuple from the given version
def test_prerelease?(_)
false
end
Expand Down
10 changes: 10 additions & 0 deletions spec/unit/semantic_puppet/version_range_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,16 @@ def self.test_range(range_list, str, includes, excludes)
expect(range.exclude_end?).to be_nil
end
end

context 'prerelease' do
test_expressions(
[ '>=5.0.1-rc0' || '>=0.5.0' ] => {
:to_str => '>=5.0.1-rc0',
:includes => ['5.0.1-rc0', '5.0.1'], # should include 1.0.0
:excludes => ['1.0.0', '5.0.0-rc0', '5.0.2-rc0']
}
)
end
end

context 'invalid expressions' do
Expand Down

0 comments on commit 9f9b71c

Please sign in to comment.