Repository: callowayproject/bump-my-version
Pull request #57 (2023-08-25 12:46:39)

55 bump silently fails
This was due to how the file config tried to filter out bad values.


Patch:
diff --git a/.changelog-config.yaml b/.changelog-config.yaml
index 9e725e73..838db4e9 100644
--- a/.changelog-config.yaml
+++ b/.changelog-config.yaml
@@ -104,34 +104,27 @@ valid_author_tokens:
 # Rules applied to commits to determine the type of release to suggest.
 release_hint_rules:
   - match_result: dev
-    no_match_result: no-release
     branch: ^((?!master|main).)*$
   - match_result: patch
-    no_match_result: no-release
     path: requirements/prod.in
     branch: master|main
   - match_result: patch
-    no_match_result: no-release
     grouping: Other
     path: bumpversion/*
     branch: master|main
   - match_result: patch
-    no_match_result: no-release
     grouping: Fixes
     path: bumpversion/*
     branch: master|main
   - match_result: minor
-    no_match_result: no-release
     grouping: Updates
     path: bumpversion/*
     branch: master|main
   - match_result: minor
-    no_match_result: no-release
     grouping: New
     path: bumpversion/*
     branch: master|main
   - match_result: major
-    no_match_result: no-release
     grouping: Breaking Changes
     path: bumpversion/*
     branch: master|main
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 9002f345..fe85899d 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -64,6 +64,7 @@ jobs:
         with:
           fetch-depth: 0
           token: ${{ secrets.PAT }}
+          ref: ${{ github.head_ref }}
 
       - uses: actions/setup-python@v4
         with:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 833ec0d9..e0e486fb 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,7 +1,7 @@
 repos:
   - repo: https://github.com/astral-sh/ruff-pre-commit
     # Ruff version.
-    rev: 'v0.0.284'
+    rev: 'v0.0.285'
     hooks:
       - id: ruff
         args: [--fix, --exit-non-zero-on-fix]
@@ -39,7 +39,7 @@ repos:
         args: ['--baseline', '.secrets.baseline']
         additional_dependencies: ["gibberish-detector"]
   - repo: https://github.com/pre-commit/mirrors-mypy
-    rev: v1.5.0
+    rev: v1.5.1
     hooks:
       - id: mypy
         args: [--no-strict-optional, --ignore-missing-imports]
diff --git a/bumpversion/config.py b/bumpversion/config.py
index b70c6897..fc346e72 100644
--- a/bumpversion/config.py
+++ b/bumpversion/config.py
@@ -122,7 +122,7 @@ def get_all_file_configs(config_dict: dict) -> List[FileConfig]:
         "ignore_missing_version": config_dict["ignore_missing_version"],
         "no_regex": config_dict["no_regex"],
     }
-    files = [{k: v for k, v in filecfg.items() if v} for filecfg in config_dict["files"]]
+    files = [{k: v for k, v in filecfg.items() if v is not None} for filecfg in config_dict["files"]]
     for f in files:
         f.update({k: v for k, v in defaults.items() if k not in f})
     return [FileConfig(**f) for f in files]
diff --git a/docsrc/reference/configuration.md b/docsrc/reference/configuration.md
index 754b8c61..e43cae22 100644
--- a/docsrc/reference/configuration.md
+++ b/docsrc/reference/configuration.md
@@ -236,7 +236,7 @@ This is useful if there is the remotest possibility that the current version num
 
 This is the template to create the string that will replace the current version number in the file.
 
-### `ingore_missing_version`
+### `ignore_missing_version`
 :required: No
 
 :default: `False`
@@ -447,10 +447,10 @@ This is an override to the default template string how to search for the string
 
 This is an override to the template to create the string that will replace the current version number in the file.
 
-### `ingore_missing_version`
+### `ignore_missing_version`
 :required: No
 
-:default: The value configured in the global `ingore_missing_version` field
+:default: The value configured in the global `ignore_missing_version` field
 
 :type: boolean
 
diff --git a/pyproject.toml b/pyproject.toml
index 070b7534..8559f3f7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,9 +1,5 @@
 [build-system]
-
-requires = [
-    "setuptools >= 40.9.0",
-    "wheel",
-]
+requires = ["setuptools"]
 build-backend = "setuptools.build_meta"
 
 [project]
@@ -158,6 +154,7 @@ ignore = [
     "S101", "S104",
     "D105", "D106", "D107", "D200", "D212",
     "PD011",
+    "PLW1510",
 ]
 
 # Allow autofix for all enabled rules (when `--fix`) is provided.
@@ -216,9 +213,9 @@ commit_args = "--no-verify"
 tag = true
 tag_name = "{new_version}"
 allow_dirty = true
-parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)(\\.(?P<dev>dev\\d+))?"
+parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)(\\.(?P<dev>dev)\\d+\\+[-_a-zA-Z0-9]+)?"
 serialize = [
-    "{major}.{minor}.{patch}.{dev}{distance_to_latest_tag}",
+    "{major}.{minor}.{patch}.{dev}{distance_to_latest_tag}+{short_branch_name}",
     "{major}.{minor}.{patch}"
 ]
 message = "Version updated from {current_version} to {new_version}"


Test patch:
diff --git a/tests/test_files.py b/tests/test_files.py
index dfd2caed..96fb6a03 100644
--- a/tests/test_files.py
+++ b/tests/test_files.py
@@ -349,7 +349,16 @@ def test_multi_line_search_is_found(tmp_path: Path) -> None:
     assert alphabet_path.read_text() == "A\nB\nC\n10.0.0\n"
 
 
-def test_ignore_missing_version(tmp_path: Path) -> None:
+@pytest.mark.parametrize(
+    ["global_value", "file_value", "should_raise"],
+    [
+        param(True, True, False, id="ignore global and file"),
+        param(True, False, True, id="ignore global only"),
+        param(False, True, False, id="ignore file only"),
+        param(False, False, True, id="ignore none"),
+    ],
+)
+def test_ignore_missing_version(global_value: bool, file_value: bool, should_raise: bool, tmp_path: Path) -> None:
     """If the version is not found in the file, do nothing."""
     # Arrange
     version_path = tmp_path / Path("VERSION")
@@ -357,16 +366,20 @@ def test_ignore_missing_version(tmp_path: Path) -> None:
 
     overrides = {
         "current_version": "1.2.5",
-        "ignore_missing_version": True,
-        "files": [{"filename": str(version_path)}],
+        "ignore_missing_version": global_value,
+        "files": [{"filename": str(version_path), "ignore_missing_version": file_value}],
     }
-    conf, version_config, current_version = get_config_data(overrides)
-    assert conf.ignore_missing_version is True
-    new_version = current_version.bump("patch", version_config.order)
-    cfg_files = [files.ConfiguredFile(file_cfg, version_config) for file_cfg in conf.files]
-
-    # Act
-    files.modify_files(cfg_files, current_version, new_version, get_context(conf))
+    with inside_dir(tmp_path):
+        conf, version_config, current_version = get_config_data(overrides)
+        new_version = current_version.bump("patch", version_config.order)
+        cfg_files = [files.ConfiguredFile(file_cfg, version_config) for file_cfg in conf.files]
+
+        # Act
+        if should_raise:
+            with pytest.raises(VersionNotFoundError):
+                files.modify_files(cfg_files, current_version, new_version, get_context(conf))
+        else:
+            files.modify_files(cfg_files, current_version, new_version, get_context(conf))
 
     # Assert
     assert version_path.read_text() == "1.2.3"