mirror of
https://github.com/actions/checkout.git
synced 2026-09-26 20:10:04 +08:00
Merge 72ca3d5f64 into f548e57e54
This commit is contained in:
commit
008d5545f3
|
|
@ -45,6 +45,31 @@ describe('git-version tests', () => {
|
||||||
expect(version.checkMinimum(new GitVersion('5.1.2'))).toBeFalsy()
|
expect(version.checkMinimum(new GitVersion('5.1.2'))).toBeFalsy()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('compares an explicit patch of zero', async () => {
|
||||||
|
// A patch component of zero must be compared, not treated as unspecified
|
||||||
|
// (0 is falsy). A patch left unspecified by a two-part version such as
|
||||||
|
// "2.28" is treated as satisfying any patch of that minor version.
|
||||||
|
expect(
|
||||||
|
new GitVersion('4.5.0').checkMinimum(new GitVersion('4.5.1'))
|
||||||
|
).toBeFalsy()
|
||||||
|
expect(
|
||||||
|
new GitVersion('2.28.0').checkMinimum(new GitVersion('2.28.1'))
|
||||||
|
).toBeFalsy()
|
||||||
|
expect(
|
||||||
|
new GitVersion('4.5.0').checkMinimum(new GitVersion('4.5.0'))
|
||||||
|
).toBeTruthy()
|
||||||
|
expect(
|
||||||
|
new GitVersion('4.5.0').checkMinimum(new GitVersion('4.5'))
|
||||||
|
).toBeTruthy()
|
||||||
|
expect(
|
||||||
|
new GitVersion('4.5.1').checkMinimum(new GitVersion('4.5.0'))
|
||||||
|
).toBeTruthy()
|
||||||
|
// Unspecified patch satisfies any patch of the same minor version
|
||||||
|
expect(
|
||||||
|
new GitVersion('4.5').checkMinimum(new GitVersion('4.5.0'))
|
||||||
|
).toBeTruthy()
|
||||||
|
})
|
||||||
|
|
||||||
it('sparse checkout', async () => {
|
it('sparse checkout', async () => {
|
||||||
const minSparseVer = MinimumGitSparseCheckoutVersion
|
const minSparseVer = MinimumGitSparseCheckoutVersion
|
||||||
expect(new GitVersion('1.0').checkMinimum(minSparseVer)).toBeFalsy()
|
expect(new GitVersion('1.0').checkMinimum(minSparseVer)).toBeFalsy()
|
||||||
|
|
|
||||||
8
dist/index.js
vendored
8
dist/index.js
vendored
|
|
@ -35553,8 +35553,12 @@ class GitVersion {
|
||||||
}
|
}
|
||||||
// Minor is equal
|
// Minor is equal
|
||||||
if (this.minor === minimum.minor) {
|
if (this.minor === minimum.minor) {
|
||||||
// Patch is insufficient
|
// Patch is insufficient. The patch component is only compared when it
|
||||||
if (this.patch && this.patch < (minimum.patch || 0)) {
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,12 @@ export class GitVersion {
|
||||||
|
|
||||||
// Minor is equal
|
// Minor is equal
|
||||||
if (this.minor === minimum.minor) {
|
if (this.minor === minimum.minor) {
|
||||||
// Patch is insufficient
|
// Patch is insufficient. The patch component is only compared when it
|
||||||
if (this.patch && this.patch < (minimum.patch || 0)) {
|
// 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
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user