| 791 | } |
| 792 | |
| 793 | fn 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)] |
| 824 | mod record_output_tests { |