Parses `git log --pretty=%H %ct` output into `(sha, committed_at)` pairs, capping at `max`. Malformed and non-hex lines are skipped. Pure.
(log_text: &str, max: usize)
| 319 | /// Parses `git log --pretty=%H %ct` output into `(sha, committed_at)` pairs, |
| 320 | /// capping at `max`. Malformed and non-hex lines are skipped. Pure. |
| 321 | pub fn parse_commit_log(log_text: &str, max: usize) -> Vec<(String, i64)> { |
| 322 | let mut commits = Vec::new(); |
| 323 | for line in log_text.lines() { |
| 324 | if commits.len() >= max { |
| 325 | break; |
| 326 | } |
| 327 | let mut parts = line.split_whitespace(); |
| 328 | let Some(sha) = parts.next() else { continue }; |
| 329 | let Some(ts) = parts.next().and_then(|t| t.parse::<i64>().ok()) else { |
| 330 | continue; |
| 331 | }; |
| 332 | if sha.len() >= 7 && sha.chars().all(|c| c.is_ascii_hexdigit()) { |
| 333 | commits.push((sha.to_ascii_lowercase(), ts)); |
| 334 | } |
| 335 | } |
| 336 | commits |
| 337 | } |
| 338 | |
| 339 | /// Runs the historical backfill against one project's session store. |
| 340 | /// |