Skip to content

Commit

Permalink
Fixed normalized paths in is_subpath
Browse files Browse the repository at this point in the history
  • Loading branch information
coordt committed Jan 26, 2025
1 parent 4e993ed commit d1c180b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bumpversion/bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ def commit_and_tag(
Args:
config: The configuration
config_file: The configuration file to include in the commit, if it exists
config_file: The configuration file to include in the commit if it exists
configured_files: A list of files to commit
ctx: The context used to render the tag and tag message
dry_run: True if the operation should be a dry run
"""
if not config.scm_info or not config.scm_info.tool:
if not config.scm_info or not config.scm_info.tool: # pragma: no-coverage
return

commit_files = {f.file_change.filename for f in configured_files}
Expand Down
6 changes: 5 additions & 1 deletion bumpversion/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,8 @@ def run_command(command: list, env: Optional[dict] = None) -> CompletedProcess:

def is_subpath(parent: Path | str, path: Path | str) -> bool:
"""Return whether a path is inside the parent."""
return str(path).startswith(str(parent)) if Path(path).is_absolute() else True
normalized_parent = Path(parent).resolve()
normalized_path = Path(path).resolve()
print(f"normalized_parent: {normalized_parent}")
print(f"normalized_path: {normalized_path}")
return str(normalized_path).startswith(str(normalized_parent)) if normalized_path.is_absolute() else True

0 comments on commit d1c180b

Please # to comment.