MCPcopy
hub / github.com/nesquena/hermes-webui / _added_lines

Function _added_lines

scripts/ruff_lint.py:88–106  ·  view source on GitHub ↗

Set of NEW-file line numbers added or modified in `path` since merge_base.

(merge_base: str, path: str)

Source from the content-addressed store, hash-verified

86
87
88def _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
109def _ruff_check_json(ruff: list[str], files: list[str]) -> list[dict]:

Callers 1

run_diffFunction · 0.85

Calls 2

_runFunction · 0.70
setFunction · 0.50

Tested by

no test coverage detected