-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix #155 by extracting version without suffix #175
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @seigert for working on this!
I don’t think the fix is correct, please see my comment below.
isCompatible("1.0.0-RC1", "1.0.0-RC1") | ||
isCompatible("1.0.0", "1.0.0-RC1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is inconsistent with what versions
does, see https://scastie.scala-lang.org/LQVPcpnLSuqRzz9z8J4jQA.
We should ignore the suffix of the current version only (as in https://scastie.scala-lang.org/miZPzsvfS7mrB6FGoyMVEQ).
So, we should have the following assertions:
isBreaking("1.0.0", "1.0.0-RC1")
isBreaking("1.0.1", "1.0.0-RC1")
isBreaking("1.1.0", "1.0.0-RC1")
isBreaking("2.0.0", "1.0.0-RC1")
isCompatible("1.0.0-RC1", "1.0.0-RC1")
isCompatible("1.1.0-RC1", "1.0.0")
isCompatible("1.2.1-SNAPSHOT", "1.2.0")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed logic to ignore suffix only for current version with just one note: isCompatible("1.1.0-RC1", "1.0.0")
=> isCompatible("1.0.1-RC1", "1.0.0")
, because 1.1.0
is allowed to be source incompatible.
This leads to question: what should we do with changes in suffix? Should RC2 vs RC1
or RC1 vs SNAPSHOT
be assumed compatible or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This leads to question: what should we do with changes in suffix? Should RC2 vs RC1 or RC1 vs SNAPSHOT be assumed compatible or not?
We should conform to the following checks:
isBreaking("1.0.0-RC2", "1.0.0-RC1")
isBreaking("1.1.0-RC2", "1.1.0-RC1")
// however:
isCompatible("1.0.1-RC2", "1.0.1-RC1")
The reason is that 1.0.1-RC1
and 1.0.1-RC2
are both candidates for patch releases, and patch releases cannot introduce source incompatibilities anyway.
sbt-version-policy/src/test/scala/sbtversionpolicy/DependencyCheckReportTest.scala
Show resolved
Hide resolved
sbt-version-policy/src/test/scala/sbtversionpolicy/DependencyCheckReportTest.scala
Show resolved
Hide resolved
I think I've implemented this correctly -- at least, all checks pass. :) Also, I've reordered checks by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for the quick update!
I’ve left two minor comments, but otherwise it looks good to me!
sbt-version-policy/src/main/scala/sbtversionpolicy/DependencyCheckReport.scala
Outdated
Show resolved
Hide resolved
def compatPatch = | ||
(currentSemVer.patch > 0 && samePatch) || | ||
(currentSemVer.patch > previousSemVer.patch && previousSemVer.suffix.isEmpty) | ||
|
||
sameMajor && sameMinor && ((samePatch && sameSuffix) || compatPatch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this could be simplified to:
def compatPatch = | |
(currentSemVer.patch > 0 && samePatch) || | |
(currentSemVer.patch > previousSemVer.patch && previousSemVer.suffix.isEmpty) | |
sameMajor && sameMinor && ((samePatch && sameSuffix) || compatPatch) | |
def compatPatch = | |
previousSemVer.suffix.isEmpty || previousSemVer.patch > 0 | |
sameMajor && sameMinor && compatPatch |
(untested)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've used your check, but we still need (samePatch && sameSuffix)
to allow 1.0.0-RC1
be source compat to itself. :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Should I add it to filters? Class is private and only method that uses it is private too. |
Yes, please add it to the filters with a comment that says it is |
Done. |
Thank you @sjrd for merging the PR. It would be great to publish the fix by creating a new release on GitHub (version 2.1.3) |
As proposed by @julienrf I've changed semver version extraction method to allow suffixes after first three numbers.
Test are updated accordingly.