MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / print_coverage

Method print_coverage

atomic-cli/src/commands/agent/attest.rs:531–579  ·  view source on GitHub ↗

Print coverage per view.

(&self, repo: &Repository, attest: &Attestation)

Source from the content-addressed store, hash-verified

529
530 /// Print coverage per view.
531 fn print_coverage(&self, repo: &Repository, attest: &Attestation) {
532 let views = match repo.list_views() {
533 Ok(s) => s,
534 Err(_) => return,
535 };
536
537 let covered_set: std::collections::HashSet<&Hash> = attest.changes_covered.iter().collect();
538
539 let mut has_coverage = false;
540
541 for view_name in &views {
542 let history = match repo
543 .log(atomic_repository::history::HistoryOptions::default().view(view_name))
544 {
545 Ok(h) => h,
546 Err(_) => continue,
547 };
548
549 let total = history.len();
550 if total == 0 {
551 continue;
552 }
553
554 let covered = history
555 .iter()
556 .filter(|e| covered_set.contains(&e.hash))
557 .count();
558
559 if covered == 0 {
560 continue;
561 }
562
563 if !has_coverage {
564 println!("Coverage:");
565 has_coverage = true;
566 }
567
568 let pct = (covered as f64 / total as f64) * 100.0;
569 let bar_width = 20;
570 let filled = ((pct / 100.0) * bar_width as f64) as usize;
571 let empty = bar_width - filled;
572 let bar = format!("{}{}", "█".repeat(filled), "░".repeat(empty),);
573
574 println!(
575 " {:<20} {} {}/{} ({:.0}%)",
576 view_name, bar, covered, total, pct,
577 );
578 }
579 }
580}
581
582// Formatting Helpers

Callers 1

show_detailMethod · 0.80

Calls 7

logMethod · 0.80
list_viewsMethod · 0.45
iterMethod · 0.45
viewMethod · 0.45
lenMethod · 0.45
countMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected