Skip to content

Commit

Permalink
Fixes repository path checks
Browse files Browse the repository at this point in the history
Checked for relative paths when determining if the file was part of the repo or not.
  • Loading branch information
coordt committed Aug 7, 2024
1 parent 72f9841 commit ff3f72a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions bumpversion/scm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
8 changes: 6 additions & 2 deletions tests/test_bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand All @@ -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
Expand All @@ -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]]
Expand All @@ -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 == ""

0 comments on commit ff3f72a

Please sign in to comment.