(diff_output: str)
| 203 | |
| 204 | |
| 205 | def _get_diff_dict(diff_output: str) -> dict: |
| 206 | diff_dict = {} |
| 207 | current_file = None |
| 208 | current_diff_lines = [] |
| 209 | |
| 210 | lines = diff_output.split("\n") |
| 211 | i = 0 |
| 212 | |
| 213 | while i < len(lines): |
| 214 | line = lines[i] |
| 215 | |
| 216 | if line.startswith("diff --git"): |
| 217 | # Save previous file's diff if exists |
| 218 | if current_file and current_diff_lines: |
| 219 | diff_dict[current_file] = "\n".join(current_diff_lines) |
| 220 | |
| 221 | # Extract file name from diff --git line |
| 222 | parts = line.split(" ") |
| 223 | if len(parts) >= 4: |
| 224 | # Get the b/ path (new file path) |
| 225 | current_file = parts[3][2:] if parts[3].startswith("b/") else parts[3] |
| 226 | current_diff_lines = [] |
| 227 | |
| 228 | # Skip the diff --git line |
| 229 | i += 1 |
| 230 | |
| 231 | # Skip the index line if it exists |
| 232 | while i < len(lines) and ( |
| 233 | lines[i].startswith("index ") |
| 234 | or lines[i].startswith("new file mode ") |
| 235 | or lines[i].startswith("deleted file mode ") |
| 236 | ): |
| 237 | i += 1 |
| 238 | |
| 239 | continue |
| 240 | |
| 241 | # Add all other lines to current diff |
| 242 | if current_file is not None: |
| 243 | current_diff_lines.append(line) |
| 244 | |
| 245 | i += 1 |
| 246 | |
| 247 | # Don't forget the last file |
| 248 | if current_file and current_diff_lines: |
| 249 | diff_dict[current_file] = "\n".join(current_diff_lines) |
| 250 | |
| 251 | return diff_dict |
| 252 | |
| 253 | |
| 254 | def diff(repo_path: Union[str, os.PathLike], previous_frid: str = None) -> dict: |
no outgoing calls
no test coverage detected