(c: &ChangeReport)
| 510 | } |
| 511 | |
| 512 | fn render_change(c: &ChangeReport) -> String { |
| 513 | let cov = html_escape(&c.coverage); |
| 514 | let cov_class = match c.coverage.as_str() { |
| 515 | "covered" => "covered", |
| 516 | "uncovered" => "uncovered", |
| 517 | _ => "unknown", |
| 518 | }; |
| 519 | let (adds, dels) = diff_stat_counts(c); |
| 520 | let stat = if c.diff.is_empty() { |
| 521 | String::new() |
| 522 | } else { |
| 523 | format!( |
| 524 | " <span class=\"stat\">+{adds} -{dels} \u{00b7} {} file(s)</span>", |
| 525 | c.diff.len() |
| 526 | ) |
| 527 | }; |
| 528 | let mut s = String::new(); |
| 529 | // Collapsible, like intents — the summary conveys the change's shape while |
| 530 | // collapsed; the (potentially long) diff lives in the body. |
| 531 | s.push_str("<details class=\"change\">\n"); |
| 532 | s.push_str(&format!( |
| 533 | "<summary><code>{}</code> <span class=\"badge cov-{cov_class}\">{cov}</span>{stat}</summary>\n", |
| 534 | html_escape(&c.id) |
| 535 | )); |
| 536 | if !c.message.is_empty() { |
| 537 | s.push_str(&format!( |
| 538 | "<div class=\"change-msg\">{}</div>\n", |
| 539 | html_escape(&c.message) |
| 540 | )); |
| 541 | } |
| 542 | // Changed files: symbol + path + per-file hunk summary (no diff dump). |
| 543 | if !c.files.is_empty() { |
| 544 | s.push_str("<table class=\"files\">\n"); |
| 545 | for f in &c.files { |
| 546 | s.push_str(&format!( |
| 547 | "<tr><td class=\"sym\">{}</td><td><code>{}</code></td><td class=\"summary\">{}</td></tr>\n", |
| 548 | html_escape(&f.symbol), |
| 549 | html_escape(&f.path), |
| 550 | html_escape(&f.summary) |
| 551 | )); |
| 552 | } |
| 553 | s.push_str("</table>\n"); |
| 554 | } else if !c.modifies.is_empty() { |
| 555 | // Fallback (change not loadable): show the modified file-node ids. |
| 556 | s.push_str("<ul class=\"modifies\">\n"); |
| 557 | for m in &c.modifies { |
| 558 | s.push_str(&format!("<li><code>{}</code></li>\n", html_escape(m))); |
| 559 | } |
| 560 | s.push_str("</ul>\n"); |
| 561 | } |
| 562 | s.push_str(&format!( |
| 563 | "<div class=\"review-cmd\">inspect: <code>{}</code></div>\n", |
| 564 | html_escape(&c.review_command) |
| 565 | )); |
| 566 | // The real code-review surface: inline, color-coded unified diff. |
| 567 | for f in &c.diff { |
| 568 | s.push_str(&render_diff_file(f)); |
| 569 | } |
no test coverage detected