callowayproject/bump-my-version

[bug] incorrectly bumps dependency that matches <project version>

Closed this issue · 1 comments

  • bump-my-version version: 0.12.0 (currently not a tagged release on github)
  • Python version: 3.12
  • Operating System: macOS

Description

Describe what you were trying to get done. Tell us what happened, what went wrong, and what you expected to happen.

bump-my-version seemingly mis-identifies strings other than version in the target file that are contained in the current version string.

Expected: bumping versions in pyproject.toml only changes project.version and tool.bumpversion.current_version (if present).

What I Did

While trying to bump minor version of a pyproject.toml containing a dependency whose version substring-matches version, both were updated.

[project]
name = "sample-repo"
version = "0.0.2"
description = ""
authors = [
    {name = "Amar Paul", email = "amar.paul16@gmail.com"},
]
dependencies = []
requires-python = ">=3.11"
readme = "README.md"
license = {text = "MIT"}

[build-system]
requires = ["setuptools>=61", "wheel"]
build-backend = "setuptools.build_meta"

[tool.pdm.dev-dependencies]
lint = [
    "ruff==0.0.292",
]
build = [
    "bump-my-version>=0.12.0",
]

[tool.bumpversion]
commit = false
tag = false
current_version = "0.0.2"
$ bump-my-version bump minor pyproject.toml

results in:

diff --git a/pyproject.toml b/pyproject.toml
index ebdfd3d..a98f3d9 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [project]
 name = "sample-repo"
-version = "0.0.2"
+version = "0.1.0"
 description = ""
 authors = [
     {name = "Amar Paul", email = "amar.paul16@gmail.com"},
@@ -16,7 +16,7 @@ build-backend = "setuptools.build_meta"
 
 [tool.pdm.dev-dependencies]
 lint = [
-    "ruff==0.0.292",
+    "ruff==0.1.092",
 ]
 build = [
     "bump-my-version>=0.12.0",
@@ -25,4 +25,4 @@ build = [
 [tool.bumpversion]
 commit = false
 tag = false
-current_version = "0.0.2"
+current_version = "0.1.0"

note that the original dependency string for ruff contains 0.0.2, even though it has a longer version string (0.0.292 in this case).

See discussion of search regexes to avoid false positive matches, here: #97 (comment)