Parse the file diff log content into structured data.
(log_content: str)
| 52 | |
| 53 | |
| 54 | def parse_diff_log(log_content: str) -> list[dict]: |
| 55 | """Parse the file diff log content into structured data.""" |
| 56 | phases = [] |
| 57 | current_phase = None |
| 58 | |
| 59 | lines = log_content.split("\n") |
| 60 | i = 0 |
| 61 | |
| 62 | while i < len(lines): |
| 63 | line = lines[i].strip() |
| 64 | |
| 65 | # Look for phase headers |
| 66 | if line.startswith("=" * 60): |
| 67 | i += 1 |
| 68 | if i < len(lines) and "FILE DIFF" in lines[i]: |
| 69 | phase_line = lines[i].strip() |
| 70 | phase_match = re.search(r"FILE DIFF - (\w+) PHASE", phase_line) |
| 71 | if phase_match: |
| 72 | phase_name = phase_match.group(1).lower() |
| 73 | i += 1 |
| 74 | |
| 75 | # Get timestamp |
| 76 | timestamp = None |
| 77 | if i < len(lines) and lines[i].strip().startswith("Timestamp:"): |
| 78 | timestamp_str = lines[i].strip().replace("Timestamp:", "").strip() |
| 79 | try: |
| 80 | timestamp = datetime.fromisoformat(timestamp_str) |
| 81 | except ValueError: |
| 82 | pass |
| 83 | i += 1 |
| 84 | |
| 85 | # Initialize phase data |
| 86 | current_phase = { |
| 87 | "name": phase_name, |
| 88 | "timestamp": timestamp, |
| 89 | "added_files": [], |
| 90 | "removed_files": [], |
| 91 | "modified_files": [], |
| 92 | "unified_diffs": {}, |
| 93 | } |
| 94 | phases.append(current_phase) |
| 95 | continue |
| 96 | |
| 97 | # Look for file lists (but don't collect files here - they're listed individually) |
| 98 | if current_phase and ( |
| 99 | "ADDED FILES" in line or "REMOVED FILES" in line or "MODIFIED FILES" in line |
| 100 | ): |
| 101 | # Just skip the header line - files are listed individually with ~ prefix |
| 102 | pass |
| 103 | |
| 104 | # Look for individual file entries (with +, -, or ~ prefix) |
| 105 | if current_phase and lines[i].startswith(" + "): |
| 106 | # This is an added file entry |
| 107 | file_path = lines[i][4:].strip() # Remove the ' + ' prefix |
| 108 | if file_path not in current_phase["added_files"]: |
| 109 | current_phase["added_files"].append(file_path) |
| 110 | elif current_phase and lines[i].startswith(" - "): |
| 111 | # This is a removed file entry |
no outgoing calls
no test coverage detected