Extract file paths from `git status --porcelain` output. Handles rename entries ("R old -> new") by returning the new path, and strips the leading 3-character status field.
(porcelain: str)
| 114 | |
| 115 | |
| 116 | def _parse_porcelain_paths(porcelain: str) -> list[str]: |
| 117 | """Extract file paths from `git status --porcelain` output. |
| 118 | |
| 119 | Handles rename entries ("R old -> new") by returning the new path, and |
| 120 | strips the leading 3-character status field. |
| 121 | """ |
| 122 | paths: list[str] = [] |
| 123 | for line in porcelain.splitlines(): |
| 124 | if len(line) < 4: |
| 125 | continue |
| 126 | # Format: XY <path> (or "R old -> new" for renames) |
| 127 | rest = line[3:] |
| 128 | if " -> " in rest: |
| 129 | rest = rest.split(" -> ", 1)[1] |
| 130 | # Strip optional surrounding quotes that git uses for paths with |
| 131 | # special characters |
| 132 | rest = rest.strip() |
| 133 | if rest.startswith('"') and rest.endswith('"'): |
| 134 | rest = rest[1:-1] |
| 135 | if rest: |
| 136 | paths.append(rest) |
| 137 | return paths |
| 138 | |
| 139 | |
| 140 | def classify_changes(porcelain: str) -> ChangeBuckets: |
no test coverage detected