MCPcopy Index your code
hub / github.com/tirth8205/code-review-graph / parse_diff_ranges

Function parse_diff_ranges

code_review_graph/changes.py:113–133  ·  view source on GitHub ↗

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",
)

Source from the content-addressed store, hash-verified

111
112
113def 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
136def _parse_unified_diff(diff_text: str) -> dict[str, list[tuple[int, int]]]:

Callers 2

analyze_changesFunction · 0.85
detect_changes_funcFunction · 0.85

Calls 2

parse_svn_diff_rangesFunction · 0.85
parse_git_diff_rangesFunction · 0.85

Tested by

no test coverage detected