Skip to content

Commit

Permalink
fix(script): handle patch versions after the .0 for set version (#36020)
Browse files Browse the repository at this point in the history
Summary:
A small backport to main of a local fix done in 0.71 to account for the logic for releases 0.Y.1,2,3-prerelease (meaning, not just strictly 0).

I could have done like the other logics and just remove the check for patch, but decided to at least make sure it's a digit 😅

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[INTERNAL] [FIXED] - handle patch versions after the .0 for set version

Pull Request resolved: #36020

Test Plan: Tested in 0.71-stable, without it we can't test RNTestProject.

Reviewed By: jacdebug, cortinico

Differential Revision: D42924375

Pulled By: cipolleschi

fbshipit-source-id: b003d884cc45a2602adbc14fa8b66d3f1e0c94a6
  • Loading branch information
kelset authored and facebook-github-bot committed Feb 7, 2023
1 parent ecf967a commit 7adf6b1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
27 changes: 0 additions & 27 deletions scripts/__tests__/version-utils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,6 @@ describe('version-utils', () => {
expect(prerelease).toBe('rc.4');
});

it('should reject pre-release version with patch != 0', () => {
function testInvalidVersion() {
parseVersion('0.66.3-rc.4', 'release');
}
expect(testInvalidVersion).toThrowErrorMatchingInlineSnapshot(
`"Version 0.66.3-rc.4 is not valid for Release"`,
);
});

it('should reject pre-release version from tag with random prerelease pattern', () => {
function testInvalidVersion() {
parseVersion('v0.66.0-something_invalid', 'release');
Expand Down Expand Up @@ -233,15 +224,6 @@ describe('version-utils', () => {
expect(prerelease).toBe('rc.0');
});

it('should reject dryrun with prerelease . version with patch different from 0', () => {
function testInvalidFunction() {
parseVersion('0.20.3-rc.0', 'dry-run');
}
expect(testInvalidFunction).toThrowErrorMatchingInlineSnapshot(
`"Version 0.20.3-rc.0 is not valid for dry-runs"`,
);
});

it('should parse dryrun with prerelease - version', () => {
const {version, major, minor, patch, prerelease} = parseVersion(
'0.20.0-rc-0',
Expand All @@ -254,15 +236,6 @@ describe('version-utils', () => {
expect(prerelease).toBe('rc-0');
});

it('should reject dryrun with prerelease - version with patch different from 0', () => {
function testInvalidFunction() {
parseVersion('0.20.3-rc-0', 'dry-run');
}
expect(testInvalidFunction).toThrowErrorMatchingInlineSnapshot(
`"Version 0.20.3-rc-0 is not valid for dry-runs"`,
);
});

it('should parse dryrun with main version', () => {
const {version, major, minor, patch, prerelease} = parseVersion(
'1000.0.0',
Expand Down
2 changes: 1 addition & 1 deletion scripts/version-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function isStablePrerelease(version) {
return (
version.major === '0' &&
version.minor !== '0' &&
version.patch === '0' &&
version.patch.match(/^\d+$/) &&
version.prerelease != null &&
(version.prerelease.startsWith('rc.') ||
version.prerelease.startsWith('rc-') ||
Expand Down

0 comments on commit 7adf6b1

Please sign in to comment.