Files
wehub-resource-sync e4dcfc49aa
Tests / Import Check (Python 3.13) (push) Has been cancelled
Tests / Import Check (Python 3.14) (push) Has been cancelled
Tests / Python Tests (Python 3.11) (push) Has been cancelled
Tests / Python Tests (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.14) (push) Has been cancelled
Tests / Test Summary (push) Has been cancelled
Tests / Lint and Format (push) Has been cancelled
Tests / Web Node Tests (push) Has been cancelled
Tests / Import Check (Python 3.11) (push) Has been cancelled
Tests / Import Check (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.13) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:00:43 +08:00

17 lines
610 B
TypeScript

/** Normalize a version string into a ``vMAJOR.MINOR.PATCH`` tag form.
*
* Accepts PEP 440 / semver forms used in ``deeptutor/__version__.py`` and
* GitHub release tags (``1.4.0``, ``v1.4.0``, ``1.4.0rc1``, ``v1.0.0-beta.4``)
* while rejecting git-describe output like ``v1.2.3-5-gabc1234``.
*/
export function normalizeVersionTag(
raw: string | null | undefined,
): string | null {
const value = raw?.trim();
if (!value) return null;
const match = value.match(
/^v?(\d+\.\d+\.\d+(?:(?:rc|a|b)\d+|\.dev\d+|\.post\d+|-[A-Za-z][0-9A-Za-z.-]*)?)$/,
);
return match ? `v${match[1]}` : null;
}