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

Function record_statistics_from_proto

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

Source from the content-addressed store, hash-verified

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

Calls 2

countFunction · 0.85
okMethod · 0.45