(logOutput: string)
| 74 | } |
| 75 | |
| 76 | export function parseGitLog(logOutput: string): CommitInfo[] { |
| 77 | if (!logOutput.trim()) return []; |
| 78 | |
| 79 | const commits: CommitInfo[] = []; |
| 80 | const lines = logOutput.trim().split("\n"); |
| 81 | |
| 82 | for (const line of lines) { |
| 83 | if (!line.trim()) continue; |
| 84 | |
| 85 | // Format: hash|shortHash|message|description|author|date |
| 86 | // Use slice to preserve '|' characters in commit messages/descriptions |
| 87 | const parts = line.split("|"); |
| 88 | if (parts.length < 6) continue; |
| 89 | |
| 90 | const hash = parts[0]?.trim(); |
| 91 | const shortHash = parts[1]?.trim(); |
| 92 | const message = parts[2]?.trim(); |
| 93 | // Description is between message and last 2 parts (author, date) |
| 94 | const description = parts.slice(3, -2).join("|").trim(); |
| 95 | const author = parts[parts.length - 2]?.trim(); |
| 96 | const dateStr = parts[parts.length - 1]?.trim(); |
| 97 | |
| 98 | if (!hash || !shortHash) continue; |
| 99 | |
| 100 | let date: Date; |
| 101 | if (dateStr) { |
| 102 | const parsed = new Date(dateStr); |
| 103 | date = Number.isNaN(parsed.getTime()) ? new Date() : parsed; |
| 104 | } else { |
| 105 | date = new Date(); |
| 106 | } |
| 107 | |
| 108 | commits.push({ |
| 109 | hash, |
| 110 | shortHash, |
| 111 | message: message || "", |
| 112 | description: description || undefined, |
| 113 | author: author || "", |
| 114 | date, |
| 115 | files: [], |
| 116 | }); |
| 117 | } |
| 118 | |
| 119 | return commits; |
| 120 | } |
| 121 | |
| 122 | export function parseDiffNumstat( |
| 123 | numstatOutput: string, |
no outgoing calls
no test coverage detected