From ff3f72a9a922dfbb61eea9325fc9dba7c12c7f62 Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Wed, 7 Aug 2024 13:25:00 -0500 Subject: [PATCH] Fixes repository path checks Checked for relative paths when determining if the file was part of the repo or not. --- bumpversion/scm.py | 2 ++ tests/test_bump.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) 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 == ""