From 647b10b73b1c60dbe35632dee192086192a9cd0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?sag=E2=80=8Be?= Date: Thu, 24 Oct 2024 21:05:59 +0100 Subject: [PATCH] Clarify support for an optional `v`-prefix in branch and tag names (#11712) * Clarify support for an optional v-prefix in branch and tag names * Add info about v-prefix in automation rules docs --- docs/user/automation-rules.rst | 3 ++- docs/user/versions.rst | 4 +++- readthedocs/builds/constants.py | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/user/automation-rules.rst b/docs/user/automation-rules.rst index 01b72dc0817..f76d9969ec1 100644 --- a/docs/user/automation-rules.rst +++ b/docs/user/automation-rules.rst @@ -46,7 +46,8 @@ Predefined matches Automation rules support two predefined version matches: - **Any version**: All new versions will match the rule. -- **SemVer versions**: All new versions that follow `semantic versioning `__ will match the rule. +- **SemVer versions**: All new versions that follow `semantic versioning `__ + (with or without a `v` prefix) will match the rule. Custom matches ~~~~~~~~~~~~~~ diff --git a/docs/user/versions.rst b/docs/user/versions.rst index 8e54fe3a6dc..19d0cba957f 100644 --- a/docs/user/versions.rst +++ b/docs/user/versions.rst @@ -19,7 +19,8 @@ During initial setup, Read the Docs also creates a ``latest`` version that points to the default branch defined in your Git repository (usually ``main``). This version should always exist and is the default version for your project. -If your project has any tags or branches with a name following `semantic versioning `_, +If your project has any tags or branches with a name following +`semantic versioning `_ (with or without a ``v`` prefix), we also create a ``stable`` version tracking your most recent release. If you want a custom ``stable`` version, create either a tag or branch in your project with that name. @@ -135,6 +136,7 @@ all of which can be reconfigured if necessary: Semantic versioning allows "normal" version numbers like ``1.4.2``, as well as pre-releases like this: ``2.0a1``. The ``stable`` version of your documentation never includes a pre-release. + An optional ``v`` prefix like ``v1.4.2`` or ``v2.0a1`` is also allowed. - Branches are assumed to be **long-lived branches**, This is most useful for **release branches**, which are maintained over time for a specific release. diff --git a/readthedocs/builds/constants.py b/readthedocs/builds/constants.py index 39fc8edb4f8..564467edde7 100644 --- a/readthedocs/builds/constants.py +++ b/readthedocs/builds/constants.py @@ -130,6 +130,8 @@ # Pattern referred from # https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string +# without naming the capturing groups and with the addition of +# allowing an optional "v" prefix. SEMVER_VERSIONS_REGEX = r"^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$" # noqa