mirror of
https://github.com/actions/checkout.git
synced 2026-11-16 22:45:08 +08:00
compare an explicit patch of zero against the minimum version
GitVersion.checkMinimum guarded the patch comparison with a truthiness check
on `this.patch`, so a version whose patch component was explicitly zero was
treated as if the patch were unspecified and the comparison was skipped
entirely. That made `new GitVersion('4.5.0').checkMinimum(new GitVersion('4.5.1'))`
return true.
Compare the patch only when it was actually specified, distinguishing an
explicit zero from an unspecified one. A two-part version such as "2.28" still
leaves patch as NaN and continues to satisfy any patch of that minor version,
which is the behavior the existing tests rely on.
* compare an explicit patch of zero against the minimum version
* add regression coverage for an explicit patch of zero
* rebuild dist
This commit is contained in:
parent
f548e57e54
commit
72ca3d5f64
3 changed files with 37 additions and 4 deletions
8
dist/index.js
vendored
8
dist/index.js
vendored
|
|
@ -35553,8 +35553,12 @@ class GitVersion {
|
|||
}
|
||||
// Minor is equal
|
||||
if (this.minor === minimum.minor) {
|
||||
// Patch is insufficient
|
||||
if (this.patch && this.patch < (minimum.patch || 0)) {
|
||||
// Patch is insufficient. The patch component is only compared when it
|
||||
// was explicitly specified: an instance built from a two-part version
|
||||
// (e.g. "2.28") leaves patch as NaN, which is treated as satisfying any
|
||||
// patch of that minor version. An explicit zero must not be mistaken for
|
||||
// an unspecified value, because 0 is falsy.
|
||||
if (!Number.isNaN(this.patch) && this.patch < (minimum.patch || 0)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue