Parse one raw line from a .graphifyignore file per gitignore spec. - Strip newline chars - Strip inline comments (whitespace + # suffix), but only when # is preceded by whitespace — so path#with#hash.py is preserved - Unescape \\# to literal # - Remove trailing spaces unless e
(raw: str)
| 713 | |
| 714 | |
| 715 | def _parse_gitignore_line(raw: str) -> str: |
| 716 | """Parse one raw line from a .graphifyignore file per gitignore spec. |
| 717 | |
| 718 | - Strip newline chars |
| 719 | - Strip inline comments (whitespace + # suffix), but only when # is |
| 720 | preceded by whitespace — so path#with#hash.py is preserved |
| 721 | - Unescape \\# to literal # |
| 722 | - Remove trailing spaces unless escaped with backslash |
| 723 | - Strip leading whitespace |
| 724 | - Return empty string for blank lines and full-line comments |
| 725 | """ |
| 726 | line = raw.rstrip("\n\r") |
| 727 | line = line.lstrip() |
| 728 | if not line or line.startswith("#"): |
| 729 | return "" |
| 730 | # Strip inline comments: require whitespace before # (gitignore extension) |
| 731 | line = re.sub(r"\s+#+[^\\].*$", "", line) |
| 732 | # Unescape \# → literal # |
| 733 | line = line.replace("\\#", "#") |
| 734 | # Remove unescaped trailing spaces (per gitignore spec) |
| 735 | line = re.sub(r"(?<!\\) +$", "", line) |
| 736 | return line |
| 737 | |
| 738 | |
| 739 | def _find_vcs_root(start: Path) -> Path | None: |
no outgoing calls
no test coverage detected