From 367c901bc900bd4f85ea0e8dd6d0da5e61dc4bab Mon Sep 17 00:00:00 2001 From: allan johns Date: Thu, 9 Sep 2021 15:50:42 +1000 Subject: [PATCH] chore: rez versioning regex (#11634) --- lib/versioning/index.spec.ts | 2 + lib/versioning/rez/index.ts | 59 ++++++++++++++++++++++ lib/versioning/versioning-metadata.spec.ts | 3 +- 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 lib/versioning/rez/index.ts diff --git a/lib/versioning/index.spec.ts b/lib/versioning/index.spec.ts index 92097568612a07..aa23e0d78e35fa 100644 --- a/lib/versioning/index.spec.ts +++ b/lib/versioning/index.spec.ts @@ -33,6 +33,8 @@ describe('versioning/index', () => { const vers = allVersioning.getVersionings(); const loadedVers = loadModules(__dirname); + // TODO: revert rez in #10930 + delete loadedVers.rez; expect(Array.from(vers.keys())).toEqual(Object.keys(loadedVers)); for (const name of vers.keys()) { diff --git a/lib/versioning/rez/index.ts b/lib/versioning/rez/index.ts new file mode 100644 index 00000000000000..8114b4545321fb --- /dev/null +++ b/lib/versioning/rez/index.ts @@ -0,0 +1,59 @@ +// istanbul ignore file: requires (#10930) + +// original rez regex written in python (#11634) +// version_range_regex = ( +// # Match a version number (e.g. 1.0.0) +// r" ^(?P{version_group})$" +// "|" +// # Or match an exact version number (e.g. ==1.0.0) +// " ^(?P" +// " ==" # Required == operator +// " (?P{version_group})?" +// " )$" +// "|" +// # Or match an inclusive bound (e.g. 1.0.0..2.0.0) +// " ^(?P" +// " (?P{version_group})?" +// " \.\." # Required .. operator +// " (?P{version_group})?" +// " )$" +// "|" +// # Or match a lower bound (e.g. 1.0.0+) +// " ^(?P" +// " (?P>|>=)?" # Bound is exclusive? +// " (?P{version_group})?" +// " (?(lower_bound_prefix)|\+)" # + only if bound is not exclusive +// " )$" +// "|" +// # Or match an upper bound (e.g. <=1.0.0) +// " ^(?P" +// " (?P<(?={version_group})|<=)?" # Bound is exclusive? +// " (?P{version_group})?" +// " )$" +// "|" +// # Or match a range in ascending order (e.g. 1.0.0+<2.0.0) +// " ^(?P" +// " (?P" +// " (?P>|>=)?" # Lower bound is exclusive? +// " (?P{version_group})?" +// " (?(range_lower_asc_prefix)|\+)?" # + only if lower bound is not exclusive +// " )(?P" +// " (?(range_lower_asc_version),?|)" # , only if lower bound is found +// " (?P<(?={version_group})|<=)" # <= only if followed by a version group +// " (?P{version_group})?" +// " )" +// " )$" +// "|" +// # Or match a range in descending order (e.g. <=2.0.0,1.0.0+) +// " ^(?P" +// " (?P" +// " (?P<|<=)?" # Upper bound is exclusive? +// " (?P{version_group})?" +// " (?(range_upper_desc_prefix)|\+)?" # + only if upper bound is not exclusive +// " )(?P" +// " (?(range_upper_desc_version),|)" # Comma is not optional because we don't want to recognize something like "<4>3" +// " (?P<(?={version_group})|>=?)" # >= or > only if followed by a version group +// " (?P{version_group})?" +// " )" +// " )$" +// ).format(version_group=version_group) diff --git a/lib/versioning/versioning-metadata.spec.ts b/lib/versioning/versioning-metadata.spec.ts index 371d9abadf7467..7275d4d394b51f 100644 --- a/lib/versioning/versioning-metadata.spec.ts +++ b/lib/versioning/versioning-metadata.spec.ts @@ -26,7 +26,8 @@ describe('versioning/versioning-metadata', () => { (item) => !item.includes('.') && !item.startsWith('_') ); - for (const versioning of allVersioning) { + // TODO: revert rez in #10930 + for (const versioning of allVersioning.filter((v) => v !== 'rez')) { const versioningObj = require(`./${versioning}`); expect(versioningObj.id).toEqual(versioning); expect(versioningObj.displayName).toBeDefined();