diff --git a/bumpversion/scm.py b/bumpversion/scm.py index f98b8db8..c8cd6d83 100644 --- a/bumpversion/scm.py +++ b/bumpversion/scm.py @@ -52,6 +52,8 @@ def path_in_repo(self, path: Union[Path, str]) -> bool: """Return whether a path is inside this repository.""" if self.repository_root is None: return True + elif not Path(path).is_absolute(): + return True return str(path).startswith(str(self.repository_root)) diff --git a/tests/test_bump.py b/tests/test_bump.py index 13e5b72e..a376af4c 100644 --- a/tests/test_bump.py +++ b/tests/test_bump.py @@ -367,7 +367,7 @@ def test_changes_to_files_are_committed(git_repo: Path, caplog): """ [tool.bumpversion] current_version = "0.1.26" - allow_dirty = true + tag_name = "{new_version}" commit = true [[tool.bumpversion.files]] @@ -394,6 +394,7 @@ def test_changes_to_files_are_committed(git_repo: Path, caplog): with inside_dir(git_repo): run_command(["git", "add", str(chart1_path), str(chart2_path), str(config_path)]) run_command(["git", "commit", "-m", "Initial commit"]) + run_command(["git", "tag", "0.1.26"]) # Act from click.testing import CliRunner, Result @@ -420,7 +421,7 @@ def test_changes_to_files_are_committed(git_repo: Path, caplog): """ [tool.bumpversion] current_version = "0.2.0" - allow_dirty = true + tag_name = "{new_version}" commit = true [[tool.bumpversion.files]] @@ -442,3 +443,6 @@ def test_changes_to_files_are_committed(git_repo: Path, caplog): """ ) + with inside_dir(git_repo): + status = run_command(["git", "status", "--porcelain"]) + assert status.stdout == ""