Set of NEW-file line numbers added or modified in `path` since merge_base.
(merge_base: str, path: str)
| 86 | |
| 87 | |
| 88 | def _added_lines(merge_base: str, path: str) -> set[int]: |
| 89 | """Set of NEW-file line numbers added or modified in `path` since merge_base.""" |
| 90 | diff = _run(["git", "diff", "--unified=0", merge_base, "HEAD", "--", path]) |
| 91 | added: set[int] = set() |
| 92 | new_ln = 0 |
| 93 | for line in diff.stdout.splitlines(): |
| 94 | m = _HUNK_RE.match(line) |
| 95 | if m: |
| 96 | new_ln = int(m.group(1)) |
| 97 | continue |
| 98 | if line.startswith("+") and not line.startswith("+++"): |
| 99 | added.add(new_ln) |
| 100 | new_ln += 1 |
| 101 | elif line.startswith("-") and not line.startswith("---"): |
| 102 | # deletion: new-file pointer does not advance |
| 103 | continue |
| 104 | elif not line.startswith(("@@", "diff ", "index ", "--- ", "+++ ")): |
| 105 | new_ln += 1 |
| 106 | return added |
| 107 | |
| 108 | |
| 109 | def _ruff_check_json(ruff: list[str], files: list[str]) -> list[dict]: |