@@ -201,12 +201,14 @@ def test_listing_with_version_part(tmp_path: Path, fixtures_path: Path):
201
201
"DEPRECATED: The --list option is deprecated and will be removed in a future version." ,
202
202
"new_version=1.0.1-dev" ,
203
203
"current_version=1.0.0" ,
204
+ "excluded_paths=[]" ,
204
205
"parse=(?P<major>\\ d+)\\ .(?P<minor>\\ d+)\\ .(?P<patch>\\ d+)(\\ -(?P<release>[a-z]+))?" ,
205
206
"serialize=['{major}.{minor}.{patch}-{release}', '{major}.{minor}.{patch}']" ,
206
207
"search={current_version}" ,
207
208
"replace={new_version}" ,
208
209
"no_regex=False" ,
209
210
"ignore_missing_version=False" ,
211
+ "included_paths=[]" ,
210
212
"tag=True" ,
211
213
"sign_tags=False" ,
212
214
"tag_name=v{new_version}" ,
@@ -254,12 +256,14 @@ def test_listing_without_version_part(tmp_path: Path, fixtures_path: Path):
254
256
"" ,
255
257
"DEPRECATED: The --list option is deprecated and will be removed in a future version." ,
256
258
"current_version=1.0.0" ,
259
+ "excluded_paths=[]" ,
257
260
"parse=(?P<major>\\ d+)\\ .(?P<minor>\\ d+)\\ .(?P<patch>\\ d+)(\\ -(?P<release>[a-z]+))?" ,
258
261
"serialize=['{major}.{minor}.{patch}-{release}', '{major}.{minor}.{patch}']" ,
259
262
"search={current_version}" ,
260
263
"replace={new_version}" ,
261
264
"no_regex=False" ,
262
265
"ignore_missing_version=False" ,
266
+ "included_paths=[]" ,
263
267
"tag=True" ,
264
268
"sign_tags=False" ,
265
269
"tag_name=v{new_version}" ,
@@ -517,3 +521,52 @@ def test_replace_search_with_plain_string(tmp_path, fixtures_path):
517
521
print (traceback .print_exception (result .exc_info [1 ]))
518
522
519
523
assert result .exit_code == 0
524
+
525
+
526
+ def test_valid_regex_not_ignoring_regex (tmp_path : Path , caplog ) -> None :
527
+ """A search string not meant to be a regex (but is) is still found and replaced correctly."""
528
+ # Arrange
529
+ search = "(unreleased)"
530
+ replace = "(2023-01-01)"
531
+
532
+ version_path = tmp_path / "VERSION"
533
+ version_path .write_text ("# Changelog\n \n ## [0.0.1 (unreleased)](https://cool.url)\n \n - Test unreleased package.\n " )
534
+ config_file = tmp_path / ".bumpversion.toml"
535
+ config_file .write_text (
536
+ "[tool.bumpversion]\n "
537
+ 'current_version = "0.0.1"\n '
538
+ "allow_dirty = true\n \n "
539
+ "[[tool.bumpversion.files]]\n "
540
+ 'filename = "VERSION"\n '
541
+ "no_regex = true\n "
542
+ f'search = "{ search } "\n '
543
+ f'replace = "{ replace } "\n '
544
+ )
545
+
546
+ # Act
547
+ runner : CliRunner = CliRunner ()
548
+ with inside_dir (tmp_path ):
549
+ result : Result = runner .invoke (
550
+ cli .cli ,
551
+ [
552
+ "replace" ,
553
+ "--verbose" ,
554
+ "--no-regex" ,
555
+ "--no-configured-files" ,
556
+ "--search" ,
557
+ search ,
558
+ "--replace" ,
559
+ replace ,
560
+ "VERSION" ,
561
+ ],
562
+ )
563
+
564
+ # Assert
565
+ if result .exit_code != 0 :
566
+ print (result .output )
567
+
568
+ assert result .exit_code == 0
569
+ assert (
570
+ version_path .read_text ()
571
+ == "# Changelog\n \n ## [0.0.1 (2023-01-01)](https://cool.url)\n \n - Test unreleased package.\n "
572
+ )
0 commit comments