Skip to content

Commit ff3f72a

Browse files
committed
Fixes repository path checks
Checked for relative paths when determining if the file was part of the repo or not.
1 parent 72f9841 commit ff3f72a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

bumpversion/scm.py

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def path_in_repo(self, path: Union[Path, str]) -> bool:
5252
"""Return whether a path is inside this repository."""
5353
if self.repository_root is None:
5454
return True
55+
elif not Path(path).is_absolute():
56+
return True
5557

5658
return str(path).startswith(str(self.repository_root))
5759

tests/test_bump.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def test_changes_to_files_are_committed(git_repo: Path, caplog):
367367
"""
368368
[tool.bumpversion]
369369
current_version = "0.1.26"
370-
allow_dirty = true
370+
tag_name = "{new_version}"
371371
commit = true
372372
373373
[[tool.bumpversion.files]]
@@ -394,6 +394,7 @@ def test_changes_to_files_are_committed(git_repo: Path, caplog):
394394
with inside_dir(git_repo):
395395
run_command(["git", "add", str(chart1_path), str(chart2_path), str(config_path)])
396396
run_command(["git", "commit", "-m", "Initial commit"])
397+
run_command(["git", "tag", "0.1.26"])
397398

398399
# Act
399400
from click.testing import CliRunner, Result
@@ -420,7 +421,7 @@ def test_changes_to_files_are_committed(git_repo: Path, caplog):
420421
"""
421422
[tool.bumpversion]
422423
current_version = "0.2.0"
423-
allow_dirty = true
424+
tag_name = "{new_version}"
424425
commit = true
425426
426427
[[tool.bumpversion.files]]
@@ -442,3 +443,6 @@ def test_changes_to_files_are_committed(git_repo: Path, caplog):
442443
443444
"""
444445
)
446+
with inside_dir(git_repo):
447+
status = run_command(["git", "status", "--porcelain"])
448+
assert status.stdout == ""

0 commit comments

Comments
 (0)