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

Function record_statistics_from_proto

atomic-cli/src/commands/rpc.rs:794–822  ·  view source on GitHub ↗
(
    statistics: &pb::RecordStatistics,
)

Source from the content-addressed store, hash-verified

792}
793
794fn record_statistics_from_proto(
795 statistics: &pb::RecordStatistics,
796) -> Option<atomic_repository::record::RecordStats> {
797 let count = |value| usize::try_from(value).ok();
798 let stats = atomic_repository::record::RecordStats {
799 files_recorded: count(statistics.files_recorded)?,
800 directories_recorded: count(statistics.directories_recorded)?,
801 hunks_created: count(statistics.hunks_created)?,
802 vertices_added: count(statistics.vertices_added)?,
803 edges_modified: count(statistics.edges_modified)?,
804 content_bytes: statistics.content_bytes,
805 lines_added: count(statistics.lines_added)?,
806 lines_deleted: count(statistics.lines_deleted)?,
807 lines_modified: count(statistics.lines_modified)?,
808 tokens_added: count(statistics.tokens_added)?,
809 tokens_deleted: count(statistics.tokens_deleted)?,
810 tokens_replaced: count(statistics.tokens_replaced)?,
811 ..Default::default()
812 };
813 stats
814 .lines_added
815 .checked_add(stats.lines_deleted)?
816 .checked_add(stats.lines_modified)?;
817 stats
818 .tokens_added
819 .checked_add(stats.tokens_deleted)?
820 .checked_add(stats.tokens_replaced)?;
821 Some(stats)
822}
823
824#[cfg(test)]
825mod record_output_tests {

Calls 2

countFunction · 0.70
okMethod · 0.45