From 039d5f45ac99e1b668db75df70027ba1be40dc5b Mon Sep 17 00:00:00 2001 From: codejedi365 Date: Tue, 13 May 2025 22:04:13 -0600 Subject: [PATCH 1/3] test(stamp-version): add test case for stamping a `requirements.txt` file with double-equals --- .../version/declarations/test_pattern_declaration.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/unit/semantic_release/version/declarations/test_pattern_declaration.py b/tests/unit/semantic_release/version/declarations/test_pattern_declaration.py index fd7cb7dad..8280e95bb 100644 --- a/tests/unit/semantic_release/version/declarations/test_pattern_declaration.py +++ b/tests/unit/semantic_release/version/declarations/test_pattern_declaration.py @@ -165,6 +165,15 @@ def test_pattern_declaration_is_version_replacer(): """if version := '1.0.0': """, f"""if version := '{next_version}': """, ), + ( + "Explicit number format for requirements.txt file with double equals", + f"{test_file}:my-package:{VersionStampType.NUMBER_FORMAT.value}", + # irrelevant for this case + lazy_fixture(default_tag_format_str.__name__), + # Uses double equals separator + """my-package == 1.0.0""", + f"""my-package == {next_version}""", + ), ( "Using default number format for multi-line & quoted json", f"{test_file}:version:{VersionStampType.NUMBER_FORMAT.value}", From 4f81eb481f4351e81cd00dcd135063ddc39dbedb Mon Sep 17 00:00:00 2001 From: codejedi365 Date: Tue, 13 May 2025 22:05:33 -0600 Subject: [PATCH 2/3] feat(cmd-version): enable `version_variables` to stamp variables with double-equals (`==`) --- src/semantic_release/version/declarations/pattern.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/semantic_release/version/declarations/pattern.py b/src/semantic_release/version/declarations/pattern.py index 55873ce0a..e96234117 100644 --- a/src/semantic_release/version/declarations/pattern.py +++ b/src/semantic_release/version/declarations/pattern.py @@ -230,9 +230,9 @@ def from_string_definition( # Supports optional matching quotations around variable name # Negative lookbehind to ensure we don't match part of a variable name f"""(?x)(?P['"])?(?['"])?{value_replace_pattern_str}(?P=quote2)?""", ], From 695074173127a063f9ca5a6e733fe2012303579d Mon Sep 17 00:00:00 2001 From: codejedi365 Date: Tue, 13 May 2025 22:16:55 -0600 Subject: [PATCH 3/3] docs(configuration): update `version_variables` section to include double-equals operand support --- docs/configuration.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 78e20d183..aa904dc9d 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -1347,7 +1347,8 @@ The regular expression generated from the ``version_variables`` definition will: 2. The variable name defined by ``variable`` and the version must be separated by an operand symbol (``=``, ``:``, ``:=``, or ``@``). Whitespace is optional around - the symbol. + the symbol. As of $NEW_VERSION, a double-equals (``==``) operator is also supported + as a valid operand symbol. 3. The value of the variable must match a `SemVer`_ regular expression and can be enclosed by single (``'``) or double (``"``) quotation marks but they must match. However, @@ -1400,6 +1401,9 @@ will be matched and replaced by the new version: # Custom Tag Format with tag_format set (monorepos) __release__ = "module-v1.2.3" + # requirements.txt + my-package == 1.2.3 + .. important:: The Regular Expression expects a version value to exist in the file to be replaced. It cannot be an empty string or a non-semver compliant string. If this is the very