List the files changed between two Git refs, filtered by change type.
(ref_a: str, ref_b: str, filter_mode: str = "")
| 45 | |
| 46 | |
| 47 | def get_diff_files(ref_a: str, ref_b: str, filter_mode: str = "") -> set[Path]: |
| 48 | """List the files changed between two Git refs, filtered by change type.""" |
| 49 | added_files_result = subprocess.run( |
| 50 | [ |
| 51 | "git", |
| 52 | "diff", |
| 53 | f"--diff-filter={filter_mode}", |
| 54 | "--name-only", |
| 55 | f"{ref_a}...{ref_b}", |
| 56 | "--", |
| 57 | ], |
| 58 | stdout=subprocess.PIPE, |
| 59 | check=True, |
| 60 | text=True, |
| 61 | encoding="UTF-8", |
| 62 | ) |
| 63 | |
| 64 | added_files = added_files_result.stdout.strip().split("\n") |
| 65 | return {Path(file.strip()) for file in added_files if file.strip()} |
| 66 | |
| 67 | |
| 68 | def get_diff_lines(ref_a: str, ref_b: str, file: Path) -> list[int]: |
no test coverage detected
searching dependent graphs…