Fix version validation for nightlies
Summary: The nightly version is bumped after the check is performed, therefore it fails. With this diff, we become slightly more accepting with nightlies, allowing both `0.0.0` and `0.0.0-xxxx` as valid version for nightlies. ## Changelog [JS][Fixed] - Accept 0.0.0 with and without prelrelease for nightlies' versions Reviewed By: cortinico Differential Revision: D41534995 fbshipit-source-id: 2d0417441ca7d3d3f7660c9317133ac3c6de2eb9
This commit is contained in:
Родитель
8b8f4f3efd
Коммит
a67286913c
|
@ -171,14 +171,19 @@ describe('version-utils', () => {
|
|||
expect(prerelease).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should reject nightly with no prerelease', () => {
|
||||
it('should parse nightly with no prerelease', () => {
|
||||
// this should fail
|
||||
function testInvalidFunction() {
|
||||
parseVersion('0.0.0', 'nightly');
|
||||
}
|
||||
expect(testInvalidFunction).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Version 0.0.0 is not valid for nightlies"`,
|
||||
|
||||
const {version, major, minor, patch, prerelease} = parseVersion(
|
||||
'0.0.0',
|
||||
'nightly',
|
||||
);
|
||||
|
||||
expect(version).toBe('0.0.0');
|
||||
expect(major).toBe('0');
|
||||
expect(minor).toBe('0');
|
||||
expect(patch).toBe('0');
|
||||
expect(prerelease).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should reject nightly with prerelease but wrong version numbers', () => {
|
||||
|
@ -308,13 +313,17 @@ describe('version-utils', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('should reject dryrun for nightlies with invalid prerelease', () => {
|
||||
function testInvalidFunction() {
|
||||
parseVersion('0.0.0', 'dry-run');
|
||||
}
|
||||
expect(testInvalidFunction).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Version 0.0.0 is not valid for dry-runs"`,
|
||||
it('should parse dryrun for nightlies with no prerelease', () => {
|
||||
const {version, major, minor, patch, prerelease} = parseVersion(
|
||||
'0.0.0',
|
||||
'dry-run',
|
||||
);
|
||||
|
||||
expect(version).toBe('0.0.0');
|
||||
expect(major).toBe('0');
|
||||
expect(minor).toBe('0');
|
||||
expect(patch).toBe('0');
|
||||
expect(prerelease).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ const VERSION_REGEX = /^v?((\d+)\.(\d+)\.(\d+)(?:-(.+))?)$/;
|
|||
* Some examples of valid versions are:
|
||||
* - stable: 0.68.1
|
||||
* - stable prerelease: 0.70.0-rc.0
|
||||
* - nightly: 0.0.0-20221116-2018-0bc4547fc
|
||||
* - nightly: 0.0.0-20221116-2018-0bc4547fc | 0.0.0
|
||||
* - dryrun: 1000.0.0
|
||||
*
|
||||
* Parameters:
|
||||
|
@ -95,11 +95,9 @@ function validateRelease(version) {
|
|||
}
|
||||
|
||||
function validateDryRun(version) {
|
||||
const isNightly = isNightlyBuild(version) && version.prerelease != null;
|
||||
|
||||
if (
|
||||
!isMain(version) &&
|
||||
!isNightly &&
|
||||
!isNightlyBuild(version) &&
|
||||
!isStableRelease(version) &&
|
||||
!isStablePrerelease(version)
|
||||
) {
|
||||
|
@ -109,9 +107,7 @@ function validateDryRun(version) {
|
|||
|
||||
function validateNightly(version) {
|
||||
// a valid nightly is a prerelease
|
||||
const isPrerelease = version.prerelease != null;
|
||||
const isValidNightly = isNightlyBuild(version) && isPrerelease;
|
||||
if (!isValidNightly) {
|
||||
if (!isNightlyBuild(version)) {
|
||||
throw new Error(`Version ${version.version} is not valid for nightlies`);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче