Auto-detect VCS and return changed line ranges per file. Dispatches to :func:`parse_git_diff_ranges` for Git repositories and :func:`parse_svn_diff_ranges` for SVN working copies. Args: repo_root: Absolute path to the repository/working-copy root. base: For Git: the ref
(
repo_root: str,
base: str = "HEAD~1",
)
| 111 | |
| 112 | |
| 113 | def parse_diff_ranges( |
| 114 | repo_root: str, |
| 115 | base: str = "HEAD~1", |
| 116 | ) -> dict[str, list[tuple[int, int]]]: |
| 117 | """Auto-detect VCS and return changed line ranges per file. |
| 118 | |
| 119 | Dispatches to :func:`parse_git_diff_ranges` for Git repositories and |
| 120 | :func:`parse_svn_diff_ranges` for SVN working copies. |
| 121 | |
| 122 | Args: |
| 123 | repo_root: Absolute path to the repository/working-copy root. |
| 124 | base: For Git: the ref to diff against (default ``HEAD~1``). |
| 125 | For SVN: an optional revision range (e.g. ``"r100:HEAD"``); |
| 126 | when *base* is not a valid SVN revision, working-copy changes |
| 127 | (``svn diff``) are used instead. |
| 128 | """ |
| 129 | root_path = Path(repo_root) |
| 130 | if (root_path / ".svn").exists(): |
| 131 | rev_range = base if _SAFE_SVN_REV.match(base) else None |
| 132 | return parse_svn_diff_ranges(repo_root, rev_range) |
| 133 | return parse_git_diff_ranges(repo_root, base) |
| 134 | |
| 135 | |
| 136 | def _parse_unified_diff(diff_text: str) -> dict[str, list[tuple[int, int]]]: |
no test coverage detected